Posts

Showing posts from June, 2010

ios - Clip to bounds of a different UIImageView -

i have 2 uiimageview s, imageview1 , imageview2 . i've set self.imageview1.clipstobounds = yes; but wondering if possible set imageview1 cliptobounds of imageview2 ? not easily. "right" way use clipping path on imageview1 's layer. however, can same effect more follows. put imageview1 centered inside container uiview , , turn view's clipstobounds on. then: if you're using auto layout, constrain container view's size equal size of imageview2 . if you're not using auto layout, set bounds of container view size of imageview2 whenever calculate layout.

excel - Pivot like query access -

i having huge database of records , i'm finding nightmare getting analyse data. objective: group data country of purchase (rows), years/months (rows), product (columns) sum of paid amount being value. let me explain: below sample excerpt table. mytable http://i57.tinypic.com/2ijhi83.png and here result looking able achieve using excel pivot table: mypivot http://i60.tinypic.com/flvvjo.png why use ms access: table has on 3 million records stored across many workbooks, , excel has limit of 1m in each sheet. excel crashes more not when loading >500k of data. i installed older version of ms access (2010) has pivot tables option slow , did not allow me group correctly. tried using combination of queries , reports arrive result no avail. any welcome :) how doing aggregation in access , pivot in excel? select country, year, month, product, sum(paid) mytable group country, year, month, product ( year , month based on access functions date manipula

Customize background in Firefox Responsive Design View -

Image
is there way customize screen background in firefox "responsive design view"? insert image (for instance blank iphone template) , use screen recording software simulate mobile demo. far tell there no way change background, either via css or other addons. i looked @ firefox os simulator, doesn't cover needs (and can't use addons firebug or agent spoofer). without knowing have tried, have guess @ need answer question. need know selectors are? need informed how apply css? trying make add-on makes such modifications? without more information, here general information css used style this: responsive mode styled css in chrome://browser/content/browser.css , chrome://browser/skin/browser.css . both of these located within omni.ja (zip archive filename extension changed .ja ) file in browser directory. within archive above files chrome/browser/content/browser/browser.css , chrome/browser/skin/classic/browser/browser.css , , chrome/browser/skin/classi

html - utf-8 character in different font -

Image
so have says paieška , š, utf 8 character in different font: here's code: <h2 class="section-title">paieška</h2> .section-title, .section-highlight { padding-bottom: 24px; position: relative; margin-bottom: 40px; margin-top: 60px; text-align: center; clear: both; display: inline-block; width: 100%; } how can fix ? this case of font substitution . when chosen font lacking character, unicode renderers can use same character substitution font instead. alternative render placeholder � . better ugly unreadable. to avoid problem, use font supports characters use. if want font, can specify fallback fonts similar possible original font, while containing more characters. remember, css lets specify list of fonts, should tried in order renderer.

sql - Merge a column with results from an ActiveRecord query in Rails -

