Posts

Showing posts from July, 2014

ios - Want to perform some action only when the post is successful via UIActivityViewController in iPhone -

i having app in using uiactivityviewcontroller . this code using. nsstring *posttext = @"my text"; nsarray *activityitems = @[posttext]; uiactivityviewcontroller *activitycontroller = [[uiactivityviewcontroller alloc] initwithactivityitems:activityitems applicationactivities:nil]; activitycontroller.excludedactivitytypes = [nsarray arraywithobjects:uiactivitytypeprint, uiactivitytypecopytopasteboard, uiactivitytypeassigntocontact, uiactivitytypesavetocameraroll, nil]; [self presentviewcontroller:activitycontroller animated:yes completion:nil]; this works fine. when open twitter or e-mail uiactivityviewcontroller , shows text want share , fine. but ,now want perform action in db when post successful or e-mail sent successfully. how can that? [activitycontroller setcompletionhandler:^(nsstring *act, bool done) { nslog(@"act type %@",act); nsstri

INSERT INTO is not working foreign key php -

the check 'if' works values not updating database. wrong? think code right, confirms sucess insert. foreign key emp_id references primary key table called empresa (idempresa). // post other file @$pegar = $_post['postempresa']; $q = " select idempresa empresa idempresa = $pegar " ; if (isset($_post['submit'])) { // connect database $dbc = mysqli_connect(db_host, db_user, db_password, db_name); // grab medida data post $fk_empresa = mysqli_real_escape_string($dbc, trim($_post['chaveestrangeira'])); $prato = mysqli_real_escape_string($dbc, trim($_post['f_prato'])); $medida = mysqli_real_escape_string($dbc, trim($_post['f_medida'])); $preco = mysqli_real_escape_string($dbc, trim($_post['f_preco'])); $pessoas = mysqli_real_escape_string($dbc, trim($_post['f_pessoas'])); $categoria = mysqli_real_escape_string

jquery - Javascript for loop blocking rest of code -

i having little trouble javascript have written. purpose of code following: read list of skus provided .txt file split data @ each line for each object make lookup on provided json api information sku output information html table. currently have working have expected however, seems not blocks other javascript try run after for loop. here example of code <script type="text/javascript"> //set api address var api = "/api/athenaservice.svc/getproductbysku/"; //get array of skus txt file $.get('/views/locale/promopages/landingpages/tradelist/tradelist.txt',function(data){ //split file lines var line = data.split('\n'); for(i=0;i<line.length;i++) { $.getjson(api + line[i] , function(data1) { // request complete, can use data got! $('.tlistbody').append('<tr><td>' + data1.title + '</td><td align="center">' + data1.platform.button + '</td></tr

java - Calculate number of words in an ArrayList while some words are on the same line -

i'm trying calculate how many words arraylist contains. know how if every words on separate line, of words on same line, like: hello there blah cats dogs so i'm thinking should go through every entry , somehow find out how many words current entry contains, like: public int numberofwords(){ for(int = 0; < arraylist.size(); i++) { int words = 0; words = words + (number of words on current line); //words should equal 5 } return words; } am thinking right? you should declare , instantiate int words outside of loop int not reassign during every iteration of loop. can use for..each syntax loop through list, eliminate need get() items out of list. handle multiple words on line split string array , count items in array . public int numberofwords(){ int words = 0; for(string s:arraylist) { words += s.split(" ").length; } return words; } full test public class stacktest {

javascript - Why speed of my game character is different in different computers? -

i developing online game using java script. using setinterval (movimage, 10) method move game character. have seen movement speed of game character not same computer. please suggest me. instead of setinterval should use requestanimationframe ( https://developer.mozilla.org/en-us/docs/dom/window.requestanimationframe ). there no point trying update quicker screen can draw. aiming 60fps, 16ms per frame. http://paulirish.com/2011/requestanimationframe-for-smart-animating/ has more info how this. browser support pretty ( http://caniuse.com/#feat=requestanimationframe ) in short, current browsers apart android stock browser. if must have working in ie9 , lower, https://gist.github.com/paulirish/1579671 decent job of simulating behaviour in browsers. (though honest, suspect last of worries, particularly in regard lack of canvas …)

function - Recursive Chmod not working PHP -

i have below php function should recursively chmod 1 of dir's on server. for reason it's not working - know path dir correct i've tested quick script prints out files within dir. $root_tmp = '/tmp/mixtape2'; chmod_r($root_tmp); function chmod_r($path) { $dp = opendir($path); while($file = readdir($dp)) { if($file != "." , $file != "..") { if(is_dir($file)){ chmod($file, 0777); chmod_r($path."/".$file); }else{ chmod($path."/".$file, 0777); } } closedir($dp); } any ideas? chmod($path.'/'.$file, 0777); you must put full path chmod

google apps script - CSS In HTML Services Template -

i'm getting started gas html services. having bit of problem figuring out put css (i'm sure simple). below simple code example. in trying set background color. correct way set , organize it? //code.gs function doget() { return htmlservice.createtemplatefromfile("index").evaluate(); } //index.html <style> body { background-color:#e5e6e8; } </style> <html> <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery- ui.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"> </script> <body> <a href = "#" id = "index1" class = "anchor">i index1</a> <a href = "#" id = "index2" class = "anchor">i index2a</a> <div id="div&

java - How to return Arrays.asList() in ordered list<String>? -

i don't know duplicate or not. if so, please share link don't find yet. in java program, have string following(string created dynamically). string header="requirements id,requirements number,requirements desc,requirements text,requirements date"; now creating list list<string> csv = new arraylist<string>(); csv=arrays.aslist(header.split("\\s*,\\s*")); //splittng each phrase separated comma but not getting list value in unordered way. mean list value this [requirements number,requirements date,requirements desc,requirements id,requirements text] i know list unordered. want list csv this [requirements id,requirements number,requirements desc,requirements text,requirements date] so question how in ordered way? possible solution? the best way use stringtokenizer 1.) using stringtokenizer , split string delimiter "," 2.) iterate stringtokenizer , fill list 3.) while filling, happen in order pseudo code

asp.net - URL rewriting in, IIS 6, .aspx -

i've developed small website in vs2012 utilizes following rewrite in web.config : <system.webserver> <rewrite> <rules> <rule name="dynamicrewrite" stopprocessing="true"> <match url="(.*)"/> <action type="rewrite" url="default.aspx/{r:1}"/> </rule> </rules> </rewrite> </system.webserver> this works beautifully in iis express on dev machine, server running iis 6, , rewrite fails (i 404 on urls should have worked). i found this post , talks .asax files, i.e. web application. have simple website default.aspx , custom classes. is there way me make work? basically, want able in web.config or aspx-file, have full access iis can configure there well, if that's takes (although don't know how -- iis 6 scary). currently, i'm on .net 4.0 can lower 3.5 if needed (heard there rewriting-issues on exten

export - Exporting Selenium code to a file people without selenium can use -

is there way export selenium code sort of file send others use without selenium? preferably inserting html file or wouldn't have install on computers. thank you! kind of, depending on use currently. if use ide, yes. steps ide records put html file reads. can give html file else, have them import ide , pick there. has dependency user must have ff version supported ide. if use webdriver, no. @ least not without work - due dependencies. instance, have various drivers, user need have copy of tests work. have language tests coded in, instance java - you'd have ensure user has java. you package them nice installer - whereby installer gets dependencies user, slow, unreliable , totally not worth time , effort place it. think of when installing large programs - it's downloading lots of dependencies application too. visual studio/eclipse prime examples, depend on hundreds of things. when install them, not installing core files, things depend on too. replicate same

Passing dynamic values on page redirect -

i have gui various fields in user can enter data. have button. want pass values entered user on gui, , on button click, want pass values page can use them. note: no form/no onsubmit/no form action, page redirect page using button. based on markup: <div id="x">some data</div> <div id="y">some more data</div> jquery script retrieve data want: $("my button/link/whatever").click(function(e) { e.preventdefault(); var data = { x: $("#x").text(), y: $("#y").text() }; var req = $.ajax({ url: "the page send data to", type: "post", data: data }); req.done(function(response) { // here once request complete }); }); or use second form.

collections - Remove item from groovy list -

i trying remove item groovy list. i've tried following: list<user> availableusers = [] availableusers = workers (int = 0; < availableusers.size(); i++) { if (availableusers[i].equals(user)){ availableusers.drop(i) break } } i've tried: availableusers.remove(user) in both cases list gets emptied. have idea what's going on? fildor right, if want ot remove first occurence of user in list (minus remove occurrences), need like: list = list.indexof( user ).with { idx -> if( idx > -1 ) { new arraylist( list ).with { -> a.remove( idx ) } } else list }

oop - Error with a simple javascript prototype -

can me? i tried code : function network(ip, port){ this.socket = new websocket('ws://' + ip + ':' + port); this.socket.onopen = function(){ console.log('connected'); this.send('test'); } } network.prototype = { sendmessage : function(data){ this.socket.send(data); alert(data); } } $(document).ready(function() { window.network = new network('localhost', '8887'); window.network.sendmessage("hello, world!"); }); but when launch " uncaught error: invalidstateerror: dom exception 11 ". googled more 1 hour , didn't find something... on server : 0:0:0:0:0:0:0:1%0 entered room! org.java_websocket.websocketimpl@584fce71: test so, problem in sendmessage function.. can me ? ! :) websocket async function. please wait connected success sendmessage.

c# - Why can I not catch the value of Gridview row? -

here code. problem: when click om row och on select page refreshing , dont text in lable17.text. protected void gridview1_selectedindexchanged(object sender, eventargs e) { gridviewrow row = gridview1.selectedrow; label17.text = row.cells[2].text.tostring() ; } protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { e.row.attributes.add("onmouseover", "this.style.cursor='pointer';this.style.backgroundcolor='yellow'"); } } protected void gridview1_selectedindexchanging(object sender, gridviewselecteventargs e) { gridviewrow row = gridview1.rows[e.newselectedindex]; label17.text = "you selected" + row.cells[2].text; } is gridview in updatepanel ? if not entire page postback when click on button. also, make sure if setting text of label17 in page_load event first time i.e. public void page_load(object sende

android - RelativeLayout check runtime if is removed or not -

in activity changing 1 of viewgroup content runtime: buttons action, other events. at specific case need check if child in layout or not ( in case child relativelayout , hold other views) how can check runtime, programmatically if child_1_relativelayout there or removed view tree, parent parentrelativelayout the getparent() usefully? - not explanation how use it, thanks. in case have stored views can use getparent() check if view direct child other view. after removing view parent field cleared. example: viewgroup parent = ...; view child = ...; assert(child.getparent() == parent); // <-- true parent.removeview(child); assert(child.getparent() == parent); // <-- false

javascript - Http get multiple json files from different API endpoints using node express -

i'm looking efficient way multiple json files different api endpoints using node. basically i'd store each json object in variable, , send them jade template files parsing. i've got setup working getting one single json file (jsonfile1) doing following: httpoptions = { host: 'api.test123.com', path : '/content/food/?api_key=1231241412', headers: { "accept": "application/json", 'content-type': 'application/json' }, method: "get", port: 80 } var jsonfile1; http.get(httpoptions, function(res) { var body = ''; res.on('data', function(chunk) { body += chunk; }); res.on('end', function() { jsonfile1= json.parse(body) console.log("got response: " + jsonfile1); }); }).on('error', function(e) { console.log("got error: " + e.message); }); app.set('views', __dirnam

ruby on rails - Is this an efficient way of producing sales reporting / analytics? -

i have app receive & ingest daily sales reports multiple sources. structured differently store down postgres db in separate tables. i'm doing iterate on last 30 days sales 1 report source , seems work quite nicely. concern how efficient & scaleable when add additional report sources way have structured means i'd have add , repeat large amounts of code each new source. <% = date.today - 30 %> #30 days ago <% = date.today %> #today <% step_date = %> <% source_one_chart_data = [] %> #initialise empty array later pass js chart library <% begin %> <% count = @product.sales_source_one.total.where(:report_date => step_date).count %> #check if there sales product on current step date <% if count != 0 %> <% sale = @product.sum_total_net_by_day(step_date) %> <% source_one_chart_data.push(sale.to_s) %> #push sales total array if sales exist on date <% else %>

javascript - jQuery cycle plugin appears to show second image first -

i use cycle.js plugin slideshow, pretty lightweight , great plugin. however, image use first doesnt show first, shows second image first, problem there navigation beneath slideshow. jq: $('#slideshow').after('<div id="ssnav">').cycle({ delay: -12000, next: '#next2', prev: '#prev2', timeout: 8000, pager: '#ssnav', }); html structure: <div> <img src="#_" /> <p>text</p> </div> <div> <img src="#_" /> <p>text</p> </div> <div> <img src="#_" /> <p>text</p> </div> you picture, shows second div first - how can counteract this? the problem in option "delay" used: delay: additional delay (in ms) first transition (hint: can negative) when remo

jquery - how to check parent's parent's id equals -

<ul id="productmenu"> <li> <a ref="#"></a> </li> </ul> how check if link's parent's parent has got id = "productmenu"? tried prentnode, did not work. if($(this).closest("ul").attr("id") == "productmenu"){ }

Haml code conversion from Ruby -

i have code mentioned below , trying make work on ror application under haml extension. getting unexpected keyword end. read on net , stackoverflow , found out end not required in haml. when remove error saying end keyword expected. please check , tip me doing wrong? in advance. <div id="comments"> <% @comments.each |comment| %> <div class ="comment"> <%= simple_format comment.content %> </div> <%end%> </div> what did far is: %h1 comments .comments - @comments.each |comment| .comment = simple_format comment.content any clues? thanks please note haml based on 2 space indentations. correct haml version of html is #comments - @comments.each |comment| .comment = simple_format comment.content

HTA/VBScript Windows Gadget stops on sleep and doesn't resume -

i have windows gadget created performs function within sub, timed (currently 10 seconds), check each 10 seconds wait , loop , perform function again, however, loop stops when pc comes out of sleep, stops dead , won't resume, how stop happening in vbscript/hta? <script language="vbscript"> option explicit dim itimerid, refreshlist sub window_onload refreshlist itimerid = window.setinterval("refreshlist", 10000, "vbscript") end sub </script> sub refreshlist {do something} end sub

java - How to redirect to login page after page refresh -

i using jquery mobile application , java @ server side. user has redirected login page, i.e. index.html, if user presses refresh button. can done using javascript or need add java code achieve it? with javascript can handle onbeforeunload event. don't know if user refreshes or navigates away. need localstorage or cookies keep state , check if user refreshes can redirect them. don't know if possible in onbeforeunload event, recommend fix server side. need have logic server side.for example keep last page in session , if equals new page redirect index.html.

asp.net mvc 4 - pass url from view to controller on PaypalReturnView -

i have got mobile web app sorted, need return url return page after finishing paypal transaction, need url has token , payerid can finish off payment. i have seen can request.url.absoluteuri, there anyway can decode in normal string format, can extract token , payerid, how information on view loading, opposed doing on button press.. thanks

javascript - how to change injection target to create treemap in jit infovis toolkit? -

i need create 2 squarified treemaps in 1 web page. used jit infovis toolkit create treemap. possible create treemaps not using div id "infovis"?cause when change id of div else "test" example, cause error treemap doesn't work. change "inject into" property in jit javascript function used create treemap . please help yes, possible that. in standard examples of infovis, div "infovis" contained in "center-container". html page includes css file base.css. file applies rules both "infovis" , "center-container". #infovis { position:relative; width:600px; height:600px; margin:auto; overflow:hidden; } and center-container.. #center-container { width:600px; left:200px; background-color:#1a1a1a; color:#ccc; } you can check in html file renders visualization. should make sure div in want inject visualization, applied same/similar rules. may have more changes in html file , css fi

netzke - Autosave issue in rails 3.2 -

in given code, class supplier < activerecord::base has_one :criteria, foreign_key: "crt_sup_id", :autosave => true self.primary_key = 'sup_id' end class criteria < activerecord::base belongs_to :supplier, foreign_key: "crt_sup_id" self.primary_key = 'crt_id' self.table_name = 'criterias' end autosave not working when submitting form. supplier records created not criteria. form code class supplierform < netzke::basepack::form def configure(c) c.model = 'supplier' super c.items = [ {field_label: "name", name: :bname}, {field_label: "detail", name: :detail}, { layout: :hbox, border: false, defaults: {border: false}, items: [ { flex: 1, layout: :anchor, defaults: {anchor: "-8"}, items: [ {field_la

arraylist - Merge sort with array lists in java -

so homework have write program mergesorts array lists code works regular arrays, wondering if me figure out went wrong, because code throws ton of null pointer exceptions, , have tried fix them, when fix 1 goes another...and on.... thanks! code: private static arraylist<integer> numbers= new arraylist<integer>(); private static arraylist<integer> helper; private static int number; public static void sort(arraylist<integer> mynumbers){ for(int i=0; i<mynumbers.size();i++){ numbers.add(mynumbers.get(i)); } //numbers=mynumbers; number = mynumbers.size()-1; mergesort(0, number -1); } private static void mergesort(int low, int high){ //check if low smaller high, if not array sorted if(low<high){ //get index of element in middle int middle=low+(high-low)/2; //sort left side of array mergesort(low, middle); //sort right side of array mergesort(middle +1, high); //

scala - AbsoluteURI support in Play Framework 2.1 -

as stated here: http://www.w3.org/protocols/rfc2616/rfc2616-sec5.html to allow transition absoluteuris in requests in future versions of http, http/1.1 servers must accept absoluteuri form in requests, though http/1.1 clients generate them in requests proxies. i have client sends post-requests play-2.1.1 server. sends way: post http://172.16.1.227:9000/a8%3af9%3a4b%3a20%3a89%3a40/1089820966/ http/1.1 content-length: 473 content-type: application/json date: thu, 25 apr 2013 15:44:43 gmt host: 172.16.1.227:9000 user-agent: my-client ...some data... all requests rejected "action not found" error. same request send using curl fine , difference between them curl send relative uri: post /a8%3af9%3a4b%3a20%3a89%3a40/1089820966/ http/1.1 accept: */* content-length: 593 content-type: application/json host: 172.16.1.227:9000 user-agent: curl/7.30.0 i created following simple workaround in global.scala: override def onrouterequest(request: requestheader): option[h

Converting google maps api v2 to v3 getting script error in main.js -

i converting code version 2 version 3. getting script error in http://maps.gstatic.com/intl/en_us/mapfiles/api-3/12/9/main.js code on page as <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&key=<%=strgk%>"></script> <script type="text/javascript"> function initialize() { var myoptions = { zoom: 7, maptypeid: google.maps.maptypeid.roadmap, center: "<%=strorig%>", maptypecontrol: true, maptypecontroloptions: { style: google.maps.maptypecontrolstyle.horizontal_bar, position: google.maps.controlposition.bottom }, navigationcontrol: true, navigationcontroloptions: { style: google.maps.navigationcontrolstyle.zoom_pan, position: google.maps.controlposition.top_right }, scalecontrol

sql - Is dateadd() slow in on-conditions compared to where-clauses? -

i have situation in select , gets faster if move dateadd() on -condition where -clause. but may not possible move on -condition , where -clause. solution move dateadd() on -condition temporary table instead, , sped entire stored procedure. but left wondering; can true dateadd() slower in on -condition elsewhere? i'll answer references sql server unless can find exact sybase references query optimisers work similarly to start, dateadd function on predicate invalidates index usage (see number 2 here ). the on clause form of predicate of course (think of old implicit-join-in-where syntax) same applies. now, queries honour logical processing step (if not actual, that's why "query optimisers" called so). on before 1 of them. with dateadd in clause, residual filter because main work has been done in on clause restrict rows. if dateadd in on clause, gets processed "sooner" clause. this per sybase join docs state ...the optimize

c++ custom string format using stringstreams -

i trying use new stringstreams method convert float+int combination format trying see if there better way handle this: now using //string string = static_cast( &(ostringstream() << number) )->str(); kind of mode - how can stored string form of format - "1.10(3)". precision equal decimals. catch here none of these values constants. if solution can't in-line function or stringstreams - it's fine long it's generic enough. note in end plan use string gdi text string. thanks in advance - if 1 can help. here current sample code(and looking alternate efficient way done): string convert(float number,int decimals) { std::ostringstream buff; buff<<setprecision(decimals)<<fixed<<number; return buff.str(); } float f=1.1; // can have values 1,1.5 or 1.52 int decimals=2; //dynamic number - calculated other means - not fixed number int i=3; // dynamic number - calculated other means string s=convert(f,decimals)+"(

Facebook FQL query hometown_location {city} -

i create fql query hometown_location.city fql , not hometown_location (array). there way it? my current query following : select uid, hometown_location user uid = me(); keep in mind blank space replaced '+' query works. my current result returns me array contain city,state,country,zip,id , name. the result has little info want result isn't there way city? use dot operator: "hometown_location.city" should work so query be: select uid, hometown_location.city user uid = me();

c# - Excel Interop, iterating workbook for worksheet and chart -

i have scenario while working microsoft excel interop. system.collections.ienumerator wsenumerator = excelapp.activeworkbook.worksheets.getenumerator(); while (wsenumerator.movenext()) { wscurrent = (excel.worksheet)wsenumerator.current; //worksheet operation follows } i operating on worksheets, can not have chart in this. want achieve operate on sheets , check if worksheet or chart, , act accordingly. as sheets contain both worksheet, chart , "excel 4.0 macro", type of sheets each entry can hold of type mentioned. system.collections.ienumerator wsenumerator = workbookin.sheets.getenumerator(); while (wsenumerator.movenext()) { //identify if chart or worksheet } solved checking type of current enumerator var item = wsenumerator.current; if (item excel.chart) { //do chart operations } else if (item excel.worksheet) { //do sheetoperations }

sql server - How can I make a stored procedure commit immediately? -

edit questions no longer valid issue else. please see explanation below in answer. i'm not sure of etiquette i'l leave question in its' current state i have stored procedure writes data table. i'm using microsoft practices enterprise library making stored procedure call. invoke stored procedure using call executenonquery. after executenonquery returns invoke 3rd party library. calls me on separate thread in 100 ms. i invoke stored procedure pull data had written. in 99% of cases data returned. once in while returns no rows( ie can't find data). if put conditional break point detect condition in debugger , manually rerun stored procedure returns data. this makes me believe writing stored procedure working not committing when called. i'm novice when comes sql, entirely possible i'm doing wrong. have thought writing stored procedure block until contents committed db. writing stored procedure alter procedure [dbo].[spwrite] @gu

c# - how to copy image from filepiker to app folder windows store apps -

this code of file picker need copy image user open app folder. 1 can me please private async void button_click(object sender, routedeventargs e) { if (windows.ui.viewmanagement.applicationview.value != windows.ui.viewmanagement.applicationviewstate.snapped || windows.ui.viewmanagement.applicationview.tryunsnap() == true) { windows.storage.pickers.fileopenpicker openpicker = new windows.storage.pickers.fileopenpicker(); openpicker.suggestedstartlocation = windows.storage.pickers.pickerlocationid.pictureslibrary; openpicker.viewmode = windows.storage.pickers.pickerviewmode.thumbnail; // filter include sample subset of file types. openpicker.filetypefilter.clear(); openpicker.filetypefilter.add(".bmp"); openpicker.filetypefilter.add(".png"); openpicker.filetypefilter.add(".jpeg"); openpicker.filetypefilter.add(&

java - Using iText to convert/burn "Stamp" annotations into images -

i have pdf file contains various types of annotations, 1 of them of type "stamp". i'm using itext , , need convert stamp image on same position same size, remove stamp. how can achieve this? there way read pdfname.stamp image? thanks,

How to make bash execute a script every time it exits? -

i want execute commands every time exit bash, cannot find way it. there ~/.bash_logout file when logging out, use interactive shell instead of login shell, not useful purpose. is there way this? thanks! you can trap exit signal. exit_handler () { # code run on exit } trap 'exit_handler' exit techinically, trap exit_handler exit work well. quoted emphasize first argument trap string passed eval , , not single function name. write trap 'do_this; do_that; if [[ $picky == yes ]]; one_more_thing; fi' exit rather gather code single function.

Node.js forever module crashes on list -

i'm running node v0.10.5 on ubuntu 12.04, , i'm able processes started using forever module, try list processes out, forever crashes error/stack trace: /usr/local/lib/node_modules/forever/node_modules/nssocket/node_modules/lazy/lazy.js:211 (var = 0; < chunk.length; i++) { ^ typeerror: cannot read property 'length' of null @ function.<anonymous> (/usr/local/lib/node_modules/forever/node_modules/nssocket/node_modules/lazy/lazy.js:211:38) @ lazy.<anonymous> (/usr/local/lib/node_modules/forever/node_modules/nssocket/node_modules/lazy/lazy.js:187:21) @ lazy.eventemitter.emit (events.js:95:17) @ socket.<anonymous> (/usr/local/lib/node_modules/forever/node_modules/nssocket/node_modules/lazy/lazy.js:50:22) @ socket.eventemitter.emit (events.js:92:17) @ emitreadable_ (_stream_readable.js:392:10) @ emitreadable (_stream_readable.js:388:5) @ socket.readable.read (_stream_readabl

h:outputLink jsf, hide the external link -

i want make simple link external page in jsf. have code: <h:outputlink value ="http://www.google.com.co/" > <h:outputtext value="¿no puede acceder su cuenta?" /> </h:outputlink> but result : ¿no puede acceder su cuenta? (www.google.com.co) i dont want target (www.google.com.co) appears in link... first: way it? second: how can hide target of link? thanks! one idea is, instead of linking url, link javascript function encoded parameter, replaces current page decoded url, or opens in new page.

regex - syntax for specifying matched digit string in Emacs replace-regexp? -

in emacs, i'm trying prepend instances of digits text string, every </a>1</h2> become </a>chapter 1</h2> , on. i'm able find matches using regexp: </a>\([0-9]+\) how specify existing matched digit in replacement string, rather entire string? you've correctly used \( , \) enclose digits in capture group can write replacement string \1 (since first capture group) in regex. replacement string be </a>chapter \1

php - Symfony2 structure setup -

im new symfony2, understand bundle, entity etc. but problem structure. i created local virtualservers development , can't start until dont know im doing , how work. so current documentroot is: http://mysite.localhost/ -> /var/www/mysite i installed symfony this /var/www/mysite - app - bin - src - vendor - web may need generate bundle "index page" or need use app.php/ ? i mean page starts http://mysite.localhost/ what need do? need generate bundles? im confused. thank much best regards, krisztian for first, replies! now modified adviced guys. when write browser http://mysite.localhost/ http://mysite.localhost/app.php/ 404 error. doesn't matter directoryindex app.php or app_dev.php pointing app.php. is normal? if is, how can link bundle main page or that? here sites-available/mysite file <virtualhost *:80> servername mysite.localhost serveralias mysite serveradmin info@something.com documentroot /var/www/mysite/web/

Paypal DoCapture batch process loop -

i trying implement batch process docapture api paypal. have code below , processes first record of database...help!! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <?php include("xxxxx.php");<---- database connection $query2="select * x payment_status = 'pending'"; // custom in ( // select custom // x // group custom // having count(custom) > 1 // ) //order custom"; $results=mysql_query($query2); $row2 = mysql_fetch_array($results); $row_count=mysql_num_rows($results); echo $row_count; //$auth=$row2['auth_id']; //while($row2 =mysql_fetch_array($results)){ $arrsize=sizeof($row_count); ($number = 0; $number < $arrsize; $number++) { //for($i=0; $i<$row_count; $i++){ echo $row2['auth_id']; // prints hello //echo $row2['auth_id']; /** docapture nvp example; last modified 08may23. * * capture payment. */ $environment = 'sandbox'; // or 

ms access - "The data has been changed" error when stepping from main form into sub form -

i'm migrating access database sql server using sql server migration assistant (ssma). access application continue used linked tables instead of local ones. i've run problem during post-migration testing form contains several sub forms. testing steps: 1) edit field in main form; 2) shift focus field in sub form; 3) attempt edit field in sub form. result: error message pops up: "the data has been changed. user edited record , saved changes before attempted save changes." once error message dismissed field in sub form can edited. if field in main form not edited sub form can edited without error message. any ideas causing error? i've tried saving main form record in enter event handler sub form control on main form (ie event happens on main form, when entering control contains sub form, not on sub form itself). doesn't make difference. tried requerying main form in same sub form control enter event doesn't work - requerying main fo

php - Laravel : UPDATE if exist else INSERT? -

my question written in title! exist method in laravel (eloquent, fluent...) wich update row , if row doesn't exist inserted ? guys dunno id laravel has such method, mysql can query this insert t set c1='foo', c2='bar' on duplicate key update c2='bar' you have have unique index on table make trick work

Works in SQLFiddle Not in SQL Server 2012 -

when run query in sql fiddle runs perfectly: ;with cte (select analysisvalue.analysisid, heatname, analysistime, sampletype, grade, productid, element, value dbo.analysisvalue inner join dbo.canalysis on dbo.analysisvalue.analysisid = dbo.canalysis.analysisid heatname = 'a7m0066' ) select * s_analysis s cross join (select top 1 analysistime cte order analysisid desc ) c s.heat_no = 'a7m0066' or (s.analysis_datetime between c.analysistime , dateadd(hh, 2, c.analysistime )) however when run in sql server 2012, receive error leading semi-colon: msg 170, level 15, state 1, line 1 line 1: incorrect syntax near ';'. and error when without semicolon: msg 156, level 15, state 1, line 1 incorrect syntax near keyword 'with'. instead of cte, use #temp table , see if query valid: select analysisvalue.analysisid, heatname, analysistime, sampletype, grade, productid, element, value #te

javascript - innerHTML is working on body element but not p element -

i want display message on screen says "please enter valid email address" if email address not valid. innerhtml statement body element working fine 1 i'm using p element doesn't work. one time when testing it, saw message "please enter valid email address" display , after clicked ok button "not valid" alert box message went away. javascript: <script type="text/javascript"> function validateemail() { var emailrule = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/; if (emailrule.test(document.forms[0].email.value)) { document.getelementbyid("body").innerhtml = "thank signing our newsletter! recieve confirmation email shortly."; settimeout("window.close()", 3000); } else window.alert("not valid");

hadoop - Hive always gives "Number of reduce tasks determined at compile time: 1", no matter what I do -

create external table if not exists my_table (customer_id string,ip_id string) location 'ip_b_class'; and then: hive> set mapred.reduce.tasks=50; hive> select count(distinct customer_id) my_table; total mapreduce jobs = 1 launching job 1 out of 1 number of reduce tasks determined @ compile time: 1 there's 160gb in there, , 1 reducer takes long time... [ihadanny@lvshdc2en0011 ~]$ hdu found 8 items 162808042208 hdfs://horton/ip_b_class ... logically cannot have more 1 reducer here. unless distinct customer ids individual map tasks come 1 place distinctness can not established , single count can not produced. in other words unless heap customer ids in 1 place, cannot each 1 distinct , count them.

c# - Unable to cast object of type 'System.DateTime' to type 'System.String' -

getting error has me stumped. i'm assuming it's simple can't seem figure 1 out, code causing error: if ((string) _nullabledatetimepicker1.value != string.empty && _nullabledatetimepicker1.value != null) { _nullabledatetimepicker1.value = null; } when clicking on search button in windows form, popping up: unable cast object of type 'system.datetime' type 'system.string'. it appears type of nullable-type instance of _nullabledatetimepicker1 datetime , not string; need compare datetime or convert string. so, in simplest sense: _nullabledatetimepicker1.value.tostring() != string.empty however, beware danger of not checking hasvalue , cause nullreferenceexception if value null ; so, check little backwards. and then, if wasn't null , you'd have datetime.minvalue , , tostring wouldn't return empty string. therefore, check null on nullable thing, , if not null , compare datetime.minvalue (unless there&#

mysql - Why are variables being cut out? -

high school students trying create version of facebook our school. right stuck on joining tables in trial database before can release it. to join tables post, users, , friends: users user name 1 hallie 2 dylan 3 sarina 4 dominic friends user friend 1 2 1 3 1 4 2 1 3 1 4 1 2 4 4 2 3 2 2 3 posts | user | postid | post | +------+--------+------+ | 1 | 101 | tigerbook! | | 2 | 102 | pregnant. | | 1 | 103 | peeps | | 4 | 104 | giant buzz lightyears rock. | | 3 | 105 | die tucker die | | 1 | 106 | murhur de derpity derp | | 2 | 107 | banana spaghetti squid | | 4 | 108 | chicken | we used code: select users.user, users.name, posts.postid, posts.post, tmp.friend (select friend, user friends

java - Stop date dropping zero's -

how stop ints dropping zeros in time? i've tried formatting string.format("%02d", minutes); but doesn't work, i'm sure it's quite simple! date dt = new date(); int hours = dt.gethours(); int minutes = dt.getminutes(); string curtime = hours + ":" + minutes; string.format("%02d", minutes); updatedat.settext("updated @ " + curtime); use simpledateformat object instead format dates/times. date date = new date(); // initializes current time dateformat df = new simpledateformat("h:mm"); updatedat.settext("updated @ " + df.format(date)); read more simpledateformat , formatting specifications here .

javascript - Unable to figure out whether to use "," or "+" in console.log in node.js -

this config.json file: { "username": "myname", "api-key": "test", "name": "testname", "version": 1 } this node.js file var fs=require("fs"); console.log("start"); var contents=fs.readfilesync("config.json"); console.log("contents: " +contents); var config=json.parse(contents); console.log("username: ", config.username); now whether use console.log("username: ", config.username); or use console.log("username:" +config.username); i same result in output. gives different results while logging other variables. unable when "," used , when "+" used. pointers? if use + concatenation operator , , pass single string (or number) log() . if use , , passing multiple arguments. if pass multiple arguments, , aren't using formatting string, each logged via inspect . see documentation console.log , util

.net - C# Regex : let's parse Objective-C -

i'm trying parse x-code project translate it. i've got 3 or 4 big applications translate start c# project this. i'm having big troubles regex. does know how extract string this: string parse : title = [[object alloc] initwithtitle:@"my title" andparam:@"a complex \"param\"" andaformat:@"hello %@",toto]; result should array of : objc "my title", "a complex \"param\"", "hello %@" i'm pretty lost this... thank you. if you're trying translate set of strings within project, i'd recommend converting string instances such @"my title" localizable macro: nslocalizedstring(@"my title", @"comment appear above title, such objc \"my title\""); these can extracted using genstrings command line utility, generate strings file entries like: /* comment appear above title, such objc "my title" */ @"my title&qu

css - Twitter Bootstrap layout to "wrap" evenly on viewport resize -

i'm attempting create responsive layout using twitter bootstrap. there "grid" of images (100x100) i'd display in rows of 1,2 or 4 wide. i'm using ".row" within ".container-fluid" , span3 contain each item inside rows. <div class="container-fluid"> <div class="row"> <div class="span3 product"><img src="//placehold.it/100x100"></div> <div class="span3 product"><img src="//placehold.it/100x100"></div> <div class="span3 product"><img src="//placehold.it/100x100"></div> <div class="span3 product"><img src="//placehold.it/100x100"></div> </div> <div class="row"> <div class="span3 product clearfix"><img src="//placehold.it/100x100"><

cocoa touch - Step into a custom framework when debugging -

i have created custom ios framework added project built-in framework. is possible step-into framework code while debugging? know can if add dependent project. if want debug should add project. following discussion might you. http://www.cocoabuilder.com/archive/xcode/270461-source-debugging-of-3rd-party-framework.html

c++ - How can I prefetch infrequently used code? -

i want prefetch code instruction cache. code path used infrequently need in instruction cache or @ least in l2 rare cases used. have advance notice of these rare cases. _mm_prefetch work code? there way infrequently used code in cache? problem don't care portability asm do. the answer depends on cpu architecture. that said, if using gcc or clang, can use __builtin_prefetch instruction try generate prefetch instruction. on pentium 3 , later x86-type architectures, generate prefetchh instruction, requests load data cache hierarchy. since these architectures have unified l2 , higher caches, may help. the function looks this: __builtin_prefetch(const void *address, int locality); the locality argument should in range 0...3. assuming locality maps directly h part of prefetchh instruction, want pass 1 or 2, ask data loaded l2 , higher caches. see intel® 64 , ia-32 architectures software developer's manual volume 2b: instruction set reference, m-z (pdf)

android - Need to stop the date picker copying into the 2 textviews -

i have 2 imagebuttons , 2 textviews. following code writes same date 2 textviews dont want, when click 1 image button meant write edittext1 , when second clicked should write edittext2 here code public void selectdate(view view) { dialogfragment newfragment = new selectdatefragment(); newfragment.show(getsupportfragmentmanager(), "datepicker"); } public void populatesetdate(int year, int month, int day) { departdate = (textview)findviewbyid(r.id.edittext1); departdate.settext(month+"/"+day+"/"+year); } public void populatesetdate1(int year1, int month1, int day1) { returndate = (textview)findviewbyid(r.id.edittext2); returndate.settext(month1+"/"+day1+"/"+year1); } public class selectdatefragment extends dialogfragment implements datepickerdialog.ondatesetlistener { @override public dialog oncreatedialog(bundle savedinstancestate)

timezone - PHP Date to strtotime and back to date? -

what want convert time string strtotime , date timezone had before. i using following code, time result in utc: $timestart = "2013-04-25 18:14:00+03"; $datetimestart = strtotime($timestart); $datetimenext = strtotime('+8 hours',$datetimestart); $time = gmdate('y-m-d\\th:i:s\\z', $datetimenext); any ideas? thank you.. i think mean want same offset had. read "timezone != offset" in the timezone tag wiki . the main problem request strtotime (according the docs ) returns integer representing number of seconds epoch in utc . offset provide going factored in forgotten about. sorry don't know php enough provide code sample, can extract offset original string , re-apply @ end. possible there different way parse string yield object maintains offset. again, don't know php enough here. in .net same problem solved parsing datetimeoffset instead of datetime . also - logistically offset start not correct offset use after ad

c# - Add item to itemssource if no match from binding -

so, here's scenario: have combobox itemssource dictionary<int, string> of various titles , ids. these titles can disabled @ point in future, , therefore shouldn't show in combobox anymore. however, when viewing old item, still need able show old value in addition current active titles. i'll try visualize little better below. today: the combobox items consist of 1, title1 2, title2 3, title3 title3 selected , id (3) stored. tomorrow: title3 disabled , title4 added, items consist of 1, title1 2, title2 4, title4 however, if our value yesterday value we're binding (id 3), there no matching item. ideally, i'd append our old item end so: 1, title1, 2, title2 4, title4 3, title3 there separate lists enabled , disabled titles, , item doesn't bind reference disabled titles variable. i have investigated fallbackvalues , prioritybindings can't seem find way make them fit i'm trying do. perhaps sort of convert