Posts

Showing posts from September, 2014

ruby - manipulating array: adding number of occurrences to the duplicate elements -

(you welcome change title more appropriate one!) i got ruby/erb question. have file: ec2-23-22-59-32, mongoc, i-b8b44, instnum=1, running ec2-54-27-11-46, mongod, i-43f9f, instnum=2, running ec2-78-62-192-20, mongod, i-02fa4, instnum=3, running ec2-24-47-51-23, mongos, i-546c4, instnum=4, running ec2-72-95-64-22, mongos, i-5d634, instnum=5, running ec2-27-22-219-75, mongoc, i-02fa6, instnum=6, running and can process file create array this: irb(main):007:0> open(infile).each { |ln| puts ln.split(',').map(&:strip)[0..1] } ec2-23-22-59-32 mongoc ec2-54-27-11-46 mongod .... .... but want occurrence number concatenated "mongo-type" becomes: ec2-23-22-59-32 mongoc1 ec2-54-27-11-46 mongod1 ec2-78-62-192-20 mongod2 ec2-24-47-51-23 mongos1 ec2-72-95-64-22 mongos2 ec2-27-22-219-75 mongoc2 the number of each mongo-type not fixed , changes on time. how can that? in advance. cheers!! quick answer (maybe optimized): data = 'ec2-23-22-59-32...

HTML5 Audio API stop a sound triggered with noteGrainOn -

is there way stop (or forever pause) sound played .. audiosource.notegrainon(when, starthere, duration_sound); ..before "duration_sound" variable stops it? via noteoff, how used? yes. (note should use .start() - noteon() , notegrainon() deprecated.) just call audiosource.stop( 0 ); to stop immediately, or can schedule stop before sound finished playing calling audiosource.stop( whentostop );

process - How to double click or single click the BAT file using Java or java script which is available in the specified path -

scenario created bat file , stored in c drive. need write code double click or single click using java. this tried in java did not work: try { string path = "cmd /c start c:\\keymanager_stop.bat"; runtime rn = runtime.getruntime(); process pr = rn.exec(path); } catch (exception e) { e.printstacktrace(); } the batch file contains: cd c:\test\test.cmd stop

JavaScript variable split into groups -

this question has answer here: javascript elegant way split string segments n characters long 8 answers have var id = "123456789"; how split in groups after each 3 digits?? result must this: var no1 = 123; var no2 = 456; var no3 = 789; if id longer 12, 15 or more digits, should work same! this can answer, use function per need, output array contains result function parsedigits() { var number = 123456789, output = [], snumber = number.tostring(); (var = 0, len = snumber.length; < len; += 3) { output.push(+snumber.charat(i)+snumber.charat(i+1)+snumber.charat(i+2)); } alert(output); }

Extract attributes and certain tag values from xml using python script -

i want parse xml content , return dictionary contains name attribute , values dictionary. example: <ecmaarray> <number name="xyz1">123.456</number> <ecmaarray name="xyz2"> <string name="str1">aaa</string> <number name="num1">55</number> </ecmaarray> <strictarray name="xyz3"> <string>aaa</string> <number>55</number> </strictarray> </ecmaarray> the output has in dictionary this.. dict:{ 'xyz1': 123.456, 'xyz2': {'str1':'aaa', 'num1': '55'}, 'xyz3': ['aaa','55'] } can 1 suggest recursive solution ? assuming situation this: <strictarray name="xyz4"> <string>aaa</string> <number name="num1">55</number> </strict...

sql - Rows multiplication needed -

problem description: warehouse... received 10 pc of 1 product , 3 pc of same product 1 container. have different user_def_note_2 values. table inventory: sku_id;qty_on_hand;container_id;user_def_note_2 sku1;10;k001;ot 15/2013 sku1;3;k001;wi 14/2011 i need print 10 x label first user_def_note_2 value , 3 second. raporting software input 1 row = 1 label how "multiple rows" in case? i did standard join on rownum, , works fine 1 row case. (i mean know how multiple single row*quantity - dont know how multiply 1*qty1 +2*qty2). problem i'm using rownum...and rownum global. any ideas? select t.* inventory t join (select level n dual connect level <= (select max(qty_on_hand) inventory)) on n <= t.qty_on_hand

MySQL: Column automaticly current time of insert -

i creating new table, , each row have column equal time row inserted table. there way in create table statement or have in insert statement? this should work: create table table1 ( timestampcolumn timestamp default current_timestamp on update current_timestamp );