i have 3 following tables in ruby on rails 4: the "decision" table: class decision < activerecord::base validates :title, presence: true, length: { maximum: 50 }, uniqueness: { case_sensitive: false } validates :colour, presence: true, length: { maximum: 20 }, uniqueness: { case_sensitive: false } has_many :decision_datafields, dependent: :destroy has_many :datafields, through: :decision_datafields def datafields datafield.where(id: self.decision_datafields.select("datafield_id")) end end the "decisiondatafield" table (linking table): class decisiondatafield < activerecord::base validates :min_score, presence: true validates_inclusion_of :min_score, :in => 1..10 belongs_to :decision belongs_to :datafield end the "datafield" table: class datafield < activerecord::base validates :title, presence: true, length: { maximum: 100 }, uniqueness: { case_sensitive: fa

random - How to check if an item is already in a listbox in vb6 -

i'm working vb6 , want generate multiple randum numbers (the range detirmend user , number of generated answers) , send them listbox don't want duplicate generated numbers so.. want before sending generated number listbox check if exists in lisbox. if exists generate number if does't send the listbox here have till max , min range chose numbers between answers number of generated numbers randomize = 1 answers step 1 generated = cint(int((max - min + 1) * rnd() + min)) n = 0 list1.listcount if list1.list(n) <> gen list1.additem (gen) else if list1.list = gen 'i don't know here '(how go generate number) next n next thank in advance keep in minde need keep things simple thank soo much use boolean value keep result if same value generated in list. private sub addrandomnumbers() dim blniffound boolean dim max integer dim min integer

android - How to check if GPS is connected and the position updated -

the gps needs connected gps satellite track position in realtime. problem lose connection , if invoke locationmanager.getlastknownlocation(provider); i last known location may differ actual position. how check if gps connected , position updated before invoke / use getlastknownlocation ? implement gpsstatus.listener interface on activity or service : public class locationactivity extends activity implements gpsstatus.listener { private locationmanager locationmanager; @override public void oncreate(bundle savdedinstancestate) .... .... locationmanager = (locationmanager)getsystemservice(location_service); locationmanager.addgpsstatuslistener(this); } @override public void ongpsstatuschanged(int event) { switch (event) { case gpsstatus.gps_event_satellite_status: break; case gpsstatus.gps_event_first_fix: /* when gps activated; add code here how want application

javascript - Set DIV height for each by it's data-attribute -

i trying loop through on each div has class of block , set it's height individually based on it's data-attribute data-height html <div class="block" data-height="300"></div> <div class="block" data-height="500"></div> <div class="block" data-height="700"></div> jquery $('.block').each(function(){ var size = $this.attr('data-height'); $(this).height(size); }); js fiddle http://jsfiddle.net/mlnby/166/ it's not returning height when have in each method though not setting height each one. the problem in $this ; replace $(this) var size = $(this).attr('data-height');

php - Zend and Social Engine 4 - getting zend database configuration information -

before hand - regarding issue! running social engine 4.8.7 trying information default zend database configuration settings , new zend framework. the internet has yielded many answers in none work... in our controller have tried: $this->getinvokearg('bootstrap')->getoptions() - fatal error: call undefined method ::getinvokearg() new zend_config($this->getoptions()); - fatal error: call undefined method ::getoptions() $this->application->getoptions() - fatal error: call undefined method ::getoptions() zend_controller_front::getinstance()->getparam('bootstrap')->getoptions(); - returns empty array " array(0) { } " zend_registry::get('db') - gives null zend_registry::getinstance()['db'] - gives null and have tried many other suggestions either give null or fatal errors our controller.php at current our temporary solution not elegant @ works: $config = new zend_config(include 'applicati

r - dplyr summarize with a function of a dataframe -

i'm having trouble carrying out routine using dplyr package. in short, have function takes dataframe input, , returns single (numeric) value; i'd able apply function several subsets of dataframe. feels should able use group_by() specify subsets of dataframe, pipe along summarize() function, i'm not sure how pass (subsetted) dataframe along function i'd apply. as simplified example, let's i'm using iris dataset, , i've got simple function i'd apply several subsets of data: data(iris) lm.func = function(.data){ lm.fit = lm(petal.width ~ petal.length, data = .data) out = summary(lm.fit)$coefficients[2,1] return(out) } now, i'd able apply function subsets of iris based on other variable, species . i'm able manually filter data, pipe along function, example: iris %>% filter(species == "setosa") %>% lm.func(.) but i'd able apply lm.func each subset of data, based on species. first thought try following:

swing - Add 3 panels to a frame in java with JSplitPane? -

Image
trying add 3 panels created frame in java jsplitpane. have tried 2 panels, , worked great, 3 still not want. have read making 2 jsplitpanes , put 1 in other, not work do. my code shows there 3 panels, size wrong.. should filled out. my code: frame = new jframe(); // create new frame frame.setvisible(true); // makes visible frame.setsize(900, 500); // sets size frame.settitle(""); // sets title frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setlocationrelativeto(null); // sets window on center of screen temp_panel = new jpanel(); // creates new jpanel water_panel = new jpanel(); // creates new jpanel power_panel = new jpanel(); // creates new jpanel temp_panel.setbackground(color.decode("#2ecc71")); // sets color water_panel.setbackground(color.decode("#3498db")); // sets color power_panel.setbackground(color.decode("#f1c40f")); // sets color temp_labe

Cluster assignment remapping -

i have test classification datasets uci machine learning repository labelled. i stripping of labels , using data benchmark few clustering algorithm , planning use external validation methods. run algorithm different initial configurations, say, 50 times , take mean value. 50 iterations algorithm labels data points of 1 single cluster different numbers. because in each run cluster labels can change, because each iteration might have different cluster assignments, how somehow remap each of clusters 1 uniform numbering. primary idea remap checking how many of points in class labels intersect maximum in actual labels , making remap based on that, can incorrect remappings because when classes have more or less equal number of points, not work. another idea keep labels while clustering, make clustering algorithm ignore it. way cluster data have label tags. doable have have benchmarked cluster assignment data processed therefore trying avoid modifying , re-benchmarking implementatio

mysql - The query takes a long time -

am doing sql code right? query works, takes long, 161 seconds (with limit 2 set). there way optimize that? select p.itemid `id`, p.title `name`, pb.data_txt `birthdate`, pc.data_txt `growth`, pd.data_txt `eyes`, pe.data_txt `desc`, pf.data_txt `weight`, pg.data_txt `sex`, ph.data_txt `hair`, pi.data_txt `dimensions`, pj.data_txt `lang`, pk.data_txt `school`, pl.data_txt `know`, p.image `image` `jos_sobi2_item` p inner join `jos_sobi2_fields_data` pb on pb.itemid = p.itemid inner join `jos_sobi2_fields_data` pc on pc.itemid = p.itemid inner join `jos_sobi2_fields_data` pd on pd.itemid = p.itemid inner join `jos_sobi2_fields_data` pe on pe.itemid = p.itemid inner join `jos_sobi2_fields_data` pf on pf.itemid = p.itemid inner join `jos_sobi2_fields_data` pg on pg.itemid = p.itemid inner join `jos_sobi2_fields_data` ph on ph.itemid = p.itemid inner join `jos_sobi2_fields_data` pi on pi.item

ostringstream - Convert array of uint8_t to string in C++ -

i have array of type uint8_t. want create string concatenates each element of array. here attempt using ostringstream, string seems empty afterward. std::string key = ""; std::ostringstream convert; (int = 0; < key_size_; a++) { convert << key_arr[a] key.append(convert.str()); } cout << key << endl; try this: std::ostringstream convert; (int = 0; < key_size_; a++) { convert << (int)key[a]; } std::string key_string = convert.str(); std::cout << key_string << std::endl; the ostringstream class string builder. can append values it, , when you're done can call it's .str() method std::string contains put it. you need cast uint8_t values int before add them ostringstream because if don't treat them chars. on other hand, if represent chars, need remove (int) cast see actual characters. edit: if array contains 0x1f 0x1f 0x1f , want string 1f1

c# - RedirectTo a tab in the same aspx page using a case statement -

i have site there 5 tabs on 1 page. "next" , "back" buttons work navigating between tabs, using enum tab references , using redirectto in case statement navigate between tabs. tabs' urls #whathappened, etc. not working, happens url changes reflect new address old tab active , data gone tab though using function save, why not using javascript this. any ideas great. code in save function... protected void saveeventdetails(object sender, commandeventargs e) { bool issubmitted = false; pagelocation pagelocation = (pagelocation)session["pagelocation"]; switch (e.commandname) { case "back": if (_eventid == 0) { save(false, mode.edit, status.save); redirectto(pagelocation - 1); } else update(_eventid, false, status.s

Skipping rows in HTML Table -

i trying create html tables desired result of |----html page----------------------| | | | ---table-------------------------| | | t | text | text | | | e |----------------------| | | x | image | image | | | t |----------------------| | | | text | text | | | |----------------------- | | | image | image | | |---------|----------------------- but table isn't skipping rows when tried add <td> before text column. how skip column without adding rows or how make table display on right side of page? <div> <table border="1" width="100%"> <tbody> <tr> <td>description</td> <tr> <th>math</th> <th>scienc</th> </tr> <tr> <td>

osx - Using DualShock 4 from OS X -

on whim bought sony dualshock 4 wireless game controller. pairing controller mac easy. controller works expected in openemu. now want use controller in own game. in xcode playground, tried this: import cocoa; import gamecontroller; print(gccontroller.controllers()) print(gccontroller.controllers().count) the output is: [] 0 this means dualshock controller wasn't registered gccontroller. should it? is there kind of initialization needs done before invoking controllers? an example objective-c or swift welcome. there's tutorial here: http://www.raywenderlich.com/forums/viewtopic.php?f=21&t=10339 seems suggest dualshock 4 isn't supported gamecontroller framework. see apple documentation, begin here: https://developer.apple.com/library/mac/documentation/servicesdiscovery/conceptual/gamecontrollerpg/discoveringcontrollers/discoveringcontrollers.html explains how discover , connect controllers.

Postgresql: Using an index type as a data type? -

i'm trying extract row fields part of primary index of table. (as record) example, if create table this: create table t1 (k1 int not null, k2 int not null, label text, primary key(k1, k2)); insert t1(k1,k2,label) values (3,5,'hello'); then can : select * json_populate_record(null::t1, '{}'); k1 | k2 | label ----+----+------- | | (1 row) ...or can do... select row_to_json(row) (select * t1) row; row_to_json --------------------------------- {"k1":3,"k2":5,"label":"hello"} (1 row) but, want : select * json_populate_record(null::t1_pkey, '{}'); k1 | k2 | ----+----+ | | (1 row) ... or ... select row_to_json(row::t1_pkey) (select * t1) row; row_to_json --------------------------------- {"k1":3,"k2":5} (1 row) but, problem: error: type "t1_pkey" not exist this type exists somewhere because : \d

c# - GridView with responsive FooTable plugin breaks with paging -

i trying implement responsive design in gridview using jquery footable plugin, seem getting caught when trying implement paging gridview. style seems break, , try force regular gridview when click on second page. looks fine when loads. how can solve this? my code gridview follows: <asp:gridview id="gv_programbykeyword" runat="server" visible="false" allowpaging="true" autogeneratecolumns="false" datasourceid="ods_programbykeyword" cssclass="footable" gridlines="none"> <columns> <asp:boundfield datafield="programname" headertext="program" sortexpression="programname" /> <asp:boundfield datafield="credentialtype" headertext="credential" sortexpression="credentialtype" /> <asp:boundfield datafield="categoryname" headertext="category" sortexpression="categoryname" /&g

java - Singleton between many classes? -

i've got quite disturbing problem singleton in project. created class called singleton (how creative) variable string name; then created class called player take name of user. and main class want save data kept in singleton. the problem is, saves name of user if take in main class..it seems not work in other classes. what reason ? how fix it? advice :) here's singleton class: private string name; public void setname(string name) { this.name = name; } public string getname( ) { return this.name; } private static singleton instance = null; protected singleton() { } public static singleton getinstance() { if(instance == null) { instance = new singleton(); } return instance; } this class take name of user: public class newmain { public newmain() { string u_name="agrfd"; singleton.getinstance().setname(u_name)

php - Get Chinese characters from MySQL -

i trying display chinese characters have saved in mysql database, saved under utf8_unicode_ci type. have seen several solutions on web, nothing works. below connection file: $conn = mysql_connect("localhost","root","password"); mysql_set_charset('utf8',$conn); mysql_query("set character set utf8 "); mysql_select_db("database"); below query: mysql_query("set character_set_results=utf8", $conn); $sql = mysql_query("select * webdata",$conn); but still shows ????. ideas? how resolve... when had similar issue firstly displayed encoding of text in php using echo mb_detect_encoding ( $text ); it shows encoding of text coming query. showed me getting ascii mysql_query when chinese or russian characters in database. the change made following addition after mysql_connect mysql_set_charset('utf8'); my database utf8_unicode_ci collation , can see chinese characters. so, if m

ssh - "nodename nor servname provided" when trying to start a mesos-slave -

i following simple guide on installing mesos locally https://mesosphere.com/2014/07/07/installing-mesos-on-your-mac-with-homebrew/ i able start mesos master , able see master's console fine @ localhost:5050. when tried start new slave using sudo /usr/local/sbin/mesos-slave --master=127.0.0.1:5050 , gave me warning: logging before initgooglelogging() written stderr f0328 16:14:45.329051 2041414416 process.cpp:889] nodename nor servname provided, or not known * check failure stack trace: * any appreciated, thanks this can happen if working on framework , attempting connect mesos master. mesos attempting resolve computer's name via dns , isn't finding entry. can happen if you've changed mac's hostname post setup ( did, , had same error ). to fix, run hostname -f , will give value of os/x thinks it's name is. ensure you've got 127.0.0.1 value_of_hostname_-f in /etc/hosts file.

How can I reach my subclass? C++ -

in following code can't reach subclass. have have subclass underneath superclass inherit it, superclass won't know point unless subclass defined before it. class particlesystem { particle *ptr_to_particles; void update() { // loop through number of particles // , call update method. ptr_to_particles[i].update(); } } class particle : public particlesystem //inherits particlesystem { void update(); } or if can offer suggestions how differently, welcome it. thanks. i think should reconsider design. particlesystem should have number of particle (e.g. std::vector<particle> ). doesn't seem correct particle be type of particlesystem . this class particle { public: void update(); }; class particlesystem { public: void update() { (auto particle : _particles) { particle->update(); } } private: std::vector<particle*> _particles; };

java - What is the space complexity of enumerating subsets? -

this based off other question had on space complexity. permutation space complexity this solution problem of enumerating(naming) sets. (tested it, works) public static void subsets(set<integer> s) { queue<integer> copytoprotectdata = new linkedlist<integer>(); for(int member: s) { copytoprotectdata.add(member); } generatesubsets(copytoprotectdata, new hashset<integer>()); } private static void generatesubsets(queue<integer> s, set<integer> hashset) { if(s.isempty()) { system.out.println(hashset); } else { int member = s.remove(); set<integer> copy = new hashset<integer>(); for(int i:hashset) { copy.add(i); } hashset.add(member); queue<integer> queuecopy = new linkedlist<integer>(); for(int i:s){ queuecopy.add(i); } generatesubsets(s, hashset); generatesubsets(queu

xcode - Refresh and set new item AVPlayer class -

i'm trying refresh nsview in video finishes playing. i'd after click button next or previous refresh view in video played. see new view overlapping old vindow. i've tried using removefromsuperview removes nsvindow. how solve this? my code: @interface appdelegate () { avplayer *player; } @property (weak) iboutlet nswindow *window; @end @implementation appdelegate @synthesize playerview; - (void)applicationdidfinishlaunching:(nsnotification *)anotification { nsurl *url = [[nsbundle mainbundle] urlforresource:@"pieniadz" withextension:@"3gp"]; player = [avplayer playerwithurl:url]; avplayerlayer *playerlayer = [avplayerlayer playerlayerwithplayer:player]; [self.playerview.layer addsublayer:playerlayer]; playerlayer.frame = self.playerview.layer.bounds; playerlayer.autoresizingmask = kcalayerwidthsizable | kcalayerheightsizable; player.actionatitemend = avplayeractionatitemendnone; // [player play];

ios - Autoshrink in UILabel only for width? -

i have ascii syntax diagrams must not have line breaks in middle. these don't have editable thought best way use uilabel auto shrink option. option shrinks text if content doesn't fit height of labels frame rectangle. i want shrink if content doesn't fit width. absolutely fine scroll vertically through text. what best way uilabel or other ui element? use uitextview 'editable' property set false.

java - Issues with String Array Concatenation -

i'm trying concatenate strings in array. want example ["a","b","c"] become "abc" . here's code: import java.util.scanner; import java.util.arraylist; public class laggaihop { private static scanner scanner = new scanner( system.in ); public static void main(string[] args) { system.out.print("ange antal ord: "); string input = scanner.nextline(); int antal = integer.parseint(input); string[] ordlista; ordlista = new string[antal]; for(int = 0; < antal; i++){ system.out.print("ange ord: "); string nyttelement = scanner.nextline(); ordlista[i] = nyttelement; } string resultat; for(int = 0; < antal; i++){ resultat = resultat+ordlista[i]; } } i following error: laggaihop.java:21: error: variable resultat might not have been initialized resultat = res

ruby - Installing Rails on Mac OS Yosemite v10.10.2 (FNG) -

i'm trying install rails onto mac , keep running issue. have no coding/programming experience , trying set can start learning. i have gone through on install rails.com , not sure do. your appreciated. make install failed, exit code 2 gem files remain installed in /users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 inspection. results logged /users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out follow steps below install ruby on rails on mac osx yosemite. if not work please post exact errors. further details installation have @ https://gorails.com/setup/osx/10.10-yosemite installing homebrew you might asked install xcode commandline tools - yes. ruby -e "$(curl -fssl https://raw.githubusercontent.com/homebrew/install/master/install)" installing ruby you can browse available versions using rbenv install --list installation using ho

angularjs - How can I handle angular-route with pure Node.js? -

i'm learning node.js without express.js (trying learn node.js itself). server side, got this: node.js // creating server var server = http.createserver(function(request, response) { var filepath = false; // send files each reqeust if(request.url == '/') { filepath = 'public/index.html'; } else { filepath = 'public' + request.url; } var abspath = './' + filepath; sendfile(response, cache, abspath); // send response here }); and client side, used angular route (not ui-route). angular.js: app.config(function($routeprovider, $locationprovider) { $routeprovider.when('/', { templateurl: '/partials/foo.html', controller: 'fooctrl' }); $routeprovider.when('/bar', { templateurl: '/partials/bar.html' }); $routeprovider.otherwise({redirectto: '/'}); $locationprovider.html5mode({ enabled: true,

html - unable to put table next to each other -

i have read through other posts seems using display:inline-block , float:left doesn't fix problem. here's have: .lefttable { display: inline-block; overflow: auto; border: solid 1px black; width: 20%; } .righttable { display: inline-block; overflow: auto; border: solid 1px black; width: 80%; } <table class="lefttable"> <tr> <td> <form action="testmartcontroller" method="post"> <input type="hidden" name="action" value="dairy"> <input type="image" src="<%=request.getcontextpath()%>/css/categories/dairy.jpg"> </form> </td> </tr> <tr> <td> <form action="testmartcontroller" method="post"> <input type="hidden" name="action" value="meat"> <input type=&

class - Scanner only works with one out of multiple classes Java -

i have program purpose of analyzing text file user selects via typing in full path of text file when prompted. i have managed scanner multiple classes not work each method simultaneously. example have class print amount of numbers in file , print number of words in file. first method run work, other display 0 of whatever class searching for(numbers, lines, words etc) if true value not 0. i'm stuck why happening, have attached main class 2 other classes show clear example: main class: package cw; import java.io.file; import java.io.filewriter; import java.io.printwriter; import java.util.scanner; import javax.swing.jfilechooser; import java.io.ioexception; public class textanalyser { public static scanner reader; public static void main(string[] args) throws ioexception { scanner in = new scanner(system.in); system.out.println("enter filename"); string filename = in.nextline(); file inputfile = new file (filename); r

combine jquery load with php and sql -

http://alexanderkap.esy.es/server%20side%20assesment/ hi trying load each category in example above using jquery load function. want achieve somehow tell category clicked in loaded document can execute correct query , display in space i found solution this. if add variables on end of loaded link despite not showing in url bar(because loaded document displays internally) can still process them filter querys. had add return false; click events avoid bubbling.

c++ - Using auto keyword to fill doubly-indexed vector -

trying better learn auto keyword. i'd allocate doubly-indexed vector using auto keyword, when print vector (which should 0 's), instead prints empty space, in correct "shape" of vector. mwe: #include <iostream> #include <vector> void displayvector(const std::vector<std::vector<double> >& vec) { std::cout << "vector: \n\n"; (auto : vec) { (auto j : i) { std::cout << j << " "; } std::cout << "\n"; } std::cout << "\n"; } int main() { std::vector<std::vector<double> > vec1, vec2; /* want work */ vec1.resize(5); (auto : vec1) { i.resize(3); } displayvector(vec1); /* "old" way of doing */ vec2.resize(5); (int = 0; < 5; ++i) { vec2[i].resize(3); } displayvector(vec2); } this results in vector: vector: 0 0 0 0 0 0 0 0 0 0 0 0

python - use a list outside my loop to concatenate a url string with some list values -

im getting 3 messages sqs queue: mapper.py, reducer.py , test.txt ...and im storing each message inside list. and want use content of each message in mapper, reducer , input variables(last 3 code lines). but outside while loop line have print "connecting emr" im not seeing how can use list of filenames purpose want. do see solution this? in print item inside loop shows first element of filenames_list. conn = sqsconnection() myqueue = conn.get_queue('myqueue') while myqueue.count() != 0: filenames_list = list() message = myqueue.read() myqueue.delete_message(message) filename = message.get_body() filenames_list.append(filename) item in files_list: print item print "connecting emr" conn = boto.emr.connect_to_region('us-east-1') print "creating streaming step" step = streamingstep(name='example1', # after myfolder/ want put here content of list relative test.txt mapper="s3n://myfolde

c++ - How to debug segmentation fault? -

it works when, in loop, set every element 0 or entry_count-1. works when set entry_count small, , write hand instead of loop (sorted_order[0] = 0; sorted_order[1] = 1; ... etc). please not tell me fix code. not using smart pointers or vectors specific reasons. instead focus on question: sort of conditions can cause segfault? thank you. ---- old ----- i trying debug code isn't working on unix machine. gist of code is: int *sorted_array = (int*)memory; // know block large enough // allocated malloc earlier (int = 0; < entry_count; ++i){ sorted_array[i] = i; } there appears segfault somewhere in loop. switching debug mode, unfortunately, makes segfault stop. using cout debugging found must in loop. next wanted know how far loop segfault happend added: std::cout << << '\n'; it showed entire range suppose looping on , there no segfault. with little more experimentation created string stream before loop , write empty string each iterati

php - How can I improve this login? -

i have code: if (strcmp($user->pass, crypt($password, $user->pass)) == 0) { echo 'good'; } else { echo 'kill'; } in php , know how can improved, since think terrible, right? thanks! if comparing hashed password, use hash_equals instead. if (hash_equals($hashed_password, crypt($user_input, $hashed_password))) { echo "password verified!"; } for reference: http://php.net/manual/en/function.crypt.php http://php.net/manual/en/function.hash-equals.php

Ajax POST returning an Bad Request 400 -

i have been trying few hours debug post ajax call server. i have 2 post methods: helloworld , helloyou. same code, difference helloyou takes string parameter: namespace webservice { [servicecontract(namespace = "")] [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class service { [operationcontract] [webinvoke(method = "post", bodystyle = webmessagebodystyle.wrappedrequest, responseformat = webmessageformat.json, requestformat = webmessageformat.json)] public string helloworld() { return "hello world"; } [operationcontract] [webinvoke(method = "post", bodystyle = webmessagebodystyle.wrappedrequest, responseformat = webmessageformat.json, requestformat = webmessageformat.json)] public string helloyou(string name)

Prolog Applying Constraints to Original List Items in Matrix -

i working on project involves matrix. stuck in attempt apply constraints specific elements in matrix. matrix , domain definitions of main class/predicate. so, first 3 predicates creating matrix , defining domains while last 2 predicates labels different variables in regards domain , prints out. test(solution, n) :- length(solution,8), maplist(length_(8), solution), %the variables maplist(define_domain, solution), %the domains constraint(solution), maplist(labeling([]), solution), %labeling variables maplist(print_row, solution). length_(length, list) :- length(list, length). define_domain(x):- x ins 0..9. ww(x):- write(x). print_row(row):- %nested maplist call works on each element in maplist(ww, row), nl. so, constraints predicate applies constraint on variables having problems. have facts need capture tried using findall loop through facts , use them determine elements inside list of matrix need apply constraints to. facts contains

itertools - How to flatten a list of lists of lists in python -

this question has answer here: flatten (an irregular) list of lists 36 answers i've seen couple answers on how flatten lists of form [1,[1,2],[3]] print list(itertools.chain(*[1,[1,2],[3]])) but how flatten lists this: [[1],[[1,2],[3]]] print list(itertools.chain(*[[1],[[1,2],[3]]])) [1, [1, 2], [3]] i use recipe : import collections def flatten(l): el in l: if isinstance(el, collections.iterable) , not isinstance(el, str): sub in flatten(el): yield sub else: yield el print(list(flatten([[1],[[1,2],[3]]]))) # [1, 1, 2, 3]

php - return 2 or more variables separately from looped $.post() -

i'm developing textarea whatever pasted after push of button, added database. setting aside database function aside. achieve is: return number of records posted return number of records not inserted telling duplicate jquery code $(function(){ $('#sw').click(function(){ if($("#txta").val().length>0) { var h=confirm("are sure?"); if(h==true) { var fld=$("#txta").val().split('\n'); $.each(fld, function(){ $.post('up.php', { 'ldta': this.split('\t') }, function(data) { $('#out').append(data); } ); }); alert('upload completed'); } else alert("cancelled"); } else { alert("textarea empty."); $('#out').html(''); } }); }); php $setsu = dbsetsuzoku();//connection string stored on separate file $ldta=$_post[&

http status code 404 - Why Google crawler finds several url that is not in my page? -

i have page contains many url in its. urls generate dynamically datebase. when used goggle webmaster tools check site, found 1 of url in database has syntax error , webmaster tools give me 404 (not found) error. result fixed error. after day, goggle still gives me same message (not found error). why happening , fix problem, do? thanks.

c# - Calling DLL from Python 3.4 -

i had dll written in c. c# application, wrote .cs wrapper worked in calling dll functions.. now have c# dll , need call functions using python 3.4 (loadlibrary). preferred route of doing this 1) convert c# dll code c , make new c-style dll (with exports). 2) create kind of wrapper in python allows see c# dll functions as-is? ( if possible) 3) both python .net , ironpython don't seem actively maintained anymore (the windows installer shows python 2.7). there better alternative? take @ question on stack overflow.it tells how use ctypes.it describes ctypes.windll command including required dll.you can set prototype , parameters desired function call using ctypes.winfunctype .

Split string and get each values using java -

i have string in following format duplicate application\your request has been rejected credit bureau server.\entered value lower minimum requirement apply income proof document. please try using other income support document.\validation error. policy criteria not met.\decisioning system unavailable @ moment\decision center error:\we regret not being able take application forward @ point. thank applying. now, i'm trying split string using delimiter "\". i'm trying fetch strings , compare string receive response split result each value. i'm not getting exact thing.. here code.. //note scbcc_new string have.. string[] scbccnewarray = scbcc_new.split("/"); for(string results : scbccnewarray) { log.info("value :"+results) } is right way? you need escape slash special character in java. string str = "duplicate application\\your request has been rejected credit bureau server.\\entere"; string[] scbccn

ios - Memory leak reported by instrument. Can't understand why -

instruments telling following method leaking memory when creating mutable string. can tell me why? using arc on ios 8 xcode 6.2. - (nsstring *)capitalizefirstletter { if (self.length == 0) { return self; } nsmutablestring * string = [nsmutablestring stringwithstring:self.lowercasestring]; [string replacecharactersinrange:nsmakerange(0, 1) withstring:[self substringtoindex:1].capitalizedstring]; return string; } i not sure caused leak, if want avoid can change method to: - (nsstring *)capitalizefirstletter { if (self.length == 0) { return self; } return [nsstring stringwithformat:@"%@%@", [self substringtoindex:1].capitalizedstring, [self substringfromindex:1]]; } also review answeres here need fixing memory leak - nsmutablestring

drupal 7 - Drupal7 multiple file upload or choose from existing files -

Image
i new drupal , know have been asked cant solution problem. creating image gallery in drupal 7.i have image field want able upload multiple images @ once , or select multiple existing images. have used multifile upload, can't reuse existing images. used media , can select multiple existing files can upload single image @ once. there way can achieve want in drupal 7 ? to able upload multi images (files), download , enable multiupload filefield widget , multiupload imagefield widget modules. go content type manage fields page, , choose multiupload widget image field. and selecting existing images, use filefield sources . content type manage fields page, click on edit next file field , check on file sources fieldset.

YII PHP nested foreach error -

i have error here want combine data 2 query using nested foreach , save data in array called result there error trying property of non-object in these part of code : 'id_product'=>$detail_result->id , can me? i'm still new using yii framework php here code $result = array(); $criteria = new cdbcriteria; $criteria->condition = 'date_time >= :start , date_time <= :end'; $criteria->order = 'date_time'; $criteria->params = array(':start' => $_post['tanggal']['start'] ,':end' => $_post['tanggal']['end']); $checkin = checkin::model()->findall($criteria); foreach($checkin $entry) { $sql = "select * check_in_detail id_check_in = $entry->id"; $detail_results = yii::app()->db->createcommand($sql)->queryall(); foreach($detail_results $detail_result) {

html - Is it possible for the container to occupy 100% screen height for any desktop screen size? -

i trying make container occupy complete height of desktop screen. i can set height of divs pixels , occupy reasonable height. but if viewed on large screens, bottom of container visible, empty space. can make container occupy complete height screens? what need sticky footer. html { position: relative; min-height: 100%; } body { margin: 0 0 100px; /* bottom = footer height */ } footer { position: absolute; left: 0; bottom: 0; height: 100px; width: 100%; } read here . here's demo .

attributes - Typescript idioms around adding properties to methods inline with the method definition -

are there idioms in typescript define properties methods in class inline method definition? i'm looking similar .net attributes. here's example of i've got far class foocontroller { foo(req: express.request, res: express.response) { res.send(json.stringify({ loc: 'foocontroller::foo 2 here '+req.params.fooid })); } bar(req: express.request, res: express.response) { res.send(json.stringify({ loc: 'foocontroller::bar here' })); } } foocontroller.prototype.foo['route'] = '/foo/:fooid'; foocontroller.prototype.foo['verb'] = 'get'; foocontroller.prototype.bar['route'] = '/bar'; foocontroller.prototype.bar['verb'] = 'post'; where different function consume foocontroller , interrogate method attributes set routing table before of foocontroller methods invoked. i don't distance between method definitions , property definitions, methods larger , supportin

Finding even numbers by using pointers in c++ -

i doing assignment pointers. in 1 of question, asks me find numbers in array , print of them. have use signature given assignment , can not use use & operator or [] notation in function. signature: void print_evens(int *nums,int length) ; i know have use, if(i%2==0) cout << << endl; to find numbers don't know how pointers. how can pass array main function print_evens since there no parameters array? thank help. how can pass array main function print_evens since there no parameters array? you can never pass array function, regardless of signature. arrays decay pointers first element in such situation. in case, need dereference pointer value @ current location. for (int = 0; < length; ++i) { int current = *(nums + i); if ((current % 2) == 0) cout << current << endl; } and can pass in array (which decays pointer of course) #define len 10 int main(void) { int arr[len]; /* initialize elem

c# - Connect to SQL Server 2005 from a windows mobile -

i new site, hope won't laugh @ problem. i have new type of project me build, need write app motorola symbol mc9090 barcode scanner running windows mobile 6. need connect app sql server 2005 database. can connect ado connection 1 below? port open. use windows classic emulator debugging crashes @ myconn.open() . thank answers. sqlconnection myconn = new sqlconnection(@" data source=***.***.0.***,1443;initial catalog=test_database;user id=****ica;password=********;"); try { myconn.open(); sqlcommand comm = new sqlcommand("select * test_table id = 1", myconn); sqldatareader reader = comm.executereader(); while (reader.read()) { messagebox.show(reader[0].tostring() + "\t" + reader[1].tostring()); } } catch(exception ex) { messagebox.show(ex.message); } { myconn.close(); } the problem in case virtual pc, emulator had problems connecting internet.