Posts

Showing posts from February, 2014

jQuery starts another function and I don't want it -

i have script: http://jsfiddle.net/z8cuz/ jquery code: $('.list').hide(); $('.close').hide(); var widthval = false; $('#left').click(function(){ if(widthval == false){ $('#middle').hide('fade', 300); $('#right').hide('fade', 300, function(){ $('#left').find('.list').show(); $('#left').find('.close').show(); $('#left').animate({ width: "96%", opacity: 1 }, 1000 ); }); widthval == true; } }); $('.close').click(function(){ $(this).parent().animate({ width: "30%", opacity: 1 }, 1500 ); widthval == false; $('#middle').show(); $('#right').show(); $('.list').hide(); $('.close').hide(); }); when click #left div, works ok, when click x , should hide details, hide x , show #middle , #right tags , set width 30%. this, comes 96% width. don't know wh

Return a reference by a class function and return a whole object in c++? -

operator overloading in class cvector: cvector cvector::operator+ (cvector param) { cvector temp; temp.x = x + param.x; temp.y = y + param.y; return (temp); } and in main: cvector (3,1); cvector b (1,2); cvector c; c = + b; so object passed value, , temp object being created. guess b being passed value, 1 calling + therefore x , y belong , pram.x , param.y b. temp returned , the copy assignment operator delivers temp's values c? but this: cvector& cvector::operator= (const cvector& param) { x=param.x; y=param.y; return *this; } and in main: a=b; again calling = , b being passed reference const.(in case matter if passed value?) confused, x belonging assigned param.x of be. why isn't function void, since x , y can accessed function. return *this means, know address of object calling function, *this function itself, if returning object need assign it somewhere previous c=temp after temp=a+b? , cvector& mean, doesn't expect

c# - How to call a webservice from windows phone 6.5? -

i have following problem, try call web service windows phone 6.5 while connected active sync desktop computer, in development debug environment. so dont have wlan connected on phone, maybe problem? but when connected desktop pc, usb (windows mobile device center) can browse web , can acess ?wsdl meta data on phone - web service. webservice running on computer windows service. i use simple web reference local webservice: private void button2_click(object sender, eventargs e) { var method = new mobilecashier.testreference.yvestransfer(); method.timeout = 30000; bool bresult, bresultspec; method.testconnection(out bresult,out bresultspec); messagebox.show(bresult.tostring()); messagebox.show(bresultspec.tostring()); method.dispose(); } but when run on phone in debug mode (or not debug) error: "no connection made because target machine actively refused it" if run windows exe app on desktop computer(the same deploy on phone), or d

c# - Windows 8 store app: How dynamically change Binding in ListViewItem -

i have created common control listview , want change content of each item in listview. displaymemberpath need send 2 values ​​that not same 1 screen. <listview.itemtemplate> <datatemplate> <grid> <textblock text="{binding property1}"/> <textblock text="{binding setter2}"/> </grid> </datatemplate> </listview.itemtemplate> and on next screen want this <textblock text="{binding supernewproperty}"/> <textblock text="{binding setter2xyz}"/> how create control has variable binding like: <textblock text="{binding {binding myspecificvalue}"/> this stupid thing, best describes want do. for completion: ok have module employes.xaml call, control dependency properties itemsource , prop1, prop2(i want use both, display member path). itemsource ienumerable db , contains 2 columns: employename, employnumbe

r - Getting column by column name in plyr using summarize inside a function -

i know how use column names sorted in strings using ddply , summarize outside functions, via get, detailed in ddply + summarise function column name input . works when working interactively prompt. however, doesn't works when try inside function. know there other ways solve problem, detailed in how can use variable names refer data frame columns ddply? . avoid summarise. thing want understand how works (i'm rereading hadley's excellent book, has moved http://adv-r.had.co.nz/ ) as similar happens data.table, provide comparison require(data.table) require(plyr) dt = data.table(alpha = 1:3, beta = head(letters,n=3)) testdt <- function(dt,colname) { dt[,mean(get(colname))] } testplyr <- function(dt,colname) { ddply(.data=dt,.variables=null,.fun=summarise,mean(get(colname))) } testdt works perfectly testdt(dt,"alpha") but testplyr fails when do testplyr(dt,"alpha") surely data.table , plyr deal expressions inside calls differ

c# 4.0 - send data from standby application to active application -

while application in standby mode (not active one),i want write in text box of active application (while cursor in text box ) should done when user press specific key (for example : ctrl + r) first need have this sample on code project learn how cache key pressed while application in background chaek if ctrl + r keys pressed can use use sendkeys.send("your text"); method write in other application text box

c# - How can you set an entire object using LINQ to SQL? -