Access VBA OpenForm Grouping and Sorting -

i have form used data entry. have go through , add data these records. there way pull form groups records field "a" , sorts field "b"? order forms a1-1, a1-2, etc, making adding data easier. right using docmd.openform display records values in fields. need modify bit? thanks help! [edit] i load form on button click have private sub btndataentry_click() docmd.openform "data sheet", acnormal, , , acformedit, , openargs:="mapnumber" end sub then suggested private sub form_load() if not isnull(me.openargs) main.orderby = me.openargs main.orderbyon = true end if end sub this not working me. if possible group map numbers , have item numbers ascending. there 10 entries map number 1 , item numbers 1-10. openform doesn't include option specify sort order. use openargs option pass in sort information, apply during form load. private sub form_load() if not isnull(me.openargs) ...

asp.net mvc - How to return to calling page, but with a slight difference, in MVC3? -

i need call mvc3 page(p2) , return calling page(p1). slight twist p2 needs call itself, referrer can end being p2. so: p1 - (p2 -> p2 -> p2) ->p1 so question how p1's referrer url , keep , use later go p1, regardless of number of time p2 calls itself. i did try , populate viewbag.referrer: <a href="@viewbag.referrer">back</a> using following controller code, trying set on original call. viewbag.referrer seemed pick p2 referrer url, though in debug mode not resetting viewbag.referrer due isoriginalcall=0. weird. if storing pointer , not value. public viewresult index(int id = 0, int isoriginalcall = 0) { if (isoriginalcall =1) { if (request.urlreferrer != null) { viewbag.referrer = request.urlreferrer.localpath; } } viewbag.sliid = id == 0 ? 4 : id; return view(db.stdsection.where(r=>r.inwizard).orderby(r=>r.name).tolist()); } thoug...

Color or Highlight a data point in graph in winforms in visual studio using c# or cli/c++ -

