Posts

Showing posts from January, 2015

WebSocket (Atmosphere) with Per Request problems (Hibernate and Shiro) - Vaadin -

the framework vaadin in version 7 uses atmosphere enable both push logic, , apparently "all over" communications in system when available, i.e. on ordinarly requests browser. this when atmosphere doesn't use websockets (e.g. when jetty not configured websocket support), , therefore must rely on long polling or similar http "fake" push methods seems long servlet call. however, when actual websocket used, both shiro , hibernate complains loudly. the problem servlet filters doesn't "kick in" websockets. hibernate creates per-request connections spring's opensessioninviewfilter, acts transaction boundaries committing/closing on exit. shiro creates websubject objects extension of abstractshirofilter - sticks servletrequest , servletresponse objects subject - , clears "threadcontext" (which threadlocal) upon exit. does have ideas here? hoping atmosphere have similar "try-finally"-like "filterchain.continue&quo

Google Maps - converting address to latitude & longitude - PHP backend? -

is possible convert (in php back-end): <?php $address = "street 1, city, country"; // normal address ?> to <?php $latlng = "10.0,20.0"; // latitude & lonitude ?> the code i'm using default one: <script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?v=3.exp&#038;sensor=false'></script> <script> function initialize() { var mylatlng = new google.maps.latlng(10.0,20.0); var mapoptions = { zoom: 16, center: mylatlng, maptypeid: google.maps.maptypeid.roadmap } var map = new google.maps.map(document.getelementbyid('map'), mapoptions); var marker = new google.maps.marker({ position: mylatlng, map: map, title: 'this caption' }); } google.maps.event.adddomlistener(window, 'load', initialize); </script> <div id="map"></div> i've been reading https://developers.google.com/maps/

Android how to add support of unsupported media formats -

how can add suport of these audio formats adnroid application: aa dolby digital (ac3) aac adx asf ahx aiff ape aud and many others. real? or hard implement? same question related video, text files (djvu, pdf etc) , playlists (b4s, fpl). thank you. have @ vitamio . open source library supports many different media formats. of supported formats listed here .

ruby on rails - delayed_job tasks failing in daemon mode in production environment -

i'm trying use delayed_jobs. works perfectly, locally, when using rake jobs:work task. however, when try use daemon, tasks fail. i've stopped deleting failed tasks. i'm starting daemon ' rails_env=production bin/delayed_jobs start '. when status shows worker active. they seem failing error 'job failed load: undefined class/module productaquisition.' this snippet module i'm trying use (lib/product_aquisition.rb). module productaquisition require 'net/http' def productaquisition.get_updates ..... end end this rakefile i'm trying use trigger this require 'debugger' require 'date' require 'thread' # require 'active_support' require "#{rails.root}/lib/product_aquisition.rb" require "#{rails.root}/app/helpers/soap_helper" include soaphelper include productaquisition task :get_updates => :environment productaquisition.delay.get_updates end i don

python - Skip Login Page if Session Exists -

how skip login page if active session exists in flask application. currently have flask application, after successful login, redirecting page index - http://example.com/ --> post login --> http://example.com/index (sucess) however, when active session exists, , when try http://example.com/ , takes me login page again. in login handler, check if user logged in in function. example, if you're using flask-login: def login(): if current_user.is_authenticated(): return redirect(url_for('index')) # process login anon user

c++ - Strange error with a templated operator overload -

when compile following snippet, compiler error clang, not g++/msvc: #include <string> template<typename t> struct const { explicit const(t val) : value(val) {} t value; }; template<typename t> struct var { explicit var(const std::string &n) : name(n) {} std::string name; }; template<typename l, typename r> struct greater { greater(l lhs, r rhs) : left(lhs), right(rhs) {} l left; r right; }; template<typename l> greater<l, const<int> > operator > (l lhs, int rhs) { return greater<l, const<int> >(lhs, const<int>(rhs)); } template<typename r> greater<const<int>, r> operator > (int lhs, r rhs) { return greater<const<int>, r>(const<int>(lhs), rhs); } var<double> d("d"); int main() { d > 10; return 0; } the error reported following: error: overloaded 'operator>' must have @ least 1 parameter

