Posts

Showing posts from March, 2012

google cloud messaging - Android GCM example - how to implement in existing project? -

i've downloaded latest gcm example fromm google on github. it works well, can't make work in own project. i've got donut turning , message "generating instanceid token..." i didn't understand link class gcmsender in example. here code public class mainactivity extends actionbaractivity { private static final int play_services_resolution_request = 9000; private static final string tag = "mainactivity"; private broadcastreceiver mregistrationbroadcastreceiver; private progressbar mregistrationprogressbar; private textview minformationtextview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // url string url="http://www.monurl.org/"; webview mwview=(webview) this.findviewbyid(r.id.webview); //autorise jav

Segmentation fault (core dumped) in file handling in c -

i new stack overflow please forgive me if have disobeyed rules. trying run code #include<stdio.h> #include<stdlib.h> int o[100][100]; int a[100][100]; int b[5]; int h,w; int alpha; int min() { int i,m=b[0],k=0; for(i=1;i<5;i++) { if(b[i]<m) { m=b[i]; k=i; } } return k; } int set(int j,int k) { b[0]=a[j][k]; b[1]=((j-1)>=0)?a[j-1][k]:12000; b[2]=((k-1)>=0)?a[j][k-1]:12000; b[3]=((k+1)<w)?a[j][k+1]:12000; b[4]=((j+1)<h)?a[j+1][k]:12000; int dir=min(); int j1,k1; if(dir==1) { j1=j-1; k1=k; } else if(dir==2) { j1=j; k1=k-1; } else if(dir==3) { j1=j; k1=k+1; } else if(dir==4) { j1=j+1; k1=k; } if(o[j1][k1]==-1 && dir!=0) set(j1,k1); if(dir==0) { o[j][k]=alpha;

Java regex match not working -

i trying match string using java regex, match failing. may issue in code below? string line = "copy of 001"; boolean b = pattern.matches("001", line); system.out.println("value : "+b); output value value : false matches match whole string. use matcher , find() method instead: boolean b = pattern.compile("001").matcher(line).find(); or make pattern more flexible , allow have prefixing "001". example: ".*001" for simple, though, pattern overkill , simple indexof job more efficiently: boolean b = line.indexof("001") > -1;

playframework - How does @Inject in Scala work -

i'm wondering how @inject annotation in play-scala works. injects dependency, i'm curious how working. when using on class extending controller , set routes generator injectroutesgenerator seems autmagically create objects classes, how use in other context? i tried: @inject val mailer: mailerclient = null but doesn't seem work. there posibilities @inject things (that mailerclient, ws ets.) directly value, not controller class? looks close. change val var because not final , needs injected @ latter stage. @inject var mailer: mailerclient = null i'd check mailerclient library mentioned dependency in project configuration. try wsclient instead it's included default in template: @inject var ws: wsclient = null especially know particular 1 works. update created demo on github play-scala template index method changed follows: import play.api._ import play.api.libs.ws.wsclient import play.api.mvc._ import play.api.libs.concurrent.e

java - Getting null pointer exception on callbackmanager -

i'm using facebook sdk. when logging, i'm getting nullpointer exception, loginbutton loginbutton; callbackmanager callbackmanager; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); callbackmanager = callbackmanager.factory.create(); facebooksdk.sdkinitialize(getapplicationcontext()); setcontentview(r.layout.activity_main); loginbutton = (loginbutton)findviewbyid(r.id.login_button); list<string> permissionneeds = arrays.aslist("user_photos", "email", "user_birthday", "public_profile"); loginbutton.setreadpermissions(permissionneeds); loginbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { system.out.println("onsuccess"); }

bash - Errors when executing switch/case in awk command in Ubuntu and Mac -

