Posts

Showing posts from February, 2012

Need regex to match word or end of string -

i'm trying contents of string can either of two. title1: *stuff_to_get* title2:... title1: *stuff_to_get* my regex looks this "title1:\s*?(.+?)title2|$" the reasoning is: *stuff_to_get* can flush colon or not why include the "\s*?" then regex should grab until sees title2 or end of string. appreciated. alternations ( | ) apply entire group they're in or entire pattern, if not in groups. haven't grouped alternation anything, version match title1:\s*?(.+?)title2 or end of string , nothing else. you need group alternation this: title1:\s*?(.+?)(?:title2|$) it's little strange have 2 lazy quantifiers together. if want allow white space before *stuff_to_get* , \s* (no ? ) little bit more clear: title1:\s*(.+?)(?:title2|$)

c++ - Is there anyway I can prevent throw from calling malloc -

background in c++ program have sigalrm handler in want convert signal exception doing throw (i understand in general not practice, in system working on it's option). problem here sigalrm handler invoked when doing malloc, while throw call __cxa_allocate_exception malloc. 2 malloc calls can hit deadlock in glibc 2.12. tried pre-allocating exception, call __cxa_allocate_exception still happened. checked source code of gcc , there doesn't seem condition of putting __cxa_allocate_exception call. additional background i install signal handler right before try block , uninstall after catch. i'm throwing signal handler , way think inside try block (let's not consider case signal received when in catch logic) , can caught correctly. i think i'm hitting malloc deadlock described here: https://sourceware.org/bugzilla/show_bug.cgi?id=13699 , here https://sourceware.org/ml/libc-alpha/2012-02/msg00272.html . question my question is: there anyway can prevent thr

php - Check if variable exist in laravel's blade directive -

i'm trying create blade directive echo variable (if variable defined) or echo "no data" if variable undefined. this code in appserviceprovider.php : <?php namespace app\providers; use blade; use illuminate\support\serviceprovider; class appserviceprovider extends serviceprovider { /** * bootstrap application services. * * @return void */ public function boot() { blade::directive('p', function($ex) { error_log(print_r($ex,true)); return '<?php $defined_vars = get_defined_vars(); if(array_key_exists(\''. $ex .'\', $defined_vars) ): echo ' . $ex . ' ; else: echo \'no data\'; endif;?>'; }); } /** * register application services. * * @return void */ public function register() { // } } here index.blade.php: <p class="lead">@p($myvar)</p> but directive "p"

javascript - Wondering whats in this script causing it not to work in the new jquery update -

here link fiddle looking @ i'm looking for: https://jsfiddle.net/mariusc23/s6mlj/31/ upon attempting apply own purposes realized not working @ all. came conclusion version using causing not work.. not javascript/ jquery buff wondering precisely in script causing not work jquery 3.0.0-rc1 instead older version jquery 1.10.2 // hide header on on scroll down var didscroll; var lastscrolltop = 0; var delta = 5; var navbarheight = $('header').outerheight(); $(window).scroll(function(event){ didscroll = true; }); setinterval(function() { if (didscroll) { hasscrolled(); didscroll = false; } }, 250); function hasscrolled() { var st = $(this).scrolltop(); // make sure scroll more delta if(math.abs(lastscrolltop - st) <= delta) return; // if scrolled down , past navbar, add class .nav-up. // necessary never see "behind" navbar. if (st > lastscrolltop && st > navbarheight){

Android wifi-direct api for support Multi-group Networks -

my application need create multi-group wifi-direct communication.but after testing find none of following scenarios feasible in android: 1) device plays role of p2p client in 1 group , go in another. 2) device behaves client in 2 or more groups. i want ask google have plan update android wifi-direct api suppporting 1 of above, implement multi-group communication easily? or there ways 2 wifi-direct group communication each other in android? thanks!!!!!!!!!!!!!!!! simple answer questions be: no. though second question far know, no. anyway, if logic requires able go & client same time, work around creating normal access point, clients connect to, , connect other devices access point. for access point, example use creategroup function, create hidden access point. use wifi direct service advertising delivering password & ssid alongside ip-address other devices, discover access points , connect them.