so if want update row in db using values in received object same pk, how that. reason needed because objects quite extensive , create place have change field names if update database. question how 1 go assigning object object retrieved database using linq? show i'm talking clarify. //foo object received here, called recfoo using (var newcontext = new foodatacontext()) { var obj = newcontext.t_foo.single(x=>x.id == recfoo.id); //set obj = recfoo (directly) newcontext.submitchanges(); } i know can set each individual attribute (obj.name = recfoo.name...), there way can take received object using pk id , assign values inside of recfoo? edit: solution using (var newcontext = new foodatacontext()) { //var obj = newcontext.t_foo.single(x=>x.id == recfoo.id); //set obj = recfoo (directly) newcontext.t_foo.attach(recfoo); newcontext.refresh(system.data.linq.refreshmode.keepcurrentvalues, recfoo); newcontext.submitchanges(); }

tkinter - python 3 threading single statement? -

i trying create python 3 program in want display yes or no question tkinter.messagebox.askyesno() while simultaniously executing winsound.playsound("systemexclamation", winsound.snd_alias) . if put winsound statement first, delays until sound finished playing before creating box. if put after, plays after user clicked yes or no, isn't ideal. trying thread statement , understand threading.thread(target=target).start() requires defined function. put playsound first, snd_async flag: winsound.playsound("systemexclamation", winsound.snd_alias|winsound.snd_async)

c# - Best way to scrape source code from a webpage? -

i'm working on c# app. best way scrape source code webpage? right now, viewing page source in browser (chrome), copying & pasting text file, , sucking parser. i thinking i'd first create textbox in application i'd able paste url. application pull page's source code , pass parser. i'd consider htmlagilitypack. can download page this: htmldocument document = new htmldocument(); document.loadhtml(new webclient().downloadstring("http://www.bing.com")); if looking parser, well, i've had experience scrapysharp adds extension methods htmlagilitypack's htmldocument select elements on page using cssselectors you'd find in jquery, this: document.documentnode.cssselect(".sessions .main-head-row td.download a.text-pdf")

java - what is the faster way to get the first img from URL string? -