javascript - can't get .on() to work -

i know topic has been asked lot before read lot of stackoverflow posts , can't figure out. either i'm doing silly mistake or using code wrong. in case i'd appreciate other sets of eyes. my code simple. elements being dragged boxes , want user able close dragged boxes can redo dragging. <div id="questioncontainer"> <div class='row-fluid'> <div class='span3 box-content'> <div class="box span12"> <input type="text" placeholder="column 1" /> </div> <div class="box span12 groupboxes"> </div> </div> <div class='span3 box-content'> <div class="box span12"> <input type="text" placeholder="column 2" /> </div> <div class="box span12 groupboxes"> </div> </

postgresql - Is there an index type for BIGINT[]? -

i noticed intarray allows index type large int arrays (gist__intbig_ops), there option bigint[] arrays (gist__bigint_ops)? small number of bigint[] values per record. try gin index. no extension needed. create index index_name on tablename using gin(bigint_array_column);

Copying one column of a CSV file and adding it to another file using python -

i have 2 files, first 1 called book1.csv, , looks this: header1,header2,header3,header4,header5 1,2,3,4,5 1,2,3,4,5 1,2,3,4,5 the second file called book2.csv, , looks this: header1,header2,header3,header4,header5 1,2,3,4 1,2,3,4 1,2,3,4 my goal copy column contains 5's in book1.csv corresponding column in book2.csv. the problem code seems not appending right nor selecting index want copy.it gives error have selected incorrect index position. output follows: header1,header2,header3,header4,header5 1,2,3,4 1,2,3,4 1,2,3,41,2,3,4,5 here code: import csv open('c:/users/sam/desktop/book2.csv','a') csvout: write=csv.writer(csvout, delimiter=',') open('c:/users/sam/desktop/book1.csv','rb') csvfile1: read=csv.reader(csvfile1, delimiter=',') header=next(read) row in read: row[5]=write.writerow(row) what should append properly? thanks help! what this. r

c# - Monitoring a synchronous method for timeout -

i'm looking efficient way throw timeout exception if synchronous method takes long execute. i've seen samples nothing quite want. what need check sync method exceed sla if throw timeout exception i not have terminate sync method if executes long. (multiple failures trip circuit breaker , prevent cascading failure) my solution far show below. note pass cancellationtoken sync method in hope honor cancellation request on timeout. solution returns task can awaited on etc desired calling code. my concern code creates 2 tasks per method being monitoring. think tpl manage well, confirm. does make sense? there better way this? private task timeoutsyncmethod( action<cancellationtoken> syncaction, timespan timeout ) { var cts = new cancellationtokensource(); var outer = task.run( () => { try { //start synchronous method - passing cancellation token var inner = task.run( () => syncaction( cts.token ), cts.token );

mysql - Don't return the lowest value if -

the goal don't return lowest price markets suspended. the problem i don't know syntax. the scenario there following stored procedure lowest , biggest price of specific product: begin select min(case when product.promotionalprice = 0 product.originalprice else least(product.promotionalprice, product.originalprice) end) minproductprice, max(case when product.promotionalprice = 0 product.originalprice else least(product.promotionalprice, product.originalprice) end) maxproductprice products product product.name = 'playstation 3'; end the context is: there markets , products . products belong markets. if market suspended, doesn't display products , nor add them max/min price comparison. can understand? i want exclude products markets suspended min or max statement of above's query. the tables here markets table: +----+------+-------------+ | id

POSIX-Compliant Way to Scope Variables to a Function in a Shell Script -

is there posix compliant way limit scope of variable function declared in? i.e.: testing() { test="testing" } testing echo "test is: $test" should print "test is:". i've read declare, local, , typeset keywords, doesn't required posix built-ins. it done local keyword, is, seem know, not defined posix. here informative discussion adding 'local' posix . however, primitive posix-compliant shell know of used gnu/linux distributions /bin/sh default, dash (debian almquist shell), supports it. freebsd , netbsd use ash , original almquist shell, supports it. openbsd uses ksh implementation /bin/sh supports it. unless you're aiming support non-gnu non-bsd systems solaris, or using standard ksh, etc., away using local . (might want put comment right @ start of script, below shebang line, noting not strictly posix sh script. not evil.) having said that, might want check respective man-pages of these sh implementations

ios - profile(.MobileConfig) install from safari, then return back to app -

i working on project has user install profile (.mobileconfig) on ios device. current flow followed(each step initiated user; sub-steps antonymous): 1) button click in app directs safari - switches settings app profile install 2) user may either install or cancel - switches safari 3) user manually directs app however 1 many steps. flow followed (each step initiated user; sub-steps antonymous): 1) button click in app directs safari - switches settings app profile install 2) user may either install or cancel - switches safari - switches app i aware can place button user click direct app make process antonymous possible. flow found in app onavo, have yet find information regarding how this. the example onavo have quoted native application. the process want not yet possible in web apps, limitations of web app in ios can not not download mobile config in full screen web app. in web not normal viewport (not full screen web app) mobile config download