javascript - jQuerying content made by VueJS -

i sure has been answered before new vuejs not know correct terminology. i have table of data created vue ( <template v-for="group in groups"> etc). gets information ajax call in vue object's ready() method. ( this.$set('groups', response.data.groups); each cell of table span element want to... $('.pie').peity(); on convert text svg. where should code placed? if doing right after table loaded, try using vue's nexttick: this.$nexttick(function() { $('.pie').peity(); });

raspberry pi - How Raspbian can control temperature by setup temp_limit in config.txt -

just got new rpi gen #3, has default /boot/config.txt has temp_limit=85 i turn down temp_limit=70 after reboot, works. if don't know how stress pi processor, , how read temperature of that, feel free clone simple github code (shell script) , run that. https://github.com/fisherworks/raspberry_pi_stress i thought it's dynamic lowering frequency can limit temperature of rpi - using following command, shows frequency still 1200000 , means it's running on full power. cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq now question - how raspbian control temperature of bcm processor without reducing freq? try instead. vcgencmd measure_clock arm and can check if being(has been), throttled, capped, or in under-voltage this. vcgencmd get_throttled https://retropie.org.uk/forum/topic/2295/runcommand-warning-if-voltage-temperature-throttling return code 0x50005. bit pattern: 0: under-voltage 1: arm frequency capped 2: throttled 16:

c# - Custom control does not exist in the namespace? -

i've been interested in wpf bindings in c# , tried bind control mouse position, after getting frustrating "the name "[control]" not exist in namespace "clr-namespace:[namespace]" every time pasted xaml code editor decided wasn't worth time investigate quirk. now attempting implement binded arc drawing example stack overflow , getting same eror again. (all code short runnable example can found there) so i've combed through stack overflow solution issue (it seems rather widespread) appear sporadic , inexpiable workarounds , fixes. this question says if nothing else possible, comment lines use namespace, rebuild, , build full project again. i tried rebuilding project, reopening visual studio. nothing helped. commented xaml, rebuilt project, uncommented xaml , worked! strange issue. this one said set project release mode , answer-er on same question said define assembly: ( xmlns:local="clr-namespace:musicplayer

mysql - Leravel .env configuration works with Laravel 5.2 but gives 2002 error with Laravel 5.1 -

2 working fine set .env file like: db_connection=mysql db_host=127.0.0.1 db_port=8889 db_database=phonelist db_username=phonelist db_password=***** now cloned github project developed in laravel 5.1 , created .env file same host , port created new db new user. db_connection=mysql db_host=127.0.0.1 db_port=8889 db_database=pinboard db_username=pinboard db_password=test i keep getting sqlstate[hy000] [2002] connection refused i can see errors include values .env file. else can troubleshoot this? said 5.2 connects fine, can make migrations , 5.1 throws error. positively db, user, , pass typed correctly.

r - Distinct (dplyr) not working well - unique observation based on criteria -