it must recognize both forms: <img src='http://www.mysite.com/myimg.png' width="89px" > <img alt="ciao" width="89px" src="http://www.mysite.com/myimg.png" > here quick code made. not tested should work. cut string array of sub strings "/" being cut. 1 of our sub strings has contain image, if not there no image file. string[] src2=src.split("/"); string result="noting found !"; for(int i=0; < src2.length; i++) { if( src2[i].contains("img") && (src2[i].contains(".png") || src2[i].contains(".jpg")/* more extensions */) ) { // add more extensions if needed result = src2[i]; break; { } result = result.split(" ")[0]; //will cut @ first "space" , take "img.jpg" not "width" if(!result.equals("noting found !")) system.out.println("we found image: "+result);

“Error loading RubyGems plugin” while inside a Rails Engine -

in rails engine, "error loading rubygems." however, error doesn't persist when i'm in root directory of app. from main rails folder: $ gem -v 2.0.5 from inside engine: $ gem -v error loading rubygems plugin "/users/me/.rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.2.2/lib/rubygems_plugin.rb": dlopen(/users/me/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.4.1/openssl.bundle, 9): library not loaded: /opt/local/lib/libssl.1.0.0.dylib referenced from: /users/me/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.4.1/openssl.bundle reason: image not found - /users/me/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.4.1/openssl.bundle (loaderror) 2.0.5 this preventing me running bundle install, rails server, etc. i'm stumped. haven't been able find same issue, , have run out of leads on think night. thanks... it turns out problem lack of .ruby-version file in engine directory. adding file

Exclamation Point Randomly In Result of PHP HTML-Email -

i'm getting exclamation points in random spots in result of php email function. read it's because lines long or have encode email in base64 not know how that. this have: $to = "you@you.you"; $subject = "pulling hair out"; $from = "me@me.me"; $headers = "from:" . $from; $headers .= "mime-version: 1.0\r\n"; $headers .= "content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "content-transfer-encoding: 64bit\r\n"; mail($to,$subject,$message,$headers); how fix there's no random ! in result? thanks! as stated here: exclamation point in html email the issue string long. feed html string longer 78 characters mail function, , end ! (bang) in string. this due line length limits in rfc2822 http://tools.ietf.org/html/rfc2822#section-2.1.1

javascript - PHP UPDATE with if and else statement -

i need little script, making library sign in/out , page , have working posts form when sign in , out, want make if trying sign out , never signed in pop-up js alert tell them , can't quite it. here's code: <?php session_start(); include_once("connect.php"); date_default_timezone_set("america/winnipeg"); $date = ("m-d-y"); $timeout = date("g:i:s a"); //search existing entries if ("select exists(select * signin_out lname='".$_post['lastname']."' , fname='".$_post['firstname']."' , date='".$date."')") { //if exist run mysql_query("update signin_out set timeout='" . $timeout . "' lname='" . $_post['lastname'] . "' , fname='" . $_post['firstname'] . "' , timeout='' "); header(&quo

android - Why marker's info window doesn't show? -

i stuck couldn't figour out why info window doesn't show when click on map's marker. read on developer android site should add marker , give them title, snippet , on. result nothing. public class clubmapactivity extends defaultactivity implements googlemap.onmarkerclicklistener { private googlemap mmap; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.clubmap); bundle bundle = getintent().getextras(); double lat = bundle.getdouble("latitude"); double lng = bundle.getdouble("longitude"); mmap = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); mmap.addmarker(new markeroptions() .position(new latlng(lat, lng)) .title(bundle.getstring("clubnmae")).snippet("aaa")); animatecamerato(lat, lng); cameraupdate zoom=cameraupdatefactory.zoomto(

java - Error with user input within calculator program -

this code used calculator program. package javaapp; import java.util.scanner; public class javaapp { public static void main(string args[]){ scanner matt = new scanner("system.in"); double fnum; double snum; double answer; system.out.println("enter first number: "); fnum = matt.nextdouble(); system.out.println("enter second number: "); snum = matt.nextdouble(); answer = fnum + snum; system.out.println(answer); } } this error: exception in thread "main" java.util.inputmismatchexception @ java.util.scanner.throwfor(scanner.java:909) @ java.util.scanner.next(scanner.java:1530) @ java.util.scanner.nextdouble(scanner.java:2456) @ javaapp.javaapp.main(javaapp.java:10) java result: 1 remove quotes constructor of scanner it's not attempting read string source scanner matt = new scanner(system.in);

osx - Mac OS 10.8: apache exiting with code 1 -

i've been reading issue , have tried many things, none seem work me. after being frustrated xampp, i'm trying setup development environment locally using apache that's installed (along php , mysql). whenever do: sudo apachectl start nothing happens, , console displays: 8/23/13 3:21:08.262 pm com.apple.launchd[1]: (org.apache.httpd[1086]) exited code: 1 8/23/13 3:21:08.262 pm com.apple.launchd[1]: (org.apache.httpd) throttling respawn: start in 10 seconds i've tried doing suggestion common, seems to make directory error log, , chmod 777 it. if do: sudo apachectl -t i get: warning: documentroot [/usr/docs/dummy-host.example.com] not exist warning: documentroot [/usr/docs/dummy-host2.example.com] not exist httpd: not reliably determine server's qualified domain name, using 10.5.120.124 servername syntax ok i see ip address in 3rd line there, , i'm thinking maybe that's source of issue? if can give me advice might help, that'd grea

php - Tricky rss to read with curl -

does body know hot make feed http://maxhire.net/cp/?ea5e6f361d4364703d044f72 read curl? miss curl conf, i'm new this, js function url_get_contents ($url) { if (!function_exists('curl_init')){ die('curl not installed!'); } $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_post, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_followlocation, 1); $output = curl_exec($ch); curl_close($ch); return $output; } and calling script below, echo url_get_contents('http://maxhire.net/cp/?ea5e6f361d4364703d044f72'); does not work feed , works other, http: / / x ml.corriereobjects.it/rss/homepage.xml this website seems expect cookie named aspxautodetectcookiesupport , if didn't find it redirect cookie detection page, , stuck in loop: > curl -i -l http://maxhire.net/cp/?ea5e6f361d4364703d044f72 http/1.1 302 found date: fri, 23 aug 2013 23:10:55 gmt server: microsoft-iis/6.0 p3p: cp=

c++ - What's the proper format for a union initializer list? -

say have class/struct single union in it... like: struct box { union { as128 intr; struct { as32 a, b, c, d; }; }; }; what's proper way initializer list kind of data type? box imyboxa = { 10, 10, 100, 100 }; box imyboxb = ( box ){ 10, 10, 100, 100 }; the 'a' option above works in many cases, isn't portable... giving error "no known conversion argument 1 'brace-enclosed initializer list'". , second doesn't compile "cannot omit braces around initialization of subobject..." i've tried few other cases , can't seem compile across multiple platforms. the original version of structure , union definition in question was: struct box { union { as128 intr; as32 a, b, c, d; } }; this little unusual. assuming types as128 , as32 defined, equivalent to: struct box1 // renamed convenience of testing { union { as128 intr; as32 a; as32 b; as32 c; as32 d; }; };

python - When to use Threadpool in Gevent -

i've noticed gevent has threadpool object. can explain me when use threadpool , when use regular pool? whats difference between gevent.threadpool , gevent.pool? when have piece of python code take's long time run (seconds) , not cause swithing of greenlets. (no networking) other greenlets / gevent jobs 'starve' , have no computation time , application 'hangs'. if put 'heavy' task in threadpool, ,the threaded execution make sure other greenlets not starve. believe if code spends lot of time in c library have no effect. below example gevent examples . note example uses time.sleep blocks , not gevent.sleep. tip : if have loop takes long time run can put in gevent.sleep(0) in loop. every loop other greenlets have chance run. gevent .sleep(0) in slow loop make sure other greenlets not starve , applications appears responsive import time import gevent gevent.threadpool import threadpool pool = threadpool(3) start = time.time() _ in xrang

python - Table creating gets messed up -

Image
i trying create table using below html code in python,it works instances cases table gets messed below,please see screen shot..any inputs on wrong?how debug it?any workarounds fix it?really appreciate inputs html source messed row: http://pastie.org/8263837 ........... ........... gerritmailbody = gerritmailbody + "<td>" + gerritinfo['targetname'].rstrip('\n') + "</td>" gerritmailbody = gerritmailbody + "<td>" + gerritinfo['assignee'].rstrip('\n') + "</td>" usernames.append(gerritinfo['assignee'].rstrip('\n')) #below block getting messed gerritmailbody = gerritmailbody + "<td height=\"150\%\">" gerritmailbody = gerritmailbody + "<table>" item in gerritinfo['gerriturl']: gerritmailbody = gerritmailbody + "<tr>" gerritmailbody = gerritmailbody + "<td>" ge

shell - unix script to exit from oracle error when using a wait statement -

i have ksh shell script runs .sql script background , wait statement. possible me capture generic "ora-0" error , exit out completely? so far: $oracle_base/bin/sqlplus 2.sql & pid2=$! echo "waiting pid:$pid2" wait $pid2 #look error here #exit program if oracle error sql*plus kind of shell itself, catches errors oracle , continues execution. want @ sql*plus command whenever sqlerror , whenever sqlerror exit allows exit error code. so, @ beginning of .sql script add : whenever sqlerror exit sql.sqlcode and if there sql error exit relevant error code. now, in shell script after wait can error reading $? . something (depending on exact syntax of shell) : wait $pid2 ret=$? if [ $ret != 0 ] # if not success exit $ret # propagate error code fi

PHP chmod permission denied -

i using mac , try unlink file via php: $old_path = 'tmp/table.csv'; if(file_exists($old_path)){ chmod($old_path, 777); unlink($old_path); } it looks chmod permission denied. searched online no ideas. says chown, how work? the user executing command has no rights execute chmod command.

jquery validate plugin override error message for required: -

so have been trying global override of fields class 'required'. got can add red background field fails validation class required so: $("#signup_form").validate({ errorclass: "validateerror" }); i have tried using errorplacement: function others have mentioned remove error param so: $("#signup_form").validate({ errorclass: "validateerror" errorplacement: function (error, elemenet) { error.remove(); }, }); this kills validation entirely. one forum mentioned need specify each field validation expect , override default 'required' message nothing in messages: function. how can set globally seeing setup needs dynamic anticipate field class required set it? thanks lot to style elements have validation errors, target default class errors css. default class error . .error { background-color: #ff0000; } or perhaps more specifically: input.error { background-color: #ff0000; }

mysql - trying to link address table with companyX -

i have question related mysql relationships. let's have 4 table companya companyb companyc , companyd , each containing 3 columns: name , phone , , age . have table called address want link each companyx address table , let’s if did select * companyx; address column should appearnext each name. can done mysql? first of all, if company tables have exact same structure why don't use single table store information? may want read database normalization . secondly create relation table named 'companiesaddresses' , store fields such "companyid" , "addressid" in (you have create primary key column in companyx's table , same in 'addresses' table use inner join clause information want such select companyx.companyname, addresses.address companyx inner join companiesaddresses on companyx.companyid = companiesaddresses.companyid inner join addresses on companiesaddresses.addressid = addresses.addressid . i hope understood want

handlebars.js - Meteor template: Pass a parameter into each sub template, and retrieve it in the sub-template helper -

i trying figure out how pass parameter sub-template in each block , use parameter in sub-template sub-template helper. here tried far: template: <template name="parent"> {{#each nodes }} {{> child myparam}} {{/each}} </template> <template name="child"> {{ paramname }} </template> js: template.parent.nodes = function() { //return list }; template.parent.myparam = function() { return {"paramname" : "paramvalue"}; }; template.child.someotherhelper = function() { //how access "paramname" parameter? } so far, hasn't been working, , seems somehow mess input node list also. help. when use {{> child myparam}} , it's calling child template , associates myparam current template data context, meaning in template can reference {{paramname}} . in someotherhelper use this.paramname retrieve "paramvalue" . however, when you're using {{#each nodes}}{{> child}}{{/each}

python - how to download file by urllib2.urlopen -

i know how download simple file urrlib2.urlopen but end url not simple has special character in : " www.math.ualberta.ca/mss/misc/a mathematician's apology.pdf " special character mathematician's ' in path some how know http://www.math.ualberta.ca/mss/misc/a%20mathematician%27s%20apology.pdf is url have use download file if don't have kind of end url me every time please give me solution can download file has special url i have basic method can used don't know how use urllib.quote(string[, safe]) urllib.quote_plus(string[, safe]) urllib.unquote(string) urllib.unquote_plus(string) please me method example thank why not use this? filename = url.split('/')[-1] cleanurl = urllib.quote(url) urllib.urlretrieve(cleanurl, filename)

vb.net - Need Help Converting .NET class structure to PHP -

i hoping can me achieve same structure in php. here in .net class. public class objsample private _myprivatevar boolean = false public property mypublicproperty boolean return _myprivatevar end set(byval value boolean) _myprivatevar = value end set end property end class here is: class objsample { private $_myprivatevar = false; public $_mypublicproperty; public function getmyprivatevar() { return $this->_myprivatevar; } public function setmyprivatevar($val) { $this->_myprivatevar = $val; } }

ruby on rails 3.2 - simple form and bootstrap 3 -

with recent changes on bootstrap, i'd apply common css class input_html: {class: 'form-control'} elements without manually doing all. there way make default. haven't found setting that. jquery way of achieving aaron gong mentioned. save time of doing manually adds artificial step on client side may not cleanest solution. you may try applying sass @extend ( http://sass-lang.com/docs/yardoc/file.sass_reference.html#extend ) using css selectors select type of input want modify. example input[type='email'], input[type='password'] { @extend .form-control; }

asp.net - How can i fill a dropdown list before opening a jQuery dialog -

i have form lists bunch of links open basic documents, ie. pdf, docs, etc. on right side links have href link open jquery dialog details on each specific link, example, name of link, option upload new updated document etc. in dialog able have dropdown list holds sort order, list of numbers 1,2,3,4,5 etc. user can reorder links. best way fill form textboxes, dropdown lists (most important) needed data database , open jquery dialog. using jquery ajax , webservice fill textboxes fine, dropdown list getting filled after browser rendered. execute ajax call jquery button click event when user clicks on href tag lives on right side of each link. doesnt allow me grab selectedvalue on postback on save button click event updated values , update record. appreciated. function loaddocumentsort(id, selectedsort) { $.ajax({ type: 'post', url: baseurl + 'webservices.asmx/getsortcount', data: json.stringify({ articleid: articleid }), contenttype: "applic

math - Why should I use t1 - t0 < 0, not t1 < t0, when using System.nanoTime() in JAVA -

when reading system.nanotime() api in java. found line: one should use t1 - t0 < 0, not t1 < t0, because of possibility of numerical overflow. http://docs.oracle.com/javase/7/docs/api/java/lang/system.html#nanotime() to compare 2 nanotime values long t0 = system.nanotime(); ... long t1 = system.nanotime(); one should use t1 - t0 < 0, not t1 < t0, because of possibility of numerical overflow. i want know why t1 - t0 < 0 preferable way prevent overflow. because read other thread a < b more preferable a - b < 0 . java integer compareto() - why use comparison vs. subtraction? these 2 things make contradiction. the nano time not 'real' time, counter increments starting unspecified number when unspecified event occurs (maybe computer booted up). it overflow, , become negative @ point. if t0 before overflows (i.e. large positive), , t1 after (very large negative number), t1 < t0 (i.e. conditions wrong because t1

java - the method getactivity() is undefined for the type Use In activity_main for User Database -

i trying create user database on activity_main page when users sign app, lead them next major page. here activitymain.java file currently: package com.example.awesomefilebuilder; import android.content.contentvalues; import android.content.intent; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.view.onclicklistener; import android.view.viewgroup; import android.widget.button; import android.widget.edittext; import android.widget.toast; public class mainactivity extends base_activity { public final static string extra_message = "com.example.awesomefilebuilder.message"; public final string tag = "mainactivity"; public final string edit_message ="username"; public static final string database_name = "data"; public static final string table_name = &q

ajax - chrome browser not sending 'If-None-Match' for xhr -

i'm using angular service resource via rest api. server sets etag header value , sets cache-control: no-cache in it's response. this works expected using firefox, when access same app using chrome, not sending if-none-match . i've tried on current chrome dev , stable channels on both mac , ubuntu box, , same on both, while firefox adding if-none-match correctly. now, there other non-xhr/static resources fetched conditionally , requests correctly 304 not modified response. is there can more information why chrome not sending if-none-match header xhr requests? if you're issuing ajax query in chrome on https, certificate errors, such using self-signed cert on api server, prevent response being cached. seems design. evidently chrome defect existed fixed in webkit , made chromium / chrome around 2010. another question recommends setting if-modified-since , if-none-match headers manually using jquery's ifmodified: true , cache: true options

Ajax data returned to Symfony partial_include that is recognized by current jQuery / DOM? -

i trying return ajax data recognized jquery. able interact jquery when page loads having content load in between div tag so: <div id="edit-features-id"> include_partial( 'user/favoriteseditfavorites', array('vrs_allfav_data' => $vrs_allfav_data) ); </div> this div tag attached jquery dialog . , make things more interesting dialog opened dialog before it. explanation lets call first dialog ( listview ) , second dialog ( editmode ). therefore when page loads include_partial loads include_partial in between div tags therefore when editmode opened jquery recognizes jquery commands. works able delete, modify , reorder data nothing happens until click save. when click save, data posted ajax, updates database , if successful returns alert confirmation. when alert closed this: closes editmode dialog first function updates listview dialog div tag second function updates editview dialog div tag since listview view l

sublimetext2 - Replacing an open-ended HTML regex match in Sublime Text -

i've been doing lot of finding , replacing in sublime text , decided needed learn regex. far, good. i'm no expert means, i'm learning quickly. the trouble knowing how replace open-ended html matches. for example, wanted find <button> s didn't have role attribute. after hacking , searching, came following pattern ( see in action ): <button(?![^>]+role).*?>(.*?) great! except, in code base i'm working in, there tons of results. how do replacing results safely injecting role=button @ end of <button , before closing > in opening tag? desired results before: <button type="button"> after: <button type="button" role="button"> before: <button class="btn-lg" type="button"> after: <button class="btn-lg" type="button" role="button"> you can capture before ending > , put back, before insertion of role=button : <(

How to add emoticons in UITextView while editing -

i developing xmpp-client app. 1 of features sending smiles , user should have ability edit usuall text. emoticons editing in viber app best example of want implement. i tried 3 ways solve problem: i create emoticon usual uiimageview , place subview on uitextview using current caret rect. use 5 whitespaces text placeholder in text view. there 2 problems: placing emoticons on new line when inserting text in middle(printing whitespace not make caret move new line); when user placing caret using magnify glass, can move caret through emoticon(through 5 whitespaces), delegate method not called during process. i have tried egotextview. there problems caret position , resizing when new line should added. , there rendering artifacts when using 1 line size. i have tried using uiwebview. there great problems resizing based on text size , other artifacts speed of response when becoming first responder. may 1 give me advice of working solution? any suggestion please? thanks!

php - How to create JSON object with array of nested arrays for multipletimes and multiple times? -

$data=array ( "maths" : [ { "name" : "ramesh", // first element "marks" : 67, "age" : 23 }, { "name" : "mayur", // second element "marks" : 65, "age" : 21 } ], "science" : [ { "name" : "ram", // first element "marks" : 56, "age" : 27 }, { "name" : "santosh", // second element "marks" : 78, "age" : 41 } ] ); you can create $data , encode json this <?php $data = array ( "maths" => array( array( "name" => "ramesh", // first element "marks" => 67, "age"

yeoman - Yo : Migrate from 1.0 RC to 1.0 -

i had created angular app using yo 1.0 rc so there improvements in workflow(grunt files,etc) in yo 1.0 ? is there can update app(build 1.0rc) 1.0 ? rc means release candidate. before releasing major version release candidates serve purpose of finding , fixing bugs. no new features added in rcs. to see has changed have @ commit log . yo doesn't have changelog unfortunately. of fixes revolve around fact yo switched colors.js chalk, there still lingering references old library. so, no there's no benefit existing project. as generator-angular, here's changelog . have , decide yourself.

gcc - How to resolve crt0.o linking issue in cross compiling? -

how add ctr0.o ? i error: yagarto-4.7.2/bin/arm-none-eabi-ld: cannot find crt0.o: no such file or directory collect2: error: ld returned 1 exit status` while compiling simple program here : /* -- first.s */ /* comment */ .global main /* 'main' our entry point , must global */ .func main /* 'main' function */ main: /* main */ mov r0, #2 /* put 2 inside register r0 */ bx lr /* return main */ i have seen these 2 threads , didn't full , straight forward answer: http://www.raspberrypi.org/phpbb3/viewtopic.php?t=50046 what rationale behind removing crt0.o gcc4.7.x? i have these files, difference between crt0 , crtn can't use it? ./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtbegin.o ./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtend.o ./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crti.o ./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtn.o ./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crtbegin.o ./yagarto-4.7.2/lib/gcc/a

jquery - Click event not firing on a div containing overlaid images in Firefox -

i'm trying show popup when clicks on youtube thumbnail. works fine in chrome click event isn't firing in firefox. i've managed cut problem down i've got below ( fiddle here ) <div class="youtube"> <img class="thumb" src="http://img.youtube.com/vi/rsylgfbepm4/mqdefault.jpg" alt="marrakech"/> <img class="playbutton" src="http://ec2-54-229-110-227.eu-west-1.compute.amazonaws.com/content/images/videoplay.png" alt="play button"/> </div> the attach happening fine handler doesn't called in firefox $(".youtube").click(function () { alert('clicked'); return false; }); i suspect it's positioning/layout of div or images .youtube { margin: 5px; width: 320px; height: 180px; overflow: hidden; cursor: pointer; border: solid 5px #f00; position: relative; } div.youtube img.thumb { position:relative; z

xaml - Grid column definitions -

inside same stackpanel i'd put control aligned on left , 1 on right side. made attempt using grid , defining columndefinitions no luck. <stackpanel orientation="horizontal"> <grid> <grid.columndefinitions> <columndefinition width="auto" /> <columndefinition width="72" /> </grid.columndefinitions> <stackpanel horizontalalignment="left" grid.column="0" orientation="horizontal"> <button /> </stackpanel> <stackpanel horizontalalignment="right" grid.column="1"> <button height="72" width="72" /> </stackpanel> &l

Append repeated text using sed or awk? -

i have following config file: servers = ( { host = "localhost"; ... timeout = 5; }, { host = "127.0.0.1"; ... timeout = 0; }, { host = "example.com"; ... timeout = 99; } ); i want append "index" setting @ end of each section config this: servers = ( { host = "localhost"; ... timeout = 5; index = 1; }, { host = "127.0.0.1"; ... timeout = 0; index = 2; }, { host = "example.com"; ... timeout = 99; index = 3; } ); how can conventional unix tools sed or awk ? this adds line index = ... after each line has timeout first word. awk '1;$1=="timeout"{printf " index = %d;\n", ++i}' file

Using default constructor and parameterised constructor in unity c# -

i have application uses unity fw resolve objects throughout. have done change framework , classes can seen in code comment "new change" the wrapper class looks like public static class contractresolver { public static t resolve<t>() //this been used in many places in application { iunitycontainer container = new unitycontainer(); var section = (unityconfigurationsection)configurationmanager.getsection("unity"); section.containers.default.configure(container); return container.resolve<t>(); } //new change: new function suppose return instance of parameterised constructor public static t resolve<t>(parameteroverride[] parameteroverrides) { iunitycontainer container = new unitycontainer(); var section = (unityconfigurationsection)configurationmanager.getsection("unity"); section.containers.default.con

deployment - Database cannot open because VBA project cannot be read in MSAccess2010 file -

an amateur programmer has made nice little program works through vba on top of ms-access2010 database. asked make installer database+vba project. code runs fine on computer office installed, on computers without office error above. on computers without office install ms-access2010 runtime, free, in order able open .accde file @ all. not prevent vba error. i did research on issue did not find related specific scenario. how can troubleshooted? the problem version mismatch between .accde file (sp1) , installed ms access 2010 runtime (original) after upgrading runtime sp1 fine.

c# - Linq-to-XML for retrieving all child nodes -

i have following xml <?xml version="1.0" encoding="utf-8"?> <errorserver> <clientip> <allowall>false</allowall> <client_127_0_0_1>true</client_127_0_0_1> </clientip> <users> <admin> <password>passw0r!d</password> <nexterror>83</nexterror> <active>true</active> </admin> <jimbob> <password>passw0r!d</password> <nexterror>83</nexterror> <active>true</active> </jimbob> </users> </errorserver> using linq in c# trying user names (admin & jimbob in example above) using following code list<string> result = new list<string>(); xdocument xdoc = xdocument.load("errorserverconfig.xml"); //run query var lv1s = lv1 in xdoc.descendants("errorserver") select n

java - Is there a difference between initializing a variable with its declaration, or in a static initialization? -

the static initializer called once classloader, want, doing initialization outside static code block more readable (debatable). there difference between two? private static final map<myenum, cheese> cheesecache; static { parsercache = new enummap< myenum, string>(myenum.class){{ for(myenum myenum: myenum.values()){ put(myenum, new cheese(myenum)) ; } }}; } or : private static final map<lab, labresultparser> cheesecache = new enummap< myenum, string>(myenum.class){{ for(myenum myenum: myenum.values()){ put(myenum, new cheese(myenum)) ; } }}; it can affect ordering - example have: private static final int declaredfirst; private static final int declaredsecond = new random.nextint(); static { declaredfirst = declaredsecond + 1; } the initializers executed in textual order. of course, have declared declaredfirst se

ruby - Actionmailer - heroku app -

this newbie question please excuse me, have been working rails, first time trying require gems heroku app not include rails - plain ruby app. ok have app.rb file looking this: require "sinatra" require 'koala' require 'action_mailer' actionmailer::base.raise_delivery_errors = true actionmailer::base.delivery_method = :smtp actionmailer::base.smtp_settings = { :address => "smtp.sendgrid.net", :port => 587, :domain => "mydomain", :authentication => :plain, :user_name => "user_name", :password => "password", :enable_starttls_auto => true } actionmailer::base.view_paths= file.dirname(__file__) class testmailer < actionmailer::base default :from => "my_email" def welcome_email mail(:to => "my_email", :subject => "test mail", :body => "test mail body") end end what run testmailer::deli

javascript - How to limit frequency of calls to model functions in angularjs? -

i'm learning angularjs , picking apart first example, todo list connected todo javascript model. in html have: <div ng-controller="todoctrl"> <span>{{remaining()}} of {{todos.length}} remaining</span> in controller script have: $scope.remaining = function () { // --> alert called on each keystroke alert('remaining called'); var count = 0; angular.foreach($scope.todos, function (todo) { count += todo.done ? 0 : 1; }); return count; }; i'm thinking become latency problem if on each keystroke references controller have evaluated. what approach, if any, used make more efficient? you can use $watch method on scope react when todos changed. cant way better performance. $scope.$watch('todos', function() { $scope.remaining = ... // remaining int }, true); also, if use new angular, $watchcollection method.

android - how to avoid collision between different groups in box2d -

i have studied lot collision filtering using categories , masks , groups. involve prevention of collision between related object while collide opposite group. case totally different have 2 groups , want should collide within group bodies of different group can't collide bodies of opposite group. for example blue balls can collide each other , red ones red ones. no blue ball can collide red ball. thoughts on this you can set group index negative bodies wont collide , can set group index positive bodies want collide. collision groups let specify integral group index. can have shapes same group index collide (positive index) or never collide (negative index). group indices used things somehow related, parts of bicycle. in following example, shape1 , shape2 collide, shape3 , shape4 never collide. shape1def.filter.groupindex = 6; shape2def.filter.groupindex = 6; shape3def.filter.groupindex = -8; shape4def.filter.groupindex = -8;

azureservicebus - Windows Azure ServiceBus Relay clarification -

could 1 azure service bus expert me queries below? when these tcp ports gets used 9350 9354? communication between azure service bus relay , on-premise wcf service? if use webhttprelaybinding, client service bus end point request happens via https , sb wcf service via tcp? if use tcprelaybinding client sb , sb wcf service happens on tcp? is possible use hybrid connection webhttprelaybinding noticing slow response time? is fair assume tcprelaybinding faster webhttprelay binding? is fair assume communication between sb , wcf service (onpremise) happens on tcp only? 1) tcp ports used when listener interacts service bus. 2) can specify connection type sb -> on premise service setting servicebusenvironment.systemconnectivity.mode = connectivitymode.http . default setting connectivitymode.autodetect , attempt use tcp first. 3) similar 2. 4) not sure on atm. 5) believe faster. 6) nope, if autodetect connectivity mode, communication can happen via http.

asp.net mvc 3 - MVc error with EF -

i create model hasnt relation tables ef. when add in context , run app create database had error in application-start: one or more validation errors detected during model generation: system.data.edm.edmentitytype: : entitytype 'urlhelper' has no key defined. define key entitytype. system.data.edm.edmentitytype: : entitytype 'requestcontext' has no key defined. define key entitytype. system.data.edm.edmentitytype: : entitytype 'httpcontextbase' has no key defined. define key entitytype. system.data.edm.edmentitytype: : entitytype 'exception' has no key defined. define key entitytype. system.data.edm.edmentitytype: : entitytype 'type' has no key defined. define key entitytype. code in global.asax below: public class myinitializer : dropcreatedatabaseifmodelchanges<dbta> { } protected void application_start() { //for creating , initializing database system.data.entity.database.

How to Integrate JSON API from website -

i have been assigned integrate api client website. api provided vision6.com.au. there no information avialble on website. can give me 1 example contact vision6 database , add contact our website developed using jquery , php. here way trying var newval = { "id": 1, "method": "adduser", "params": [ "apikey", "123456", { "username" : "username_123", "password" : "123456abc", "first_name" : "first name", "last_name" : "last name", "email" : "example@example.com", "mobile" : "0412312312", "phone" : "56565656", "fax" : "57575757", "position" : "manager",