autofixture - How can I use custom ISpecimenBuilders with OmitOnRecursionBehavior? -

how can use custom ispecimenbuilder instances along omitonrecursionbehavior want applied globally fixture-created objects? i'm working ef code first model foul-smelling circular reference that, purposes of question, cannot eliminated: public class parent { public string name { get; set; } public int age { get; set; } public virtual child child { get; set; } } public class child { public string name { get; set; } public int age { get; set; } public virtual parent parent { get; set; } } i'm familiar technique side-stepping circular references, in passing test: [theory, autodata] public void cancreatepatientgraphwithautofixturemanually(fixture fixture) { //fixture.customizations.add(new parentspecimenbuilder()); //fixture.customizations.add(new childspecimenbuilder()); fixture.behaviors.oftype<throwingrecursionbehavior>().tolist() .foreach(b => fixture.behaviors.remove(b)); fixture.behaviors.add(

php - Can i reuse the prepared statement object -

in many occasions i'm using more 1 prepared statements, so $conn = connect('read'); // connect database $q = 'select ...'; $stmt = $conn->prepare($q); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($a, $b, $c); $stmt->free_result(); $stmt->close(); $q = 'select ...'; $stmt2 = $conn->prepare($q); $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($a, $b, $c, $d, $e, $f...); $stmt2->free_result(); $stmt2->close(); $conn->close(); // close db connection and it's mess trying figure out number give stmt variable... so, can reuse stmt object on , on once close using stmt->close() way don't need keep trace of index give variable stmt ? is practice or bad practice? yes, reuse variable right , quite practice. aside that, don't think it's quite repetitive use code again , again? using function , make things like $row = function('select ...', $par

caching - Override cache-control header on client side using JavaScript? -

is possible client override and/or ignore http cache-control headers of dynamically-loaded content (e.g. images loaded asynchronously) using javascript? my javascript-based gis application requests images dynamically outside server sends following header response: cache-control:max-age=0,must-revalidate this results in browser sending duplicate requests same images (along if-none-match request header) results in http 304 not modified response, cache used anyway after delay. i know images have not changed, don't have control on cache-control header sent server, force use of local browser cache when displaying image without having first revalidate server. is possible change on client side? you should able override local cache javascript doing location.reload(true) not browsers behave properly - use frame repopulate non html content

javascript - How can I run a coffeescript method that depends on the js event while maintaining DRY code? -

i want dry code: @$canvas.on 'mousemove', (e) => return unless @running @mousetarget.set @board.x + e.clientx, @board.y + e.clienty * 2 @player?.mousemove() @$canvas.on 'mousedown', (e) => return unless @running @mousetarget.set @board.x + e.clientx, @board.y + e.clienty * 2 @player?.mousedown() @$canvas.on 'mouseup', (e) => return unless @running @mousetarget.set @board.x + e.clientx, @board.y + e.clienty * 2 @player?.mouseup() i want having effect of: @$canvas.on 'mousemove', 'mousedown', 'mouseup' -> @mouseaction mouseaction: (e) => return unless @running @mousetarget.set @board.x + e.clientx, @board.y + e.clienty * 2 @player?.mouseup() # here problem... the thing is, how alternate between @player?.mouseup(), @player?.mousedown() , @player?.mousemove() while maintaining dry code? to expand on pdoherty926's answer, want somehow same thing, invoke different methods on @pl

c++ - Vector of an object instant VB Net -

i have problem vector in vb net. i have written code in c++ typedef struct { int process; int bursttime; int arrivaltime; int remaining; int timeaddedtoq; bool flag; } process; vector<process> proc; how can represent c++ code in vb net code? i tried searching google nothing helped. apreciate if can help thanks you typically make class process information, use list(of process) replace vector<process> . public class process property process integer property bursttime integer property arrivaltime integer property remaining integer property flag boolean end class ' use in code as: dim proc new list(of process)

c# - Programmatically create Application Pool, error setting "ManagedPipelineMode" -

i creating application pool iis 6 (windows server 2003r2) programmatically using following code, getting error on line trying set managedpipelinemode attempt 1 string metabasepath = @"iis://localhost/w3svc/apppools"; directoryentry apppools = new directoryentry(metabasepath); directoryentry newpool = apppools.children.add(apppoolname, "iisapplicationpool"); newpool.properties["managedruntimeversion"].value = "v4.0"; newpool.invokeset("managedpipelinemode", new object[] { 0 }); //exception thrown on line newpool.properties["enable32bitapponwin64"].value = true; if (!string.isnullorempty(username)) { newpool.properties["apppoolidentitytype"].value = 3; newpool.properties["wamusername"].value = username; newpool.properties["wamuserpass"].value = password; } newpool.commitchange

android - How can I debug in Eclipse Step by Step? -

this question has answer here: android debugging, how? 3 answers i'm new android development, i'm using eclipse juno, doubt is, can debug errors step step? mean use f10 in asp.net development, that? can know values of different variables @ point of program running. put breakpoint want start debugging right clicking on side bar next line , selecting "toggle breakpoint". press "f11" , you're done.

gmail - Google Script copy to clipboard and mailto [Questions] -

Image
i have excel spreadsheets writing schedules , sending them crews. involves vba hides columns , saves pdf. in order me use google-sheets printing pdf, , opening individual emails in gmail seems less efficient. discovered can copy (ctrl+c) range (ex: "a1:e10"), , paste straight gmail (ctrl+v) , looks good. what press button run script that: activates specific range ( did ) copies clipboard ( can not figure 1 out & activates mailto url ( didn't figure out, i'm using =hyperlink(url,name) ). or directly emails sheet formating , range-values or a script either run print dialogue, or save pdf specific google-drive folder. see here (my public version of 'sheet') i new google scripts, familiar vba (and object oriented programming in general exception scripting languages xd) any or sources, or alternative solutions accomplish same thing helpful. since google sheets not application running on computer, script capabilities dif

javascript - My jQuery gallery is too slow and I can't find the reason why -

i making jquery gallery, reason every animation function takes long execute. there simple html page table filled php( imagine has nothing problem since preloaded server) , script tag beneath calls effect. haven't finished because started "jumping" beggining...the fade not smooth @ all... the image inside gallery 40 kb size i'm calling , slow... i making jquery gallery, reason every animation function takes long execute. there simple html page table filled php( imagine has nothing problem since preloaded server) , script tag beneath calls effect. haven't finished because started "jumping" beggining...the fade not smooth @ all... the image inside gallery 40 kb size i'm calling , slow... <script> $("#gallery_base").hide(); $("#gallery").hide(); $(".item_par_pic").click(function () { $("#gallery_base").fadeto(550, 0.8); $("#gallery").fadeto(550, 1); });

javascript - Google maps api not working properly -

Image
so i'm playing around this example , our company has own api key google maps. co-worker , tried maps work - in full screen following code worked - mean let map scale full width of browser, code used is: <script> var map; function initialize() { var mapoptions = { zoom: 8, center: new google.maps.latlng(-34.397, 150.644), maptypeid: google.maps.maptypeid.roadmap }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); } google.maps.event.adddomlistener(window, 'load', initialize); </script> <div id="map-canvas"></div> obviously no api key because that's loaded else where. so decided add on this, because needed map stored else - , added jazz: <style> #map-canvas { margin: 0; padding: 0; width: 100%; height: 100%; } #map{ height: 350px; } </style> the firs

groovy - Getting node from Json Response -

i have following json response: { "0p0000g5zq": [ { "title": "pimco unconstrained bond inst", "resourceid": "587723", "publicationtime": "2013-03-07 14:13:00 -0600", "type": "research", "href": null, "videothumbnail": null, }, { "title": "nontraditional bond 101", "resourceid": "609234", "publicationtime": "2013-08-27 06:00:00 -0500", "authorname": "josh charney", "type": "news" "videothumbnail": null, }, { "title": "investors on move rates rise", "resourceid": "607677", "publicationtime": "2013-08-16 06:00:00 -0500", "authorname": "christine benz", "type": "video", &

php - issue updating html after ajax response received -

after having multiple issues requesting data server posted this question . never got code work ended rewriting whole ajax request , i'm able insert data in database. however, issue i'm having responsetext being sent ajax request not updating html. at end of registration script, after values have been inserted database, have code tests make sure registration email has been sent user , sends string ajax request: if (mail($to, $subject, $message, $headers)) { echo "email_success"; exit; } else { echo "email_failure"; exit; } once response has been received have condition test string has been returned: hr.onreadystatechange = function() { if (hr.readystate == 4 && hr.status == 200) { if (hr.responsetext == "email_success") { window.scrollto(0,0); gebi("signupform").innerhtml = "<p>sign successful. check email activate account.</p>"; } els

php - Multiple User Registration MYSQL -

so have api script , people going have hwid , has add information account when open program, when there multiple user same hwid screws , doesn't add info account, here's code i'm using: $cpukey = mysql_escape_string($_get['cpukey']); $ip = mysql_escape_string($_get['ip']); $pcname = mysql_escape_string($_get['pcname']); $con = mysql_connect($host,$username,$password); mysql_select_db("$db_name", $con); $sql="select * $table cpukey = '$cpukey'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count == 1){ $result = mysql_query("select * $table") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $time = time(); if ($row['ip'] = '-' , $row['pcname'] = '-'){ mysql_query("update $table set pcname = '$pcname' cpukey = '$cpukey' , pcname = &#

java - Where to get a simple android API Client? -

many of need perform web service data servers used in our android apps. have developed simple android api client using restful api. library easy use , simple http request support 4 http methods (get, post, put, , delete). with library can build http request , handle it's response result categories 5 categories: informational response. successful response. client error response. server error response. exception response. in answer there simple example on how use library. thanks. here link library on github https://github.com/jorcad/androidapiclient you can import jar (android-api-client.jar) file project bin folder. with library can specifiy following parameter: set base uri of call. set http method. add paths, parameters, , headers. set content type. set entity/content/body. set connection , socket timeout. set connection , socket timeout retry count. set whether enable retry when connection or socket timeout happens. execute request in 3

Why maven module got the dependencies from the parent automatically? -

i've created parent project , 3 maven module projects. when added dependencies in parent project, dependencies added module projects automatically. not want. want parent pom holds dependencies defined , add actual dependencies module project needed providing groupid , artifactid. how can stop m2eclipse automatically including dependencies parent project. there difference between build.dependencies , build.dependencymanagement.dependencies . dependencies define actual dependencies, whereas dependency management defines dependency versions (to be) used dependencies. either of inherited, that's fine. allows perform dependency management within parent while dependencies (that being managed) defined in child projects. note there trend steer away maven dependency management through inheritance, , use composition instead (" importing dependencies ").

ms access - Combobox selection items different from display items -

i have code table used in combobox. has attribute on each code called "isactive" has value of "y" or "n". code table combobox used classify transaction data on orders table. example: id code isactive -- ---------- -------- 1 repeat y 2 new y 3 discount n i want list of items include items no longer active (isactive="n") text can displayed if looks @ old record used code no longer active. example if order last year classified "discount" want show when @ order. however, want drop-down list new orders not display codes no longer active, since clutter display. if drop down includes codes isactive="y", order last year code of "discount" shows blank. how can best of both worlds here? if don't have particular row visible in combo list, combo won't display text corresponding combo's value - no exceptions. however... if sort isactive = "n&

ruby on rails - CanCan authorize all controllers -

i have cancan , rolify set activeadmin, , it's time force authorization on controllers. do have authorize_resource on every controller (we have couple dozen models , controllers now), or there way apply of activeadmin controllers? i tried calling in before_filter activeadmin.setup, didn't work. i made initializer: config/initializers/active_admin-cancan.rb module activeadmin class resourcecontroller # if don't skip loading on #index exception: # # "collection not paginated scope. set collection.page(params[:page]).per(10) before calling :paginated_collection." load_resource :except => :index authorize_resource def scoped_collection end_of_association_chain.accessible_by(current_ability) end end end borrowed user's code, can't find source more.

java - Strange continue keyword usage -

i'm reviewing java code, , have run kind of thing second time now. while (true) try { //some simple statements continue; try { thread.sleep(1000l); } catch (interruptedexception e) { samsetutils.logerror(this.logger, e.getmessage() + ".29"); } if (!samsetutils.blockingdistributorthread) { //some long , critical code here } } //several catch blocks follow to understanding, critical code omitted, since continue statement executed , start iteration immediately. first marked similar situation bug, time raised suspicions, because it's part of supposedly working code that's being used commercially. snippet work somehow, in way i'm not aware of? similar situation here: while (true) try { //some simple statements if (notifications != null) { int = 0; continue; this.recivednotifies.add(notifications[i].getname()); i++; if (i >= notifications.length) {

sed - R read only specific row of textfile and store them in data.frame -

i have following problem. there textfile want import r. looks this: # below, lines start minus sign , l (-l) # define loci, while start minus sign , (-i) # define epistatic interactions between loci defined. # loci must defined before interactions can defined. # experimental designs, interactions ignored. # -start model # # here data on qtls... # -t 3 number of traits # # -k 1 # trait -number 1 # # # ..chrom..markr. .recombil. .recombir. .additive. .dominance -l 1 2 19 0.0823 0.0028 1.1712 0.0000 # # qtl1 qtl2 type value # # # -k 1 # trait -number 2 # # # ..chrom..markr. .recombil. .recombir. .additive. .dominance -l 1 2 14 0.0309 0.0564 0.4635 0.0000 # # qtl1 qtl2 type value # # # -k 1 # trait -number 3 # # # ..chrom..markr. .recombil. .recombir. .additive. .dominance -l 1

c - Is this structure too large? -

the structure speaking of last one. segmentation faults when try use it, , when use sizeof size 218369176 returned. typedef struct { unsigned long a1; /* last structure in group. */ unsigned long a2; /* next structure in group. */ char rc; /* representing character. */ short st; /* type of structure (purpose). */ short pl; /* privilege level required alter. */ short vt; /* type of value (short, char, int, long, float, double, void*). */ union { short s; char c; int i; long l; float f; double d; void* p; } un; /* union containing values stored. */ } index_struct; /* structure composing table tree. */ typedef struct { unsigned long sr; /* script return value. */ unsigned long ir; /* interpreter return value. */ unsigned long lc; /* execut

Jquery Side Panel (click to close) -

as can see, there slide panel using jquery animated hover function. so, i'd have clcik function open , close panel. if replace "hover" "click" in code below, panel opens don't know how make closing... panel stays open... ` jquery(document).ready(function() { $('#slide').hover(function () { $(this).animate({left:"-25px"},500); },function () { var width = $(this).width() -50; $(this).animate({left: - width },500); }); }); ` (you can see working on www.zonevolley.com) try this var sliderisopen = false; $(document).ready(function() { $('#slide').click(function () { if (sliderisopen == false) { $(this).animate({left:"-25px"},500); sliderisopen = true; } else { var width = $(this).width() -50; $(thi

ruby on rails - Filtering fields from ActiveRecord/ActiveModel JSON output (by magic!) -

i want filter out specific fields activerecord/activemodel classes when outputting json. the straightforward way overriding as_json , perhaps so: def as_json (options = nil) options ||= {} super(options.deep_merge({:except => filter_attributes})) end def filter_attributes [:password_digest, :some_attribute] end this works, it's little verbose , lends not being dry pretty fast. thought nice declare filtered properties magical class method. example: class user < activerecord::base include filterjson has_secure_password filter_json :password_digest #... end module filterjson extend activesupport::concern module classmethods def filter_json (*attributes) (@filter_attributes ||= set.new).merge(attributes.map(&:to_s)) end def filter_attributes @filter_attributes end end def as_json (options = nil) options ||= {} super(options.deep_merge({:except => self.class.filter_attributes.to_a})) end end the

php - Should running preg_replace twice break a WAMP connection? -

i trying replace text in string using preg_replace . now, maybe not doing correctly, running once, doesn't trick trying replace overlapping strings. when run preg_replace once, works fine (minus half of text way want). when try run twice bad connection error in both chrome , ie (so isn't browser issue, not thought be) @ least wamp (i haven't tried on real server). so, there wrong with: 1) php logic, 2) regex, 3) or preg_replace , wamp? i want separate (put spaces between) of numbers have following format: 0.xx $text = "0.450.590.88 aut 0.570.210.400.89 cus 0.630.310.370.440.87 del 0.580.130.310.570.450.89 eva 0.600.230.420.550.440.650.91 int 0.590.390.620.530.540.520.560.85 iop 0.480.240.440.440.440.550.580.600.88 mon 0.690.390.480.560.640.610.610.550.520.85"; ($i=0;$i<2;$i++) $text = preg_replace('#0\.(\d{1,4})0\.#', '0.${1} 0.', $text); i want $text result in: 0.45 0.59 0.88 aut 0.57 0.21 0.40 0.89 cus 0.63 0.31 0.37

node.js - OSX launchd plist for node forever process -

i trying write launchd.plist file node server. using forever run node server. server start on boot. wait mongodb launchd plist run first. i installed mongobb using homebrew , came launchd.plist already. have executed following: $ launchctl load ~/library/launchagents/homebrew.mxcl.mongodb.plist plist mongodb is: <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>label</key> <string>homebrew.mxcl.mongodb</string> <key>programarguments</key> <array> <string>/usr/local/opt/mongodb/mongod</string> <string>run</string> <string>--config</string> <string>/usr/local/etc/mongod.conf</string> </array> <key>runatload</key> <true/> <key>keepalive</key> <false/> <key>workingdire

javascript - jQuery .on delegate not working -

i created simple code seems .on delegation not work? please help? html: <input type="button" value="click me!" id="button0" class=".button" /> <br/><input type="button" value="add" id="add_button" /> <script> var idx = 1; $(document).ready(function(){ $(document.body).on('click',".button",function(){ alert(this.id); }); $('#add_button').on('click',function(){ $('<input type="button" value="click me!" class=".button" />') .attr('id','button' + idx++) .insertbefore($(this).prev()); }); }); </script> the "click me!" button should alert id attribute of button, while add button should add "click me!" button different id attribute value. http://jsfiddle.net/srwrk/ please

iphone - Still can't get CoreBluetooth to work in a simple name discovery app -

i'm trying make simple application scan nearby bluetooth devices , list names discovered. i'm using corebluetooth in accordance every guide i've found, including apple's guide here however, never works. put iphone 4s in discoverable mode next iphone 5 running app, , never discovers it. tried bluetooth-enabled car, don't know if has ble. doing wrong? here essence of code, in viewcontroller.m - (void)viewdidload { [super viewdidload]; [activity stopanimating]; isscanning = no; //activity gui activity wheel centralmanager = [[cbcentralmanager alloc] initwithdelegate: self queue: nil]; } - (void)centralmanagerdidupdatestate:(cbcentralmanager *)central{ int state = central.state; [self log: [nsstring stringwithformat: @"cbcentralmanagerdidupdatestate: %d", state]]; //[self log] nslogs message , adds text view user see. if (state!=cbcentralmanagerstatepoweredon){ [self log: @"error! bluetooth not powered on!"];