i have data duplicated records , of them should not there ( mark , recov should once per band , recap can present several times). want select unique observations ( band ) based on values in column ( variable=="mark" ) , keep rest of data "recap" , "recov" . i used dyplr , group data band select unique record when column variable=="mark" , code: uniq <- df %>%group_by(band) %>% distinct(variable=="mark") i found out not working well, when looking observations values variable=="recap" have been deleted (example: in band=113749924 , recap value 1993 missing, same case in band=113728509 there recap value missing) this data example: structure(list(band = c(113728501l, 113728502l, 113728503l, 113728504l, 113728505l, 113728505l, 113728506l, 113728506l, 113728507l, 113728508l, 113728509l, 113728509l, 113728509l, 113728509l, 113728510l, 113728510l, 113729709l, 113729709l, 113729709l, 113729710l, 1137297

In Java 8, How combine two different collection into one with one matching field? -

i combine 2 different data type collection using 1 matching field. list<foo> foos... list<bar> bars... public class foo { integer fooid; integer name; integer description; integer sent; //this should coming bar integer received; //this should coming bar } public class bar { integer barid; integer fooid; //combine foo using field integer sent; integer received; } i data bar put them in foo using fooid. both collection has unique data fooid. to make code more beautiful, can take @ below :) list<foo> foos = ... list<bar> bars = ... // convert list bars map map<integer, bar> map4bar = bars.stream().collect(collectors.tomap(bar::getfooid, function.identity())); // combine bar foo foos.foreach(foo -> foo.modifybybar(map4bar.get(foo.getfooid()))); and in foo class there should new method named convert, this: public foo modifybybar(bar bar){ if(bar != null){ this.sent = bar.sent;

web services - Capture JSON from representation and return String value -

i have working webservice shown below return double value in json format e.g. {"pmc":17.34} @override @post("json") public representation post(representation entity) throws resourceexception { jsonobjectbuilder response = json.createobjectbuilder(); try { string json = entity.gettext(); // json input client map<string, object> map = jsonutils.tomap(json); // convert input map double result = matrix.calculatepmc(map); // calculate pmc value response.add("pmc", result); } catch (ioexception e) { logger.error(this.getclass() + " - ioexception - " + e); getresponse().setstatus(status.server_error_internal); } return new stringrepresentation(response.build().tostring()); } now, change program return double value, i.e. 17.34 , modified program following: @post public double post(response response) { double result = 0; try { string json = respon

TDD, Ruby, & handling nil arguments -

part of practice of tdd involves easing core functionality edges, , starting testing simplest, degenerate case. i'm working in ruby, find myself writing test this: it "does thing if given nil" expect { my_method(nil) }.to do_the_thing end and production code this: def my_method(arg) if arg.nil? do_the_thing return end do_the_real_thing end i don't idea of littering every public method such guard-clauses, given dynamic nature of ruby, draw line? when reasonable put responsibility passing valid arguments on calling code? i'd write focused, expressive methods aren't littered overly-defensive code, want build robust , correct system. the practice of easing in edge-cases appeals me, i'm unsure how particular edge-case should handled. i believe decision on how defensive write code depends on how reasonable circumstances of error condition are. the question ask how reasonable assume condition occur in normal course of

python - pandas - combine strings of row -

i have dataframe this: id text 1 dm,htn,enlarged prostate 2 hypertensive , on regular treatment 2 lbp 3 dm,htn,enlarged prostate i want combine text of same id this: id text 1 dm,htn,enlarged prostate 2 hypertensive , on regular treatment lbp 3 dm,htn,enlarged prostate the texts of id 2 combined. how can acchieve this? appreciated. you can use groupby , apply function join . last reset_index : grouped_df = df.groupby("id")['text'].apply(' '.join).reset_index() print (grouped_df) id text 0 1 dm,htn,enlarged prostate 1 2 hypertensive , on regular treatment lbp 2 3 dm,htn,enlarged prostate

ruby on rails - Forcing https in elasticbeanstalk with certificate from ACM -

i have provisioned scalable eb(elasticbeanstalk) rails(puma) instance. have applied https through acm(amazon certificate manager) , applied load balancer. https enabled website now. how force redirect https? have tried number of solutions online suggested make nginx configuration setting manually through .ebextensions , not sure certificate acm this?(i assuming not possible acm right now?). how force https? the current aws eb rails , node.js setups both use nginx (if web server apache see this answer ), following should work (adapted this question ): create file .ebextensions/01-force-https.config (the .config important, not .conf ) following content. if environment single instance: files: "/etc/nginx/conf.d/01-force-https.conf": owner: root group: root mode: "000644" content: | server { listen 8080; return 301 https://$host$request_uri; } if environment load balanced, unfortunately cannot add

android - How to get cursor position of EditText considering the html tags of the EditText html String -

please me in getting position of cursor in edittext considering html tags of string. getselectionstart() giving cursor position in plain text, need position considering html tags of string. i have implemented textwatcher on edittext text change. there in ontextchanged callback getting position considering plain text need html tags i using this richedittext library edittext pfb code. there nothing have done. cursor index not correct unable proceed. public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); richedittext editpara_et=(richedittext )findviewbyid(r.id.editpara); string htmlstring="<p>i have edit text html string.</p>"; editpara_et.settext(html.fromhtml("<p>i have edit text html string.</p>")); mytextwatcher tw1 = new mytextwatcher(editpara_et,mainactivity.th

Near perfect collision in LibGdx Java -

Image
i trying collision in game perfect. testing if hit wall player, come stop. implemented collision code when player hits left side of wall(when wall on right side of player). here code. if(entityonright){ if(player.getpositioncorner(squaremaptuples.bottom_right).x - ent.getpositioncorner(squaremaptuples.bottom_left).x > -.9f) player.setmovementbooleans(false, false, false, false); else player.setmovementbooleans(true, false, false, false); } note: if go slow, stop player desire stopped, going fast, won't collision way want essentially, code states if wall on right side, check bottom right corner of rectangle of player, subtract bottom left corner of wall, , check if distance between 2 0.001. 0.001 unnoticeable distance, hence why used value. here code player.setmovementbooleans public void setmovementbooleans(boolean canmoveright, boolean canmoveleft, boolean canmoveup, boolean canmovedown){ this.ca

How to save time in database in timeformat in Laravel 5? -

i have been trying while saving time in database in timeformat 10:00:00 . what want pick time timepicker , save data(time) in timeformat . here have done: i have used timepicker gets data in format 10:52 am . i have used accessor methods save time follows: public function setrtimeattribute($value) { $this->attributes['r_time'] = date('h:i:a', strtotime($value)); } my post controller in case needed follows: public function postsessionreservation(request $request,$profile_slug) { $restaurant = restaurant::where('slug_profile', $profile_slug)->select('name','ar_name','slug_profile','id')->firstorfail(); $this->validate($request,[ 'no_of_seats'=>'required', 'r_date'=>'required', 'r_time'=>'required', 'restaurant_id'=>'required', ]); $data = [ 'no_of_seats'=>

java - The use of executor.shutdown() -

look @ following piece of code: public void pinger() { scheduledthreadpoolexecutor executor = new scheduledthreadpoolexecutor(1); executor.scheduleatfixedrate(runnable, start, rate, timeunit.seconds); executor.shutdown(); } is there use of writing shutdown command in case? different clients create own runnable objects , invoke function. when shutdown executor, no new task accepted. since create new 1 inside pinger method every task has own executor. shutdown write free resource once corrent task terminated.

gps - Latitude,longitude and geographical quarter (NW, NE, SW, SE) from a center to a given point -

considering latitude , longitude, looking way know in quarter located point given center. nw ne ......|...... ..x...|...... ......|...... ------x------ ......|...... ......|...... ......|...... sw se ignoring poles , antimeridian (where longitude = +/- 180), it's straightforward: if(lat > centerlat) if(long < centerlong) nw if(long > centerlong ne if(lat < centerlat) if(long < centerlong) sw if(long > centerlong se if need work near antimeridian, translate whole system east adding 180 degrees longitudes.

python - Which skeleton more correct -

i use torndo projects. use skeleton server. using code address methods via http://server/dev/foo , http://server/dev/bar . code work in production class mainhandler(sessionbasehandler): def __init__(self, *args, **kwargs): global logger super(mainhandler, self).__init__(*args, **kwargs) @tornado.web.asynchronous @tornado.gen.coroutine def post(self,func_name): request = self.request.body func = getattr(self, func_name) response = yield tornado.gen.task(func,request) self.write(response) self.finish() def foo(self, query, callback): callback({"queryfoo":query}) def bar(self, query, callback): callback({"querybar":query}) class tornadoapplication(tornado.web.application): def __init__(self): handlers = [ (r"/dev/(.*)", acquiring.mainhandler), ]

Get the visibility status of a toolbar according to Customize perspective dialog in Eclipse -

i'm working on plug-in, contributes toolbar. toolbar listed in customize perstpective dialog. when uncheck check-box, toolbar disappears expected. when toolbar updated code (using toolbar manager), gets displayed again. need somehow visibility status code in order prevent toolbar beeing updated when disabled. do have idea, customize perspective dialog stores visibility status of menus , toolbars , how code, please? you can information item id way: private static boolean istoolbaritemvisible(string id){ iworkbench workbench = platformui.getworkbench(); iworkbenchwindow workbenchwindow = workbench.getactiveworkbenchwindow(); return !((workbenchpage) workbenchwindow.getactivepage()).gethiddenitems().contains((modeledpagelayout.hidden_toolbar_prefix + id + ",")); }

android - MySQL TIMESTAMP behaving weirdly -

in chat application, use system.currenttimemillis()/1000 on android app send time message created @ mysql server, without milliseconds part. strange part is, table has 2 records same value of milliseconds. stranger when convert milliseconds readable time, values totally different! here output of 2 different queries: select max(unix_timestamp(created_at)), created_at, message messages mtype = 0 , groups_id = 1; max(unix_timestamp(created_at)) | created_at | message | +--------------------------------+---------------------+---------+ | 1464096148 | 2016-04-25 13:57:18 | select unix_timestamp(created_at), created_at, message messages mtype = 0 , groups_id = 1 order created_at desc limit 1; max(unix_timestamp(created_at)) | created_at | message | +--------------------------------+---------------------+---------+ | 1464096148 | 2016-05-24 18:52:28 | test the output of last query remember sending client app.

How to set each item of a asp:CheckBoxList to seperate row of a bootstrap datatable ASP.NET -

Image
i have asp:checkboxlist .aspx page. want each item of asp:checkboxlist seperate row of bootstrap datatable. code below <asp:table id="tblusertorolelist"> <thead> <tr> <th> role list </th> <th></th> </tr> </thead> <tbody> <tr> <td> <asp:checkboxlist id="chkrolelist" runat="server" width="250px"></asp:checkboxlist> </td> <td></td> </tr> </tbody> and output here items in under 1 td of single tr but need items separate tr can search items bootstrap datatable 's default search box please me the <asp:checkboxlist> generates html table.the problem table doesn't have <th> elements defined , bootstrap datatable requires these tags present. solution?manually add <th> tags before

ZK How to handle multiple events? -

i have textbox , method listens 2 events. <textbox id="test" /> @listen("onok = #test; onblur = #test") public void action(event event) { // ... } when press enter on textbox, event "onok " triggered. it's ok. when lose focus texbox event "onblur" triggered too. it's bad, because in case method "action" called 2 times. how can cancel second event ? you forward event event : i created fiddle can test it . but explication : in zul : <textbox id="test" forward="onok=test.onblur"/> what says onok forwarded onblur, , onblur later on. in java code : @listen("onblur = #test") public void action(event event) { clients.shownotification(event.getname() + " " + ++counter); } so listen onblur because onok forwarded onblur. will case atm, not yet. not calling event => not possible, if declare it, triggered. how can handle situation : hol

php code calculate 30 minutes from created datetime field in table -

in table there created datetime field in data inserting 2016-05-25 11:50:35. suppose insertion time 11:50 , current time 12:10,so differnce 20 mins. need check difference in 1 variable , check if differnce > 30 edit link invisible else visible. below code.. i extracted mins created datetime field database. $var1 = $post['shipperrating']['created']; $time1 = date('i', strtotime($var1)); $finaltime = $time1; echo $finaltime; $createddatetime = new datetime($post['shipperrating']['created']); $createddatetime->modify('+30 minutes'); if ($createddatetime >= new datetime()) { echo '<a href="/url">edit</a>'; }

ios - How to get place name from lattitude and longitude? -

i getting latitude , longitude api, , need place name these cooridinates use block of code clgeocoder *ceo = [[clgeocoder alloc]init]; cllocation *locationatual=[[cllocation alloc] initwithlatitude:[[latlong objectforkey:@"latitude"] doublevalue] longitude:[[latlong objectforkey:@"longitude"] doublevalue]]; nslog(@"loc %@", locationatual); [ceo reversegeocodelocation:locationatual completionhandler:^(nsarray *placemarks, nserror *error) { clplacemark *placemark = [placemarks objectatindex:0]; nslog(@"placemark %@",placemark); //string hold address nsstring *locatedat = [[placemark.addressdictionary valueforkey:@"formattedaddresslines"] componentsjoinedbystring:@", "]; nslog(@"addressdictionary %@", placemark.addressdictionary); nslog(@"placemark %@",placemark.region); nslog(@"placemark %@",placemark.country); // give c

python - Connection cuts serveing files with mod_wsgi -

i runing apache 2.2 server on linux. using mod_wsgi serve http python code. when trying serve large file stops @ 95% without rasing exception on server. curl shows error: curl: (18) transfer closed 160800 bytes remaining read the code: if 'wsgi.file_wrapper' in environ: self.body = environ['wsgi.file_wrapper'](self.file, block_size) else: self.body = iter(lambda: self.file.read(block_size), '') when runing same code in windows working. what problem?

XSLT: Replacing div with script on multiple levels -

i trying replace div-tags script-tags within level. code within div set display none need (discard 2 outer divs), , divs within code has class of "is-script" must replaced script, while keeping attributes , nodes. examples of how code can look: <div data-type="embed"> <div style="display:none;"> <div class="is-script" src="http://example.js"></div> </div> </div> <div data-type="embed"> <div style="display:none;"> <div class="is-script" src="http://example1.js"></div> <div class="is-script" src="http://example2.js"></div> </div> </div> <div data-type="embed"> <div style="display:none;"> <div> <div class="is-script" src="http://example.js"></div> &

maven - Build success info is not showing after server startup -

i started ant-target(tomcat-start) maven...server started...war deployed. not showing build success after server-startup....it showing this... [java] touko 25, 2016 9:07:37 ap. org.apache.catalina.core.aprlifecyclelistener init [java] info: apr based apache tomcat native library allows optimal performance in production environments not found on java.library.path: c:\jdk1.7.0_17\jre\bin;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;c:/program files/java/jre1.8.0_92/bin/client;c:/program files/java/jre1.8.0_92/bin;c:/program files/java/jre1.8.0_92/lib/i386;c:\programdata\oracle\java\javapath;c:\programdata\oracle\java\javapath\;c:\windows\system32\;c:\jdk1.7.0_17\bin\;c:\apache-maven-3.3.9\bin\;c:\ant\apache-ant-1.8.2\bin;c:\eclipse-jee-mars-2-win32\eclipse;;. [java] touko 25, 2016 9:07:38 ap. org.apache.coyote.abstractprotocol init [java] info: initializing protocolhandler ["http-bio-8060"] [java] touko 25, 2016 9:07:38 ap. org.apache.coyote.

c# - How to turn required field validator off when selecting cancel button -

i have problem page has required field validator, want use 'cancel' button take user menu page using response.redirect("default.aspx"); problem field validator keeps firing when click cancel button. how turn off user can return menu page? just add causesvalidation="false" button definition , won't raise validators: <asp:button id="btncancel" runat="server" text="cancel" causesvalidation="false" />

javascript - array is not working in a function which is inside for loop of jquery -

i stuck @ point,its worpress mediauploader. want upload images, 1 function 1 image have several upload buttons unique id want 1 function thats why created loop, on click of each button media uploader open there problem saving selected image, not getting image url in value. pls new jquery , javascript. tried various methods 1 of them screenshot of thing want-> here jquery(document).ready(function($){ var b = ["#upload-button-1", "#upload-button-2", "#upload-button-3","#upload-button-4","#upload-button-5","#upload-button-6","#upload-button-7","#upload-button-8"]; var d =[".procircle-1", ".procircle-2",".procircle-3",".procircle-4",".procircle-5",".procircle-6",".procircle-7",".procircle-8"]; var j; var c = ["#grid-image-1", "#grid-image-2", "#grid-image-3","#grid-image-4","#g

zodb - "Non-zero version length. Versions aren't supported" after zeoserver restart -

i try restart zeoserver , "non-zero version length. versions aren't supported". $> bin/zeoserver fg /opt/plone-4.2/zeocluster/parts/zeoserver/bin/runzeo traceback (most recent call last): file "/opt/plone-4.2/buildout-cache/eggs/zodb3-3.10.5-py2.7-linux-x86_64.egg/zeo/runzeo.py", line 405, in <module> main() file "/opt/plone-4.2/buildout-cache/eggs/zodb3-3.10.5-py2.7-linux-x86_64.egg/zeo/runzeo.py", line 402, in main s.main() file "/opt/plone-4.2/buildout-cache/eggs/zodb3-3.10.5-py2.7-linux-x86_64.egg/zeo/runzeo.py", line 158, in main self.open_storages() file "/opt/plone-4.2/buildout-cache/eggs/zodb3-3.10.5-py2.7-linux-x86_64.egg/zeo/runzeo.py", line 207, in open_storages self.storages[opener.name] = opener.open() file "/opt/plone-4.2/buildout-cache/eggs/zodb3-3.10.5-py2.7-linux-x86_64.egg/zodb/config.py", line 177, in open return filestorage(config.path, **options) file &

ios - CLLocationManager weird behavior -

i have weird problem. i have 2 classes: businessvc favoritesvc in both of them show user current distance him specific point. in both of classes use exact same code that. favoritesvc presented modal view controller. for reason didupdatelocations / didupdatetolocation methods getting called in businessvc , not in favoritesvc. i'm implementing cllocationmanagerdelegate delegate in both classes. the code i'm using: -(void)viewdidload { [super viewdidload]; [self locatedme]; } -(void) locatedme{ nslog(@"locateme"); _locationmanager = [[cllocationmanager alloc] init]; [_locationmanager setdelegate:self]; [_locationmanager setdistancefilter:kcldistancefilternone]; // whenever move [_locationmanager setdesiredaccuracy:kcllocationaccuracyhundredmeters]; // 100 m [_locationmanager startupdatinglocation]; } // ios6 -(void)locationmanager:(cllocationmanager *)manager didupdatelocations:(nsarray *)locations {

objective c - ARC and "copy" method -

i'm using sbjson parse json strings. like this: nsdictionary *dict = received_notification.object; should use nsstring *name = [[dict valueforkey:@"name"] copy]; or nsstring *name = [dict valueforkey:@"name"]; i think first method copies nsstring , after dict can released. but second expression "name" keeps reference dict , can't released. am wrong? you right in first case, , copying can useful because nsstring has mutable subclass ( nsmutablestring ), copy ensures have real nsstring in *name , not it's mutable subclass. (more: talking nsstring , copy used on properties, depending on how structured code can useful on local variable) but in second case wrong. first thing: using arc (not mentioned in post see tag), local variables __strong default when do: nsstring *name = [dict objectforkey:@"name"]; // use objectforkey since valueforkey kvc, suggested martin r you not taking reference di

android.view.InflateException: Binary XML file line - how to avoid -

i have problem inflating, dont know how resolve because strange issue. got crash in basefragment class in line 60. samsung , huawei devices(huawei gra_l09). code looks that: public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { int contentview = onfragmentcontentview(); if(contentview == 0) throw new illegalargumentexception("onfragmentcontentview must not equal 0"); view layout = inflater.inflate(contentview, container, false); //!!line 60 butterknife.inject(this, layout); oncreatefragmentview(layout, container, savedinstancestate); return layout; } i not sure reason maybe theme ? use theme.appcompat.light. fatal exception: android.view.inflateexception: binary xml file line 2: error inflating class @ android.view.layoutinflater.createview(layoutinflater.java:633) @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phon

c++ - How to get the original file extension after INFLATE? -

i'm using zlib , c++ compress/decompress files. i can deflate file , put .z extension. when inflating .z file have manually put needed extension. inflating works should , can inflate .z file stdout or file. i 've read zlib manual couldn't manage, how solve problem. suppose need dig archive's header information? any appreciated, thanks! the zlib library compress , decompress both zlib , gzip streams. zlib streams have compact header , trailer no provision store file name information. gzip header , trailer on other hand can store file name, can used when decompressing. should read zlib documentation see how use gzip format, , how process gzip header.

php - Error: java.lang.string cannot be converted to jsonobject -

an error said java.lang.string cannot converted jsonobject, how can convert jsonobject here php code: <?php mysql_connect("localhost","root",""); mysql_select_db("mydatabase"); $query = "select sum(orderprice) total tbl_user"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $new_arr[] = $row['total']; } echo json_encode($new_arr); ?> my android code: try{ jsonarray jarray = new jsonarray(result); for(int i=0;i<jarray.length();i++){ jsonobject json_data = jarray.getjsonobject(i); log.i("log_tag","total: "+json_data.getstring("total")); total.settext("total"); } }catch(jsonexception e){ log.e("log_tag", "error parsing data "

mysql - Need to store form data from wordpress in database WITH current active username -

i have page users can enter kids height , track grow. possible store form data username entered it, , allow multiple entries? ideally feed data cool js chart , display it. recommendations or tips? can form data store on own, using tutorial: http://www.phpeveryday.com/articles/php-mysql-creating-form-insert-data-p280.html help appreciated! you can request logged in username wordpress, , save in db indeed. can find more info via link: codex.wordpress.org->get_currentuserinfo

c++ - Clear temporary list without clearing where I assign it to -

i have 'slate' current screen, in screen 'pages' hold 'items' 12 in size, because fit on screen, have tried check, once reaches 12 items, make new page, code listed below leaves no items in either page 1 or page 2 int pageitems = 0; std::list<item*> templist; page* temp = new page; (std::list<item*>::iterator iter = items.begin(); iter != items.end(); ++iter) { templist.push_back((*iter)); if (pageitems >= 13) { page_count++; temp->items = templist; pages.push_back(temp); templist.clear(); temp->items.clear(); pageitems = 0; } pageitems++; } page class holds std::list, should handle 12, , new page created next amount, if goes above 12, new class , slate class holds std::list std::list, item 1 easier create class, because didnt have pages, , feed 'items' 'pages' according how many given slate i think problem: temp->items.clear();

node.js - how to remove calls to github while installing node modules like node-sass@3.7.0 install -

hi i'm trying have local instance of node , npm manage using sinopia, still dose not solve problem because while installing modules node-sass@3.7.0 install <location>node_modules\gulp-sass\node_modules\node-sass [info] > node scripts/install.js [info] [error] cannot download "https://github.com/sass/node-sass/releases/download/v3.7.0/win32-x64-46_binding.node": i proxy error, work around substitute call github local service packages. probably need modify install.js file. maybe there better way of doing it. or question should how change "package.json" file "devdependencies": { "del": "~2.2.0", "gulp": "~3.9.1", } to pick local/internal repository.

javascript - bind data with rest call in angularjs -

i have populated data rest call in webapp. want detail of particular data id. working code when refresh page. when click on button crashing webapp. here code: service.js: (function() { angular.module('shoppingpad').service('registerservice', registerservice); function registerservice($q, $http,restservice) { var deferred = $q.defer(); //function category this.getallcategory = function () { console.log('in controller'); //calling json data return restservice.getrequest('api/category',null).then(function (response) { category = response.data; deferred.resolve(category); return deferred.promise; }, function (error) { deferred.reject(error); return deferred.promise; });