i drawing graph in winform picking data database. works fine. need if data value greater max value point in graph gets highlited or colored red. how can that? please help. string^ constring = l"datasource=localhost;port=3306;username=root;password=root;"; mysqlconnection^ condatabase = gcnew mysqlconnection(constring); mysqlcommand^ cmddatabase = gcnew mysqlcommand("select * `data`.`test`;",condatabase); mysqldatareader^ myreader; try{ condatabase->open(); myreader = cmddatabase->executereader(); // messagebox::show("data inserted"); while(myreader->read()){ string^ v_datetime; string^ v_temp; v_datetime = myreader->getstring("datetime"); v_pressure = myreader->getint32(...

sublimetext2 - No autocomplete popup in JSP files for snippets -

Image
i made bunch of snippets want use when i'm editing .jsp files in sublime text 2. when edit jsp file (syntax: jsp) autocomplete function doens't work. when change syntax "java" autocomplete works. plan b: work jsp syntax when hit 'c: tab'. there no autocomplete while typing java syntax. i tried changing , removing scope changing tabtrigger core-, not using ":", giving every snippet trigger, giving every snippet same trigger (so plan b works) placing snippet files in \packages\user\ , \packages\user\jsp\ folder snippet example: <snippet> <content><![cdata[ <c:foreach items="\$\{${1}\}" var="${2}" varstatus="${3}" begin="\$\{${4}\}" end="\$\{${5}\}"> ${6} </c:foreach> ]]></content> <!-- optional: set tabtrigger define how trigger snippet --> <tabtrigger>c:</tabtrigger> <!-- optional: set scope limit snippet trigger --> <sc...

Zend 2.2 trouble for HTTP Authentication -

i try make http authentication 1 of module using zend framework 2.2, code inspired official documentation, in there : $request=$this->getrequest(); $response=$this->getresponse(); assert($request instanceof zend\http\request); assert($response instanceof zend\http\response); the problem assertion goes false, seems $request , $response come class, script's not working. how request , response zend\http\request|response in controller ? many thanks. if want set http auth entire module, here's (at least how did it) : in module.php : public function onbootstrap(mvcevent $e){ $sharedevents=$e->getapplication()->geteventmanager()->getsharedmanager(); $sharedevents->attach(__namespace__,mvcevent::event_dispatch, array($this, 'authhttp')); } public function authhttp(mvcevent $e){ $servicemanager = $e->getapplication()->getservicemanager(); $request=$e->getrequest(); ...

c++ - How to make that a float use comma and not point? -

i want make operator<< use local setings or if not @ least manualy able change use of "." decimal separator ",". way of making stream (iostream, fstream, etc) , not create string , print it. is possible? you can imbue numpunct facet onto stream. believe should work you: template <typename t> struct comma_separator : std::numpunct<t> { typename std::numpunct<t>::char_type do_decimal_point() const { return ','; } }; template <typename t> std::basic_ostream<t>& comma_sep(std::basic_ostream<t>& os) { os.imbue(std::locale(std::locale(""), new comma_separator<t>)); return os; } int main() { std::cout << comma_sep << 3.14; // 3,14 } here demo. a shorter solution, uses european locale: std::cout.imbue( std::locale( std::cout.getloc(), new std::numpunct_byname<char>("de_de.utf8"))); but depends on local...

efficient storing of matlab shape functions -

i'm trying find efficient possible way store , call matlab shape-functions. have interval x=linspace(0,20) , position-vector count = 10; i=1:count pos(i)=rand()*length(x); end and now, want put on every position pos(j) shape functions gauss-kernels compact support or hat-functions or similar (it should possible change prototype function easily). support of function controlled so-called smoothing length h . constructed function in .m-file (e.g. cubic spline) function y = w_shape(x,pos,h) l=length(x); y=zeros(1,l); if (h>0) i=1:l if (-h <= x(i)-pos && x(i)-pos < -h/2) y(i) = (x(i)-pos+h)^2; elseif (-h/2 <= x(i)-pos && x(i)-pos <= h/2) y(i) = -(x(i)-pos)^2 + h^2/2; elseif (h/2 < x(i)-pos && x(i)-pos <=h) y(i) = (x(i)-pos-h)^2; end end else error('h must positive') end and construct functions on interval x like w = zeros(count,length...

png - How to draw daytime vs nightime in a gnuplot generated graph? -

i'm looking way draw horizontal line (or "shadow") following graphic in gnuplot show day vs night: http://cucatrap.us.to/dia.png the script generate image is: set autoscale set title "campo magnetico terrestre - intensidad - ultimas 24hs" set title font "freesans, 11" set timefmt '%y-%m-%d %h:%m:%s' set xdata time set xtics font "freesans, 9" set ytics font "freesans, 9" set xlabel font "freesans, 9" set ylabel font "freesans, 9" set key font "freesans,9" set key left center set xlabel "fecha/hora" set ylabel "campo (mg)" set terminal png enhanced size 1200,600 set output "dia.png" set grid y set grid x set datafile separator '|' plot "< sqlite3 /data/magneto/magneto.db 'select * v_dia'" using 1:2 title 'x' lines, \ "< sqlite3 /data/magneto/magneto.db 'select * v_dia'" using 1:3 title 'y' ...

android - Find app on computer and send to phone via phone number -

i had app accepted app store , submitted google play. have seen find app while using desktop , can enter phone number , app download link sent phone (e.g. http://www.groupon.com/mobile ). wondering how create similar application. any appreciated. you need implement twilio on website. provide api can use send text messages. looks though pricing starts @ around 1 cent per message. provide libraries in variety of languages started.

c++ - Access violation reading location 0x00000006 -

i have following code finds strings contain no alphabets. cases mynumber123 shall not recognized , numberfinder() should return false , case 123 shall recognized , numberfinder() shall return true begin index of number. the constructor: caddressparser::caddressparser(string filename) //constructor { m_filename=filename; int length=getlength(m_filename.c_str()); m_text =filereader(m_filename.c_str()); m_length=length; } which initializes string m_text contains contents of text file somewhere along implementation come across following code: for (i;i<m_length;i++) { bool uppercasebeforenofound=false; if(this->numberfinder (i).second) { //do calculations. } } the numberfinder function implemented follows: pair <int,bool> caddressparser::numberfinder(int counter) { bool nofound=isdigit(m_text[counter]); //number found? -> true if(nofound) { int end=housenodigits(counter); i...

grails - URLRewriteFilter in Development Environment? -

i using urlrewritefilter forward requests domain "www" version seo. have basic rule: <rule> <name>domain name check</name> <condition name="host" operator="notequal">www.mydomain.com</condition> <from>/.*</from> <to type="permanent-redirect">http://www.mydomain.com</to> </rule> this works great production, when running in development mode changes domain well, localhost:8080/mysite www.mydomain.com . how can fix development mode? using grails , tomcat, bundled in .war gets deployed server. thanks! can try adding in buildconfig.groovy exclude dependency? (provided have not added jar in lib ) grails.project.dependency.resolution = { inherits("global") { if (environment.current != environment.production) excludes "urlrewritefilter" } } if not work in opinion safest bet fork/clone plugin (which uses latest version of ...

ios5 - Character limit for fields on Pass in Apple Passbook -

i'm designing passes using passkit4j. apple passes crop out excessive characters in field value. example if give 25 chars, , if limit 20 last 5 chars gets cropped out. i looked around apple passbook documentation , passkit documentation detail no luck. tried myself in passkit.com website , identified char limit 20 primary fields. but nice if documentation around convention/constraint of field length fields in pass. and there workaround this? reducing font size if characters big? unfortunately there no workaround this. sizing , truncation of fields controlled proprietary algorithms in passbook app. rendering see on passkit.com our best attempt @ reverse engineering these algorithms. actual number of characters 1 field can contain varies pass type pass type, , affected content of adjacent fields. our service allows allow our users visualise pass on device, although never 100% accurate should test on device. the problem truncation becomes more acute when deali...

ruby on rails 3 - Carrierwave: set image path and skip the upload -

i set images without uploading. (they exist, or task saves them...) if try (in rails console): user = user.last user.picture = '/some/picture.jpg' user.save user.picture # nil the way set remote_picture_url, , delete upload (which stupid) is there method in carrierwave lets modify filename ? class user < activerecord::base attr_accessible :picture # don't want write database, want able check attr_writer :skip # set default value def skip @skip ||= false end mount_uploader :image, pictureuploader # make sure skip callback comes after mount_uploader skip_callback :save, :before, :store_picture!, if: :skip_saving? # other callbacks might triggered depending on usecase #skip_callback :save, :before, :write_picture_identifier, id: :skip_saving? def skip_saving? skip end end class pictureuploader < carrierwave::uploader::base # implement filename= def set_filename(name) @filename = name end end assuming...

javascript - pass array in the "data" tag at server side - bootstrap ajax call -

i not able figure out if can send array in data tag: client js code looks : $.ajax({ url: '/mobiledoc/jsp/aco/beneficiary/ptmmview.jsp', data: { "action":"savepatientrecords", "ptid":strptid, "patientval":patientval, "qid":qid, "qtype":qtype "array" : ?? }, datatype: 'text', type: 'post', success: function (responsemsg) { // gets response message server loadmilestonedata(); alert(responsemsg); yes can. first use method instead of type post. this... method: 'post' jquery should serialise data you. $.ajax({ url: '/mobiledoc/jsp/aco/beneficiary/ptmmview.jsp', data: { "action": "savepatientrecords", "ptid": st...

How to use SAS Macro call in a %let -

i want use macro in %let call, below macro code , how want invoke it. please me achieve it. %macro xscan(string, delimiter, word_number); %let len1=%length(&string); /*computing length of string*/ %let len=%eval(&len1+1); %let sub=%scan(&string,&word_number,"&delimiter"); /*fetch string specified word_number*/ %if &word_number ge 0 %then %do; %let pos=%index(&string,&sub); /* locate position while reading left right*/ %end; %if &word_number lt 0 %then %do; data _null_; pos=find("&string","&sub",-&len); /* locate position while reading right left*/ call symput("pos",pos); run; %end; %let strg=%substr(&string,&pos); /* extract substring*/ %put string &strg; %mend; %let sub_str = %xscan(a bb ccc dddd bb eeeee, %str( ), -2); %put value of sub_str = &sub_str; desired implementation: data work.in_data; length in_string $50; in_string = “a bb ccc dddd bb eeeee”; output...

javascript - jQuery .click() doesn't trigger function in IE -

i have html form runs javascript function before submitting. html of form tag is: <form onsubmit="return sub();" method="post" action="useclick.php"> the html of submit button is: <input type="submit" value="submit" id="submit"/> that works fine, want user able press enter anywhere , submit form i've got bit of code: $(document).keypress(function(e) { if(e.which == 13) { $(this).blur(); $('#submit').focus().click(); } }); this want in browser except ie. in ie, click submit button, , send off form doesn't run sub() function first. it's same in ie 8 , 10, versions have access @ moment. for completeness, sub() function looks like: function sub(){ document.getelementsbyname('coords')[0].value = json.stringify(coordsarray); return true; } i'm new javascript , new jquery useful. have tried: $(document).keypress(function(e) { ...

gravity forms plugin - How to hide custom field text if field left blank -

i have site form created gravity forms. visitor fills out form , populates custom post type. fields user completes custom fields have created plugin "advanced custom fields". the form has series of questions user fills out, leave blank, not required. this code used output: i need figure out how hide text 'birthday' if birthday field left blank. you should able this: <?php if( get_field( "birthday" ) ) { the_field( "birthday" ); } ?> source: http://www.advancedcustomfields.com/resources/functions/the_field/

php - How to find if $row contains certain characters -

having bit of coding issue, how can check see if value of $row['value'] contains characters, in case, if 'rename_file' contains filename has '128' in it. have doesn't seem echo when is. $row = mysql_fetch_assoc($result); { while ($row = mysql_fetch_assoc($result)) { echo $row['c_id'] . " " . $row['source_file'] . " " . $row['rename_file'] ." " . $row['p_id']; if ($row['rename_file'] = '%128%') { echo "<p> 128"; } else echo "<br>"; } } many thanks. cp use preg_match() : if(preg_match('/128/',$row['rename_file'])){ echo "<p> 128"; } else { echo "<br>"; } or strpos() : if(strpos($row['rename_file'], '128') !== false){ echo "<p> 128"; } else { echo "<br>"; }

php - Color overlay on white PNG image with transparency -

i have following image: http://i.stack.imgur.com/mm8cy.png what create "color overlay" effect in photoshop. need sort of code allow me change each white pixels values specified in rgb numbers ranging 0-255. have heard imagemagick class, not find anywhere, , have no idea how class. i'm trying imagefilter , doesn't work white images. here current code: <?php $match = array(); if (isset($_get['c']) && preg_match('/^#?(?:[a-fa-f0-9]{2}){3}$/',$_get['c'],$match)){ $match = str_split($match[0],2); foreach ($match $k=>$m){ $match[$k] = intval($match[$k],16); } $img = imagecreatefrompng('splat.png'); $background = imagecolorallocate($img, 0, 0, 0); imagecolortransparent($img, $background); imagealphablending($img, false); imagesavealpha($img, true); //transformation code imagefilter($img, img_filter_colorize, $match[0], $match[1], $match[2]); header('content-type: image/png...

c# - how to check if a column exist in a datatable -

i have datable generated content of csv file. use other information map column of csv (now in datatable) information user required fill. in best world mapping alway possible. not reality... before try map datatable column value need check if column exist. if don't check have argumentexception. of course can check code : try { //try map here. } catch (argumentexception) { } but have 3 columns map , or might existing/missing is there way check if column exist in datatable? you can use operator contains , private void containcolumn(string columnname, datatable table) { datacolumncollection columns = table.columns; if (columns.contains(columnname)) { .... } } msdn - datacolumncollection.contains()

insert - MongoDB insertion based on reading -

in data, need if combination of attributes exist in database yet. if update it, if not insert new doc. know easy in relational database if set combination of attributes primary key, don't find same thing in mongo. set combination index, query database find if count zero, decide update or insert. growth of data size (currently 2mill docs), query ate memory faster inserting without query. have idea?

c# - display enum inside radio buttons, winforms -

i have enum datatype public enum userchoices { basic = 0, lite = 1, standard = 2 }; how can use enum property inside winforms radio button choices? use below code name , values in array. string[] names = enum.getnames(typeof(myenum)); myenum[] values = (myenum[])enum.getvalues(typeof(myenum)); now for( int = 0; < names.length; i++ ) { //add item radio button list //names[i] going text //values[i] going value } queries welcomed!

python - Importing Modules vs. Executing Scripts for Global Variables -

is bad practice execute script execfile(xx.py) , rather import xx module? reason i'm interested, executing file puts functions directly __main__ , , globals available without needing explicitly pass them. but, i'm not sure if creates trouble... thanks! yes, it's bad practice, reason ends in __main__ . if have 2 modules have variable same name, 1 overwrite other.

osx - "mate sample.js" command not working from Mac terminal -

i tried creating new js file mac terminal (i.e., mate sample.js) got below error: -bash: mate: command not found i'm not sure how create new file directly terminal. can me out? you trying create , open file textmate. work, have meet 2 conditions: having textmate installed having textmate's command-line tool ( mate ) installed (in tm 2.0, can preferences > terminal tab)

python - Setting up numeric boundaries? -

i'm having trouble setting simple boundary. i've set minimum , maximum boundary using code here. def min3(n,m,o): if (n<m<o or n<o<m): return(m) elif (o<m<n or o<n<m): return(o) def max3(n,m,o): if (n>m>o or n>o>m): return(n) elif (m>n>o or m>o>n): return(m) elif (o>m>n or o>n>m): return(o) this code not print values onto terminal, if use: def min3(n,m,o): if (n<m<o or n<o<m): return("the minimum value is",n) then values returned printed in terminal "the minimum value n", seems i'm moving along nicely program. but, when enter boundary code, is: def boundaries(a,x,b): if (x < a): return false elif(x >=a , x<= b): return true then run program usual, python3 complains saying "unorderable types: int() < tuple()" and can't figure out how either...

php - Div auto-increment page for gallery -

i want create script auto-increment div number every time reach limit 16 pics. "next" - "prev" controls. example: if have 16 pics in database, these remain in page n.1, if i've 20 pics: 16 pics in page n.1 , 4 pics in page n.2 ...etc the number of page depends number of pics in database sql. javascript or php? thank's! what looking called pagination. https://phpacademy.org/course/pagination

mysql - Trouble with loading a csv from a migration script in rails -

when trying load csv migration script using this: activerecord::base.connection.execute( "load data local infile 'my_data.csv' table my_table fields terminated ',' lines terminated '\n' (column1, column2) i get: mysql2::error: used command not allowed mysql version: load data local infile.... i have added appropriate settings my.cnf: [mysqld] local-infile=1 [mysql] local-infile=1 if run "load data local infile" command mysql client (e.g., mysql -uname -p) works great. reason in migration script (from rails) fails "not allowed mysql version". i had problem when using activerecord-fast-import (which based on same type of import query), , found out that, security reasons , both server , client need have enabled. the setting on ( my.cnf ) indeed needed server. enable on client, add database.yml : local_infile: true

javascript - Making a HTML_PARSER to work in widget DataTable -

so i'm trying parse html table yui 3 datatable widget, modifiyng widget html_parser object. html <div id="table"> <table> <thead> <tr> <th>tipo</th> <th>codigo</th> <th>descripcion</th> <th>impuesto para la venta</th> <th>precio</th> <th>precio con iva</th> <th>cantidad</th> </tr> </thead> <tbody> <tr> <td>producto</td> <td>1</td> <td>7</td> <td>12</td> <td>7.00</td> <td></td> <td>7</td> </tr> </tbody> </table> </div> javascript y.datatable.html_parser = { columns:function(srcnode) { var cols = []; srcnode.all("th").each(function(th){ var col = { // sets column "key" contents of th spaces remo...

asp.net - difference between Page_Init vs OnInit -

i had interview week ago , 1 of questions difference between oninit, page_init , prerender. 1 preferable? page_init event handler page.init event, typically see if add handler within class itself. oninit method raises init event. the 2 can seen being equivalent if used within subclass , there difference: init exposed other types, oninit method protected , responsible raising event, if override oninit , fail call base.oninit init event won't fired. here's how looks like: public class page { public event eventhandler init; public event eventhandler load; protected virtual void oninit(object sender, eventargs e) { if( this.init != null ) this.init(sender, e); } protected virtual void onload(object sender, eventargs e) { if( this.load != null ) this.load(sender, e); } public void executepagelifecylce() { this.oninit(); // houskeeping here this.onload(); // further housekeepin...

objective c - iOS Low Memory Warning in MapKit/SDWebImage -

Image
i've become frustrated enough beg insights mob. have application using mapkit, on tap shows thumbnail, , on tap of thumbnail shows photo gallery of images. images using sdwebimage. i've looked @ allocation tables , see map alone using ton of memory. peaks @ around 60mbs, kind of crazy. when open gallery drops around 40/35mbs. can @ 1 gallery find, open second gallery , start scrolling crashes, though memory use around 35mbs. my first attempts @ combating purge webimage cache on didreceivememwarning, second remove map , annotations. app using arc. here question... how can fix this? stop memory crash. help? crash report free pages: 1188 active pages: 6757 inactive pages: 4192 throttled pages: 89007 purgeable pages: 0 wired pages: 26699 largest process: dbconnect processes name <uuid> rpages recent_max [reason] (state) accountsd <e6ceba0e6e053a3ea02d0a916903cff8> ...

ios - Run code in the background -

this question has answer here: loading images background thread using blocks 3 answers i'm trying download image website , save uiimage if user has low connection can take forever... how can download in background user can keep using app in meantime? here code: theicon.image = [[uiimage alloc] initwithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:@"http://mywebsite.com/icon.png"]]]; use gcd. dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0), ^{ // background code dispatch_async(dispatch_get_main_queue(), ^{ // handling on main thread when done! }); });

linux - pam_cracklib not seeing old password -

i have enabled linux pam (version 1.1.4) , cracklib (version 2.8.22) , things working fine. password complexity specified via pam configuration file being adhered (upper/lower case, digits, etc) 'difok' not being adhered to. no matter set option to, pam_cracklib let password through (provided meets other complexity requirements i've specified). long story short had modify linux pam cracklib add debug , found out pam_cracklib fails able retrieve old password. thinks string null naturally there nothing compare new password to. yet when user changes own password, correctly authenticating current (what become old) password pam_unix correctly seeing old password. time gets down pam_cracklib line of pam configuration password appears have been wiped out somehow. i'm pulling hair out trying figure out how/where/why happening. here relevant password lines in pam configuration file: password requisite pam_cracklib.so debug reject_username\ minlen...

apache camel - Set property on body using bean() -

i'm trying set property called "articleid" on exchange's body , thought explicit way use bean() . however, can't work. when have following in route: .bean(body(article.class), "setarticleid(${header.articleid})") i error message: caused by: org.apache.camel.component.bean.methodnotfoundexception: method name: setarticleid(${header.articleid}) not found on bean: bodyas[com.example.model.article] of type: org.apache.camel.builder.valuebuilder my solution has been use processor() , few lines of code in order set articleid property header value, me seems overkill. i've been complaining on camel-users there isn't way this. here how tackle it: .setheader("dummy").ognl("request.body.articleid = request.headers.articleid") which requires adding camel-ognl dependency. update actually, there language endpoint can without setheader, have transform=false or else replaces body result: .to("languag...

Ignore the items in the ignore list by name in python -

i ignore items in ignore_list name in python. example consider fruit_list = ["apple", "mango", "strawberry", "cherry", "peach","peach pie"] allergy_list = ["cherry", "peach"] good_list = [f f in fruit_list if (f.lower() not in allergy_list)] print good_list i good_list ignore "peach pie" because peach in allergy list , peach pie contains peach :-p how about: fruits = ["apple", "mango", "strawberry", "cherry", "peach","peach pie"] allergies = ["cherry", "peach"] okay = [fruit fruit in fruits if not any(allergy in fruit.split() allergy in allergies)] # ['apple', 'mango', 'strawberry']

jquery - Trying to hide/show divs on radio button clicks -

i'm trying hide , show different divs depending on radio button people click on. jquery loading fine, i've tried putting alert on page load. very similar code, selector methods etc have worked on page in same directory same includes on same server the input box code is: <label class="radio"><input type="radio" name="input_sandwich_choice" value="panini">panini</label> <label class="radio"><input type="radio" name="input_sandwich_choice" value="sandwich">sandwich</label> <label class="radio"><input type="radio" name="input_sandwich_choice" value="baguette">baguette</label> the divs are: <div id="div_bread_options" class="collapse span3"> <!--2.2--> <h4>which bread like?</h4> <l...

c - segmentation fault (core dumped) in simple assignment -

i'm using c , wrote code on freebsd system. ///// defines ///// #define cpucores 2 #define threadamount cpucores - 1 #define nullptr null ///// typedefs ///// typedef enum bool_e { e_false = 0, e_true = 1 }bool_t; typedef struct newclient_s { int sdnewclient; struct sockaddr sdinclientip; socklen_t sdlenipsize; }newclient_t; typedef struct clientthreadarg_s { int iinternid; newclient_t sincommingclient; bool_t bhaskillsig; bool_t bisshutdown; }clientthreadarg_t; //------------------------------------ imagin main clientthreadarg_t *splistofarguments; size_t sizeindexi; splistofarguments = (clientthreadarg_t *) malloc (threadamount * sizeof (clientthreadarg_t)); (sizeindexi = 0; sizeindexi < threadamount; sizeindexi++) { splistofarguments[sizeindexi].bhaskillsig = e_true;//heres error.... } this code snippet figured out responsible error, don't understand why. tried al...

data structures - Why in-order traversal of a threaded tree is O(N)? -

i can't seem figure out how in-order traversal of threaded binary tree o(n).. because have descend links find the leftmost child , go thread when want add parent traversal path. not o(n^2)? thanks! the traversal of tree (threaded or not) o(n) because visiting node, starting parent, o(1). visitation of node consists of 3 fixed operations: descending node parent, visitation proper (spending time @ node), , returning parent. o(1 * n) o(n). the ultimate way @ tree graph, , traversal crosses each edge in graph twice. , number of edges proportional number of nodes since there no cycles or redundant edges (each node can reached 1 unique path). tree n nodes has n-1 edges: each node has edge leading parent node, except root node of tree. at times appears if visiting node requires more 1 descent. instance, after visiting rightmost node in subtree, have pop numerous levels before can march right next subtree. did not descend way down visit that node. each one-level desc...

c - OpenSSL and Network namespace - Closed -

i developing application using openssl library. new openssl library. application working correctly until tested within network namespace. application hangs @ ssl_connect. using sockets in blocking mode. read somewhere should use non-blocking mode instead solve issue. switched blocking sockets non-blocking sockets code still gets stuck @ ssl_connect method in client. i have simple client-server program nothing fancy stuff. have added ssl methods inside them make them secure. works when run them inside terminal when switch network namespace , run inside virtual network, client code hangs @ ssl_connect. not able understand may causing problem. appreciated! here code server.c file: #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> #include <errno.h> #include <sys/select.h> #include <sys/types.h> #include <unistd.h> #include <string.h...

java - Event Handling for Pie Chart -

i have created javafx pie chart , want when user clicks on slice of pie. following tutorial: for (final piechart.data data : chart.getdata()) { data.getnode().addeventhandler(mouseevent.mouse_pressed, new eventhandler<mouseevent>() { @override public void handle(mouseevent e) { caption.settranslatex(e.getscenex()); caption.settranslatey(e.getsceney()); caption.settext(string.valueof(data.getpievalue()) + "%"); } }); i getting these error warnings prior compile: on ".addeventhandler" bound mismatch: generic method addeventhandler(eventtype<t>, eventhandler<? supert>) of type node not applicable arguments (integer, new eventhandler<mouseevent> (){}). inferred type mouseevent&event not valid substitute bounded parameter <t extends event> on "eventhandler" bound mismatch: type mouseevent not valid substitute bounded parameter <t extends event...

java - Using Gradle in Android Development -

im new android development , ive seen old tutorials before regarding development on eclipse. download new android studio use development. however, found new called gradle files present in projects folder along normal files used in project. everytime try run app following error: " gradle: failure: not determine tasks execute. * went wrong: task 'assemble' not found in root project 'sampleproject'. * try: run gradle tasks list of available tasks. " could please explain whats use of gradle? , have use while developing android apps? thank you version 0.2.1 of studio released , provides better error. should upgrade , see happens, it's project has problem should fixed instead of randomly adding task shouldn't added.

cross-domain image for three.js (canvas/webGL), proxy? -

i realize may not possible... i've been scouring around , trying out different things no avail, thought might merit post before giving up... i'm putting app uses three.js (webgl) , give user option input url image on web , use texture 3d object in web app. no problem if not whole cross-domain security issue. i know there supposed work arounds cors approved images, though don't entirely understand this, it's impression has set on host's end (and users need able pull image anywhere on web , use @ texture) >> i've tried this: https://hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/ ...but didn't work (probably due misunderstanding of constitutes "cors approved" ) i thought maybe doing kind of php proxy might work? tried this: http://benalman.com/code/projects/php-simple-proxy/docs/files/ba-simple-proxy-php.html ...but didn't seem have luck. (it may not have been written work images... getting ...

php - (CakePHP on WAMP) page hangs on load only in IE -

i'm developing application in cakephp , i've been debugging firefox. has been great until decided test ie , came across strange behavior. pages not load in ie, they'll sit there loading status. page hangs simple, makes use of cakephp's html helper create single form , check authcomponent::user() (to see if user logged in). i'm convinced issue has sessions. open page in ie , in fact hang, can't view page in firefox until stop connection in ie. again, issue not occur whatsoever in firefox. i've tried fixes posted within sessionid cookie in cakephp causing page hang no luck. update: installed xdebug. placed call xdebug_break() @ beginning of index.php in webroot directoy. when requests in ie hang, breakpoint never triggered. i'm suspecting wamp acting up? here code causing concern, in root controller other controllers extend. public function beforefilter() { if($this->auth->user()) { if($this->auth->user('roles...