i have strange problem when executing following code: awk '{ foo = 1; switch (foo) { case 1: i=i+1; break; } }' ./tcpheader.txt getting following error: awk: syntax error @ source line 1 context { foo = 1; switch (foo) >>> { <<< awk: illegal statement @ source line 1 awk: illegal statement @ source line 1 any idea what's problem ? tested on mac: awk --version output: awk version 20070501 tested on ubuntu: awk -w version output: mawk 1.3.3 nov 1996, copyright (c) michael d. brennan compiled limits: max nf 32767 sprintf buffer 2040 installing gawk solved problem: sudo apt-get install gawk in mac: sudo port install gawk

jquery - How to calculate Last column total -

i have 1 html table. want last column total. these excepting result -------------------------------- | names |process_id | total| -------------------------------- |construction 1001 1001 | |engineering 1005 1005 | |total 0 2006 | ---------------------------------- i tried thing here please me these thank you. try rowcount = $('#table4 tr:last').index() + 1; var total_1 = 0; (i = 1; < rowcount; i++) { var rows = $('#table4 tbody tr'); var cellval_2 = parsefloat($('#table4 tr:eq(' + + ')').find("td:last").text().replace(',', '')); $('#table4 tr td:last').each(function() { var cellval_1 = parsefloat($('#table4 tr:eq(' + + ')').find("td:last").text().replace(',', '')); if (!isnan(cellval_1)) { total_1 = total_1 + cellval_1; } }); } $('#t

html - How can I create large ASCII text from a string? -

given string, example 'imgur', how can generate large ascii text following? thanks. _ (_) _ _ __ ___ __ _ _ _ _ __ | | '_ ` _ \ / _` | | | | '__| | | | | | | | (_| | |_| | | |_|_| |_| |_|\__, |\__,_|_| __/ | |___/ you can use ascii text generator figlet uses figlet fonts. toilet figlet , can use figlet fonts additional capabilities including unicode handling, colour fonts, filters , various export formats. specific logos may need created own font. here links: figlet: http://www.figlet.org/ toilet: https://apps.ubuntu.com/cat/applications/toilet/ figlet fonts: http://www.figlet.org/fontdb.cgi figlet web demo: http://www.kammerl.de/ascii/asciisignature.php

java - JDBC - PostgreSQL - batch insert + unique index -

i have table unique constraint on field. need insert large number of records in table. make faster i'm using batch update jdbc (driver version 8.3-603). there way following: every batch execute need write table records batch don't violate unique index; every batch execute need receive records batch not inserted db, save "wrong" records ? the efficient way of doing this: create staging table same structure target table without unique constraint batch insert rows staging table. efficient way use copy or use copymanager (although don't know if supported in ancient driver version. once done copy valid rows target table: insert target_table(id, col_1, col_2) select id, col_1, col_2 staging_table not exists (select * target_table target_table.id = staging_table.id); note above not concurrency safe! if other processes same thing might still unique key violations. prevent need lock target table. if

ruby on rails - want to encrypt password like devise gem and check in db -

how encrypt password through devise gem manually? there gem this? password coming form web service , want encrypt , check in db devise internally uses bcrypt gem encryption. bcrypt class user < activerecord::base before_save :encrypt_password validates_confirmation_of :password validates_presence_of :password, :on => :create def encrypt_password if password.present? self.password_salt = bcrypt::engine.generate_salt self.password_hash = bcrypt::engine.hash_secret(password,password_salt) end end end try this.

jquery - primefaces javascript event for tab inside accordian panel -

i using primefaces accordianpanel <h:form id="mainmenuform" style="font-size: 13px;font-weight: bold;"> <p:accordionpanel id="accord"> <p:tab id="hometab"> <f:facet name="title"> <p:graphicimage id="homeicon" value="images/home.png" width="13%" height="13%" /> <p:outputlabel value="home" id="homelabel"/> </f:facet> <ul> <li>val1</li> <li>val2</li> <li>val2</li> </ul> </p:tab> <p:tab> <f:facet name="title"> <p:graphicimage id="projecticon" value="images/createproject.png" width="13%" height=&

events - Javascript Key Handler -

i have javascript key handler function , im trying use in game im working out doesnt seem quite working , im not sure if editor or code has errors. code shown: var mykey = { pressedkeys: [], left: 37, up: 38, right: 39, down: 40, ispressed: function(zkey){ return this.pressedkeys[zkey]; }, onkeydown: function(event){ this.pressedkeys[event.keycode] = true; }, onkeyup: function(event){ this.pressedkeys[event.keycode] = false; }, }; window.addeventlistener("keydown", mykey.onkeydown); window.addeventlistener("keyup", mykey.onkeyup); var checkinput = function(){ if(mykey.pressedkeys[mykey.left]){ confirm("pressed left"); } } var gameloop = function(){ checkinput(); window.requestanimationframe(gameloop); } the game loop animation frame called first time in main function thats not shown here. dont understand going wrong. tried hard coding numbers , stil

Display Popup when text is clicked in wordpress -

i have html code in wordpress.: ' <a href="">example</a> ' when "example" clicked, needs show popup window texts. came across wordpress popup plugins uji popup,etc.. given short codes. how can use shortcodes "href". or other plugins can use, or easy ideas display popup when text clicked in wordpress? hi can used bootstrap modal popup. demo <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> <!-- button trigger modal --> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#mymodal"> launch demo modal </button> <!-

php - Laravel query, foreach function to remove items then paginate -

a user searches profiles within km radius i.e. 50 km of run function uses latitude/longitude values retrieve results (this rough search within square not straight line distance), paginate results. $query = $this->filternearby($query, $geocode); $query = $query->paginate(10); but each query need run proper distance using great circle formula (to accurate 50km) , people searched may willing travel 20km location need remove these query. i have tried $query = $query->get() prior pagination, each remove items pagination not work. have tried create new paginator unsure how works through view? latest code: if (\request::segment(2) == "jobs") { $query = $this->searchjob($search_strategy); $query = $this->filternearbyjob($query, $geocode); $query = $this->filterjob($query); $query = $query->get(); // foreach function go here accurate dist

ios - Unbalanced call to dispatch_group_leave() on CloudKit CompletionBlock -

so building ios app working cloudkit. particular function calls products: func getallproducts(){ //empty object in singleton class sharedstore.products.removeallobjects() var products = nsmutablearray() //set query var predicate = nspredicate(value: true) var query = ckquery(recordtype: "product", predicate: predicate) //set in query operation var queryoperation = ckqueryoperation(query: query) //define method catch fetched records //define completion block process results queryoperation.querycompletionblock = { (cursor: ckquerycursor!, error: nserror!) in if error != nil { //there error, error delegate self.delegate?.cloudkitreturnederror(error) } else { //there no error println("no error") //cursor used know if there more data fetched, check cursor if cursor != nil { //there more data fetch pr

R - ddply to act on 2 columns in 3 column data.frame -

i trying use ddply act on 2 columns in 3 column data.frame. know i've done before, life of me cannot work. here's example: func = function(x, y) { if(x>y) { x-y } else { 0 } } df = data.frame(name=c('w','x','y','z'), a=c(1,2,3,4), b=c(4,3,2,1)) here i've tried, along many other things: ddply(df, summarize, func(a, b)) ddply(df, mutate, func(df$a, df$b)) ddply(df, func) the common error is: error in usemethod("as.quoted") : no applicable method 'as.quoted' applied object of class "function" expected output: name b result 1 w 1 4 0 2 x 2 3 0 3 y 3 2 1 4 z 4 1 3 ddply(df,.(name), summarize, result=ifelse(a>b,a-b,0)) or func = function(x, y) { ifelse(x>y,x-y,0)} ddply(df,.(name), summarize, result=func(a,b)) run code in rfiddle

c# - Program hanging point identification -

Image
there c#-program hangs pretty rare. execution of program takes place on remote machines , start debugger not option. run external profiler more realistic, conjugate huge difficulties. how can determine point of program hang without profiler or debugger? option "detailed logging on fs" poorly suited. program consists of 20 thousand lines of code , hangs not often. i have tried process explorer works strange (or have not understood it). if have managed "catch" moment when thread entered infinite loop, possible see stack in moment. thread disappears quite (whether in pe or killed environment). the option create application, application-monitor, acceptable. if can how create dump of main process or obtain information threads of main process, great. if have ready tools, better. when application crashes, should logged window's application event log . it's not extremely detailed, should give pretty solid clues anyway without external tools needed

api - PHP put request with JSON -

i using parseapi ( https://parse.com/docs/rest/guide#objects-updating-objects ) , i'm attempting update object rest api. response parse saying object updated, no change made. can please guide me in correct direction? thank you!! <?php $url = ' https://api.parse.com/1/classes/gamescore/ed1nuqpvcm'; $appid = 'my app id'; $restkey = 'my rest key'; $headers = array( "content-type: application/json", "x-parse-rest-api-key: " . $restkey, "x-parse-application-id: " . $appid ); $data = array('pass' => 'hi'); $jsondataencoded = json_encode($data); $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_customrequest, "put"); curl_setopt($ch,curlopt_httpheader,$headers); curl_setopt($ch, curlopt_postfields, http_build_query($jsondataencoded)); $response = curl_exec($ch); echo $response; ?>

java - Variable Setting to All Subclasses -

is there way insantiate variable encompasses subclasses of class? i've read far must state type variable before setting equal something: example: exampleobject1 object = reference object but if wanted make set variable instance or subclass of object? yes, can that. a variable of type t (as long t class/interface/enum/annotation) can hold reference instance of class t , or instance of class extends or implements t . for example, works: class myclass1 { // ... stuff goes here ... } class myclass2 extends myclass1 { // ... stuff goes here ... } class main { public static void main(string[] args) { myclass1 object = new myclass2(); } }

Thread management for Akka actors -

i have 32 actors running @ time 24 threads. first 24 actors gets 24 available threads. remaining 8 threads execution threads termination of 1 of 24 actors. can please point me how change dedicated thread option per actor shared one. thanks, cabear this how actor scheduling works - should read on akka dispatchers better understanding of it. in 1 sentence though: actors multiplexed onto threads. means multiple actors using same thread, not @ same time - works this: actor has messages process, gets thread t1, processes number of messages (set throughput setting in dispatchers), , lets go of thread t1 such actor b can use t1 again. if there's more threads available t2 used in same style, allowing multiple actors run in parallel.

javascript - Why is <body> element in the tab sequence in ember application. clean to make address bar not in the tab sequence -

i have simple form in ember.js has 3 form elements. tab go through 5 element , element can't see, used document.activeelement in console, got element, doesn't have tabindex attribute. there know why element in tab sequence? , also, what's clean way skip address bar(url field) in tab sequence. thanks.

c# - Crystal report viewer triggers invalid cast exception error -

i using crystal reports ver 14 visual studio 2010/12. continue have problem crystal reports view triggers following: system.invalidcastexception error. when trying set viewer report source. -running windows os7 latest updates -report has data -report prints directly printer fine ////////////////// create report document////////////////////////////// reportdocument crreport = new reportdocument(); // load .rpt file; statement need changed reference application.startuppath crreport.load(@"c:\cpms.net.sql\cpms.net\crpprojectlist.rpt"); // set report title1, title2, title3 here // txttitle1 // txttitle2 // txttitle3 // set report datasource ds.tables[2]; tables[2] = tbl01_general crreport.setdatasource(ds); // set viewer control , preview report this.axcrystalactivexreportviewer1.begininit(); this.axcrystalactivexreportviewer1.reportsource = crreport; //this line causing problem this.axcrysta

Java check if squaring integers causes overflow -

how can possibly determine if squaring integer causing overflow. number greater 46340 have square value greater maximum integer value of java. since java wrap numbers squaring 46431 gives -2147479015 whereas squaring 2147483647 gives 1, further complicates. unfortunately cannot in java 8 have thrown arithmeticexception. there other possible way of checking if squaring integer causing overflow or not? public class securesquare { private static final double secure_square_limit = math.sqrt(integer.max_value); public static int square(int number) { if (math.abs(number) > secure_square_limit) { throw new arithmeticexception("square overflow exception!"); } return number * number; } public static void main(string[] args) { int number = square(-46340); system.out.println(number); } } output 43640: 2147395600 output 43641: exception in thread "main" java.lang.arithmeticexcepti

ios - Action after tweet has been published -

i set button in game can tweet score. thing when user publishes tweet want open new view , don't know how know when tweet has been published. publish tweet used code: -(void)sharetwitter { if ([slcomposeviewcontroller isavailableforservicetype:slservicetypetwitter]) { slcomposeviewcontroller *tweetsheet = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypetwitter]; [tweetsheet setinitialtext:[nsstring stringwithformat:@"i've scored 98 points!]; uiviewcontroller *controller = self.view.window.rootviewcontroller; [controller presentviewcontroller:tweetsheet animated:yes completion:nil]; } } you can set completion handler on tweetsheet so: [tweetsheet setcompletionhandler:^(slcomposeviewcontrollerresult result) { switch (result) { case slcomposeviewcontrollerresultcancelled: nslog(@"post canceled"); break; case slcomposeviewcontrollerres

compiler construction - Compile Java source code from a string? -

this question has answer here: how programmatically compile , instantiate java class? 3 answers is there way running java program compile java source code (passed string)? class newclass = compiler.compile ("class abc { void xyz {etc. etc. } }"); ideally, classes referenced passed-in source code resolved program's class loader. does exist? sure. have @ javacompiler class , other classes in javax.tools package. they've been around since java 1.6. here example code. (as pointed out @sergey tachenov in comments, needs jdk installed necessary tools.jar file comes jdk not jre.)

.net - how to deploy both x86 and x64 MSVCR120 to local application folder for C# project? -

my ultimate purpose deploy .net application clickonce , copy runtime dlls (msvcr, msvcp) local application folder. needed nlua integration .net app. that way user doesn't need install using microsoft redistributable package, not have admin right install that. the possible method can think of have both x86 , x64 dlls deployed somewhere separate folders , during application launch, detect user platform , copy right dlls actual app/bin folder. avoid doing if known method work on case. appreciate given.

python - What is the best way to calculate percentage of an iterating operation? -

i've written function saves numbers between 2 digit groups text file, step option save space , time, , couldn't figure out how show percentage value, tried this. for length in range(int(limit_min), int(limit_max) + 1): percent_quotient = 0 j=0 while j <= (int(length * "9")): while len(str(j)) < length: j = "0" + str(j) percent_quotient+=1 j = int(j) + int(step) # increasing dummy variable length in range(int(limit_min), int(limit_max) + 1): counter=1 = 0 while <= (int(length * "9")): while len(str(i)) < length: = "0" + str(i) # print "writing %s file. progress: %.2f percent." % (str(i),(float(counter)/percent_quotient)*100) a.write(str(i) + "\n") # gets written = int(i) + int(step) # increasing counter+=1 if length != int(limit_max): print "length %i done. moving o

python - Embedding plot to web page using rbokeh -

i have created plot in r using rbokeh , want convert html/javascript in order embed inside web page. i'm able achieve mpld3 on python (and know bokeh on python too) want able rbokeh in r. i'm looking similar python's mpld3.fig_to_html(), e.g: fig, ax = plt.subplots() ax.p1 = plt.bar(...) html = mpld3.fig_to_html(fig) # <- converts plot html/javascript! print html # prints out html/javascript code text or using python's bokeh module: embed.autoload_static() can rbokeh plots converted html/javascript code? many in advance. it appears that, date, savewidget closest want, hrbrmstr . wanted avoid having read , write disk every time graph exported html it's not possible yet.

java - Boolean and if mistake -

this question has answer here: how compare strings in java? 23 answers i have problem code. process - first enter name then enter age then enter password (default value "anybody") name , age can entered without problem program evaluates password error. when enter password correctly, still returns false. please me!! thanks. import java.util.scanner; public class myclass { public static void main(string[] args) { string name; int age; boolean trueorfalse; boolean trueorfalse2; string builtinpassword = "anybody"; scanner keyboardinput = new scanner(system.in); system.out.print("please enter first name: "); name = keyboardinput.next(); system.out.print("please enter age: "); age = keyboardinput.nextint();

jquery - Best way to have a javascript load only on desktop version of site? -

i have javascript (jquery) running on wordpress site. want script load if screen width under 1024 pixels. the reason because has how top navigation menu functions. want script load when screen width under 1024 pixels, because under going have different menu style / functionality. naturally have plenty of media queries in css file change design @ min-width: 1024px. i've found several ways this, i'm trying determine best way be. here copy of current javascript file: function accordion_menus(){ // if not on mobile (menu icon hidden) show sub items , bail console.log('debug: start'); if ( jquery('#primary-navigation .menu-toggle').is(':hidden') ){ console.log('debug: yes, hidden'); // show sub menus $('#primary-navigation ul.nav-menu ul.sub-menu').show(); return; } else{ // hide sub menus $('#primary-navigation ul.nav-menu ul.sub-menu').hide(); } // top level nav click function $('#primary-

matlab - Understand and implement power spectral density -

i have problems when comes understand power spectral density (especially difference between discrete , continuous). "beginner" question hope has time clarify me since literature gave me contradictory results , confused me more. i found 2 terms seemingly not same: power density spectrum power spectral density (some books scaled power density spectrum) so in understanding power spectral density (sxx) should give power per hz. continuous signal can calculated fourier transform of autocorrelation function (through integral unit w/hz seems fine). followingly signals power can calculated total integral of sxx. but how calculate discrete , finite signal? ("by hand" , not use pwelch) if apply autocorrelation , use fft in case obtain: sxx_disc=1/n*abs(fft(x)).^2 n=length(x) but if use sum(sxx_disc) doesn't give me right signalpower should be: px_disc=1/n*sum(abs(x).^2) . px_disc obtain sum(sxx_disc)/n - why have divide n again? thank kind of help

Aggregate count by several weeks after field data in PostgreSQL -

i have query returns that: registered_at - date of user registration; action_at - date of kind of action. | registered_at | user_id | action_at | ------------------------------------------------------- | 2015-05-01 12:00:00 | 1 | 2015-05-04 12:00:00 | | 2015-05-01 12:00:00 | 1 | 2015-05-10 12:00:00 | | 2015-05-01 12:00:00 | 1 | 2015-05-16 12:00:00 | | 2015-04-01 12:00:00 | 2 | 2015-04-04 12:00:00 | | 2015-04-01 12:00:00 | 2 | 2015-04-05 12:00:00 | | 2015-04-01 12:00:00 | 2 | 2015-04-10 12:00:00 | | 2015-04-01 12:00:00 | 2 | 2015-04-30 12:00:00 | i'm trying implement query returns me that: weeks_after_registration - in example limited 3, in real task limited 6. | user_id | weeks_after_registration | action_counts | ------------------------------------------------------- | 1 | 1 | 1 | | 1 | 2 | 1 | | 1 |

sql server - Is it possible to iterate a calculation across distinct values in a column? -

i want iterate calculation takes counts of people fit particular criteria , calculates percentages based on counts across distinct regions. my code: use database1; go declare @shouldregister float declare @registered float set @shouldregister = (select count(*) dbo.table field1 in.. , field2 in.. , field3 in.. ... ) set @registered = (select count(*) dbo.table field1 in.. , field2 in.. , field3 in.. ... ) select @shouldregister shouldregister , @registered registered , cast((@registered/nullif(@shouldregister, 0))*100 decimal(12,8)) percentmet , cast(100*2.33*(sqrt(@registered/nullif(@shouldregister, 0) * (1-(@registered/nullif(@shouldregister, 0)))/nullif(@shouldregister, 0))) decimal(12,8)) + cast((@registered/nullif(@shouldregister, 0))*100 decimal(12,8)) adjpercentmet the code returns

javascript - Google Polymer 1.0 - Auto-binding template values empty? -

i'm developing application inspired polymer starter kit , works fine in chrome in safari {{route}} , {{user}} stamped dom empty values. i've noticed auto-binding template values not empty in both chrome , safari in vanilla polymer starter kit. or insight what's happening , why auto-binding template values empty in safari appreciated. here's i've got far: routing.html : <script src="page/page.js"></script> <script> window.addeventlistener('webcomponentsready', function() { page('/', function() { app.route = 'home'; app.user = 'alex'; }); // initialize router. page(); }); </script> elements.html : <link rel="import" href="iron-flex-layout/iron-flex-layout.html"> <!-- <link rel="import" href="iron-ajax/iron-ajax.html"> --> <link rel="import" href=&qu

select - iOS: change background color using multiple buttons -

i trying change background color randomly effect overtime of buttons on screen tapped. control effect on/off uibutton. tapping changecolorbutton logs “off” never “on”. not sure do? everyone!! edited code far!! in .h @property(nonatomic,readwrite) bool shouldchangecolor; in .m - (ibaction)changecolorbutton:(uibutton*)sender { // self.shouldchangecolor = !sender.selected; sender.selected = !sender.selected; if(sender.selected) { nslog(@"switch on"); //make off // sender.selected=no; // self.shouldchangecolor=true; } else nslog(@"switch off"); //make on // sender.selected=yes; self.shouldchangecolor=true; } - (void)randomcolor{ int r = arc4random() % 255; int g = arc4random() % 255; int b = arc4random() % 255; uicolor *color = [uicolor colorwithred:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:1.0]; [self.view setbackgroundcolor:color]; } becau

mysql - Django - Dojo/Dgrid - how to manage LARGE data sets -

6.30.15 - how can make question better , more helpful others? feedback helpful. thanks! i developing web application handle/manage large data set - kind of heavy load causes browser lock - whether i'm in django rest framework api or in dojo/dgrid. kind of dual question. i've researched , can't find clear way on either side. how limit how database sends @ 1 time django rest framework and/ or dojo dgrid. dgrid pulls data django rest api. drf pulls data directly mysql database. if can control how data sent @ 1 time, won't lock browser much. suggestions, advice, help, examples helpful. in advance! updated 6.22.15 - alright, got pagination work , display limit/offset in headers. :) yay!!!! can see data in response headers. however... grid won't populate , keep getting odd error: typeerror: transform(...) null return transform(value, key).tostring(); instrum...tion.js (line 20) i've gotten error before, i've never been able find solution

excel - PowerPivot Relations - error while creating -

Image
i m trying create relation between database , table created avoid using vlookup formula in excel. error. want link account daily report names. can tell me how solve or why getting error? thanks as error message states, have either duplicate entries or blanks in "daily report names" column. note when bring data power pivot trims it, items different in excel due trailing spaces become duplicates in pp. check not bringing through blank rows in dataset. highlight number of rows on excel sheet below dataset , delete entire rows.

vb6 trying to get old program working with excel 2013 -

i have code program created take data , export excel in vb6 , dont know vb6 started coding in vb.net tell me why isnt working excel 2013 opens closes right away , unsure why. sub getexcel() dim myexcel object ' variable hold reference ' microsoft word. dim excelwasnotrunning boolean ' flag final release. ' test see if there copy of microsoft excel running. 10 on error resume next ' defer error trapping. ' getobject function called without first argument returns ' reference instance of application. if application isn't ' running, error occurs. 20 set myexcel = getobject(, "xlmain") 30 if err.number <> 0 excelwasnotrunning = true 40 err.clear ' clear err object in case error occurred. ' check microsoft excel. if microsoft excel running, ' enter running object table. 50 detectexcel ' set

How to merge old version to head of a branch in git? -

my repository has 2 branches, master , mybranch . i've commited many times mybranch , realized many of changes not wanted. thus, did git checkout of old commit on* mybranch* using git checkout 02c383 i want old commit head of mybranch . how do this? when @ branches, see: $ git branch *(detached numbershere) mybranch master git checkout mybranch git reset --hard 02c383 after this, mybranch moved point 02c383 .

magento - Add block to all CMS Pages with certain URL Key -

Image
i'm trying discover whether possible or not. have series of cms pages represent our library. so url keys these pages like: library/ library/top-ten library/five-questions library/faq etc... the powers want add static block appear only on library cms pages. there way, in layout xml file, target pages contain keyword, along lines of <default> .... </default> <library_*> <reference name="right"> <block goes here/> </reference> </library_*> you may find this question useful understand cms page layouts. while can’t accomplish trying in way going exactly, here couple of options consider: add layout xml each of cms pages in admin this preferred solution since leverages out of box functionality, requiring less maintenance , no coding knowledge modify. when editing cms page, go design tab: here can change page template. select custom page template— that create static block in

javascript - angularjs: input with ng-model tag does not appear in model until I type in it -

why properties not appear in model until user types in field? i have simple form: <form ng-controller="ctrlapplicantinfo vm"> <input id="name" name="name" ng-model="vm.applicantinfo.name" class="form-control" type="text" placeholder="name" /> <input id="age" name="age" ng-model="vm.applicantinfo.age" class="form-control" type="text" placeholder="age" /> </form> and controller: myapp.controller('ctrlapplicantinfo', ['$scope', '$http', '$interval', '$filter', function ($scope, $http, $interval, $filter) { var vm = this; $scope.$watch("vm.applicantinfo", function (newvalue, oldvalue) { console.log("something has changed"); console.log("newvalue: " + json.stringify(newvalue)); console.log("oldvalue: " + json.string

javascript - Mmenu Vertical Submenu w/ JQuery toggle -

has been able implement .slidetoggle vertical submenu opposed display:none / display block functionality? i able intermittently work it's fighting built in functionality, i'm not sure how disable. i haven't been able find in documentation admittedly amount of scripting little on head. any guidance appreciated. $("#dropdown").click(function () { $(".dropdown-mmenu").slidetoggle("slow", function () { // animation complete. }); }); https://jsfiddle.net/ub75faxv/1/ alright - wasn't far off, moment of clarity struck. comment out: .mm-listview .mm-vertical .mm-panel, .mm-vertical .mm-listview .mm-pane , .mm-vertical li.mm-opened>.mm-panel, li.mm-vertical.mm-opened>.mm-panel , add $(".dropdown-mmenu").hide(); above script set hidden on load. done.

python - Why is my tkinter toplevel 'X' button over-ride method not being called? -

i have created toplevel widget class , want call method 'close' when window 'x' (closed). error - name 'close' not defined. me getting method run when toplevel window closed? code in focus: class questions_window(): def __init__(self, master): self.master = master self.master.geometry("300x300") self.master.title("questions") self.master.protocol("wm_delete_window", close) def focus(self): self.master.attributes("-topmost", 1) self.master.grab_set() def close(self): global paused paused = false self.master.grab_release() self.master.destroy() full code: from tkinter import * #starting velocity ball x_speed = 25 y_speed = 25 paused = false class questions_window(): def __init__(self, master): self.master = master self.master.geometry("300x300") self.master.title("questions&qu

Spring Data Couchbase and Spring Data MongoDB at the same time use -

i want use spring data couchbase , spring data mongodb @ same time. has error happen, both hava bean customconversions defined. so, how deal it? this stacktrace caused by: java.lang.classcastexception: org.springframework.data.mongodb.core.convert.customconversions cannot cast org.springframework.data.couchbase.core.convert.customconversions @ com.*.*.config.dev.developmentcouchbaseconfig$$enhancerbyspringcglib$$64a18d5.customconversions(<generated>) @ org.springframework.data.couchbase.config.abstractcouchbaseconfiguration.couchbasemappingcontext(abstractcouchbaseconfiguration.java:157) @ com.*.*.config.dev.developmentcouchbaseconfig$$enhancerbyspringcglib$$64a18d5.cglib$couchbasemappingcontext$13(<generated>) @ com.*.*.config.dev.developmentcouchbaseconfig$$enhancerbyspringcglib$$64a18d5$$fastclassbyspringcglib$$7675b050.invoke(<generated>) @ org.springframework.cglib.proxy.methodproxy.invokesuper(methodproxy.java:228) @ org.springfr