Posts

Showing posts from June, 2015

PHP - Filter Non Numerals from a string -

i have variable: $number that contain values in these formats: 125.00 125.00 $125.00 i need insert number database, need remove/filter out isn't number whilst retaining decimals points. not sure how/best approach in php? use regex : <?php $num = "125.00"; $num = preg_replace("/([^0-9\.,])/","",$num); $num = (double) $num; // make double allow point , comma $num = (int) $num; // , convert integer echo $num; ?>

javascript - Data not binding properly in angular in list box -

i using below code data in list box. <div class="form-group"> <label class="control-label col-md-6">year built</label> <div class="col-md-6"> <select ng-model="property.yearbuilt" id="yearbuilt" rb-default-year="currentyear" ng-options="year.yearfourdigit year.yearfourdigit year in years"> <option value="">--select--</option> </select> </div> </div> but somoehow data not binding html. getting blank list box 50% of times. can please me in this? i wanted post picture showing seeing, don't have 10 in reputation able that.

sql - Entity Framework 6 with Azure DB secondary connection -

i'm facing problem ef against azure db secondary connection. here problem: i'm using ef 6 code first i setup primary azure db 2 active geo-replicated secondary database (have difference server , db name login account) i use ef6 manipulate primary azure db. case if primary db down (by reason) , want switch active secondary dbs select statements @ runtime. how can achieved that? notes: example, have code snippet below: using (appcontext context = new appcontext()) // appcontext derived dbcontext , using primary connection string { var users = await context.users.tolistasync(); // if line of code failed primary connection string } i want auto-switch dynamically secondary db if line var users... failed @ runtime. recommendation? thanks help!

javascript - AngularJs: Searching with ng-repeat with two different controllers -

i have angular app using 2 tables. top table supposed search data both tables, however, using 2 different controllers. how can top table using simple service or factory? div ng-controller="topctrl"> <tr ng-repeat="data in mydata | filter:search"> <td><input type="checkbox"/></td> <td>{{ data.number }}</td> <td>{{ data.street }}</td> </tr> </div> div ng-controller="botctrl"> <tr ng-repeat="data in mydata2 | filter:search2"> <td><input type="checkbox"/></td> <td>{{ data.number }}</td> <td>{{ data.street }}</td> </tr> </div> you can include service directly searchquery demo angular.module('myapp').controller('topctrl', function topctrl($scope, searchservice) { $scope.mydata = [...

ios - Change Position Of a UIView programatically -

Image
there arabic page in app , "date field" in arabic page must align right side of view(right now, left). have tried following code -(void)changedateposition{ if (!_isenglish) { cgrect currentdatepostion=_viewfordate.frame; [_viewfordate removefromsuperview]; currentdatepostion.origin.x+=currentdatepostion.size.width; _viewfordate.frame=currentdatepostion; [_baseview addsubview:_viewfordate]; } } but did not help. view positioned top of navigation bar(no change in x co-ordinate,either). have used autolayout align left leading space of "viewfordate"(the date field) leading space of "placesview"(the view on top of date field). set priority 250. how can solve problem? hook iboutlet leading constraint of date view , set value 0. , try code: -(void)changedateposition{ if (!_isenglish) { _dateviewleadconstraint.constant = x; } //x - amount view should move right, can calcul...

swift - unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: -

i tried make facebook login function in login page. failed first time, (here code) when try make facebook login in app, "message = "(#100) graph api app id 1xxxxxxxxx called, token has app id 4xxxx851";" error then made again in same way, time, have different type of error. it can built, doesn't show ui. display black. when touch blacked display shows, 2015-09-21 01:42:34.419 nona_app[3327:624143] unexpected nil window in _uiapplicationhandleeventfromqueueevent, _windowserverhittestwindow: ; layer = > this. what wrong p.list or code? , how can solve error? here login page , p.list code. import uikit import parse class customloginviewcontroller: uiviewcontroller { @ibaction func facebooklogin(sender: anyobject) { pffacebookutils.logininbackgroundwithreadpermissions(["public_profile", "email"]) { (user: pfuser?, error: nserror?) -> void in if(fbsdkaccesstoken.currentaccesstoken() != ni...

c# - How can I replace text in RichTextBox form another form? -

so have richtextbox called richtextbox1 , in form named xmleditor want able rename chosen word in parts of rich text box want. (like find , replace in notepad). but want use form called find (it looks find & replace in notepad) have functions replace words in richtextbox1 in xmleditor . the form named find has 2 textboxes , 1 button. first textbox named textbox1 used choose text replace while textbox3 text replaced with. , button button3 replace text while clicked. how can replace text in richtextbox form? how can these forms? void button3_click(object sender, eventargs e) { xmleditor xmle = new xmleditor(); xmle.richtextbox1.text = xmle.richtextbox1.text.replace(textbox1.text, textbox3.text); } one thing can pass xmleditor form parameter when constructing find, , have public xmleditor method can used interaction. interface ifindandreplace { void replace(string s); } public class xmleditor : ifindandreplace { ... public void showf...

git - Best Practice Laravel gitignore -

i want ask best practice laravel. i use gulp js , css. 1 should include on push @ asset folder (use "gulp" on server) or public folder (gulp result)? which 1 should include on push @ asset folder (use "gulp" on server) or public folder (gulp result)? any generated content should not, if possible, included in git repo (and pushed) if can have post-receive hook on server side executes gulp you, best. being said, isn't possible, , on production server, adding gulp might not possible. in case, versionning generated content acceptable.

Create child processes inside a child process with Python multiprocessing failed -

i observed behavior when trying create nested child processes in python. here parent program parent_process.py : import multiprocessing import child_process pool = multiprocessing.pool(processes=4) in range(4): pool.apply_async(child_process.run, ()) pool.close() pool.join() the parent program calls "run" function in following child program child_process.py: import multiprocessing def run(): pool = multiprocessing.pool(processes=4) print 'test!' pool.close() pool.join() when run parent program, nothing printed out , program exited quickly. however, if print 'test!' moved 1 line above (before nested child processes created), 'test!' printed 4 times. because errors in child process won't print screen, seems show program crashes when child process creates own nested child processes. could explain happens behind scene? thanks! according multiprocessing documentation, daemonic process...

linux - Why is the super simple fuction not displaying 256 colors in my Mac terminal? -

Image
long time mac (read gui) user started running ubuntu , has spent week or customizing .bashrc (ubuntu) file , .bash_profile (mac) informative , colorful ps1 , terminal output. i've got tiny little function: function colors2nums() { code in {0..255}; echo -e "\e[38;05;${code}m $code: test"; done } that displays 256 colors codes can choose 1 want... it works in ubuntu (14.0.4 lts, gnome terminal) , not work @ on mac (os 10.7.5 both iterm & terminal.app). the prompt_command function of .bashrc file on ubuntu same, copied & pasted line-for-line mac's prompt_command function in .bash_profile. both ps1 prompts identical in color (with odd spacing on mac side) , ls -gfa (or variant) prints in colors set ls_colors , .dircolors. colors working output, not all. on mac, 256 lines in same color terminal input set last escaped color (green, white, whatever) in ps1. wth?!? and yes, i've tried 2 variations of trap - debug (hack?): #trap 'echo -ne...

PlayFramework, Scala for loop in view layer. How to get index value? -

this question has answer here: getting index of current loop in play! 2 scala template 2 answers i have loop in view tier of playframework application. @for(art <- currentpage.getarticles()) { } where method: getarticles() returns object of: list<articlei> . i index value inside loop. how can achive this? i use play 2.2.6 java , eclipse ide . the eclipse plugin play very bad. if work, think intelisense figure out on own. you can index in way: @for((art, index) <- currentpage.getarticles()) { <p>element @index @art</p> } note: index starts 0, if want display 1 instead: @for((art, index) <- currentpage.getarticles()) { <p>element @{index+1} @art</p> } i hope, helps you...

javascript - Keep jquery option value, save user's value -

i'm trying achieve quite small. i'll try best explain it. i have option form multiple selects, year, month , date. whenever user selects something, form submitted can fetch data database. <form role="form" action="" method="post"> <select class="form-control" id="day" name="day" onchange="this.form.submit()"> <option>- dummy option -</option> <option>- dummy option -</option> <option>- dummy option -</option> <option>- dummy option -</option> </select> </form> one day, month , year. element's ids "day", "month", "year" . i'm trying show today's date default, automatically fetches today's information. as i'm relatively new js/jq, i've tried set options today's date : var fyear = currentdate.getfullyear(); var fmonth = currentdate.getmon...

Using mongodb for the ruby on rails app -

i new work ruby on rails mongodb, can setup application structure properly.can me start it. example or sample appreciable. first have add gem 'mongoid', '~> 5.0.0.beta', github: 'mongoid/mongoid' in gem file. after add your_app/config/mongoid.yml file development: clients: default: database: database_name hosts: - localhost:27017 then add model , can add number of fields class model include mongoid::document field :name, type: string end then can test using console .

go - Almost Repeating Myself -

combinitorial explosion have lots of code same thing.. tiny variations in data or behavior. can difficult refactor-- perhaps using generics or interpreter? - jeff atwood via coding horror in case not lots of code, still bugging me. have shared problem, when trying connect ip, if fails, should retry next ip. i have 1 function generates producer nsq: //since in critical system, try each ip until producer var err error i, success := 0, false; < len(ips) && !success; i++ { publisher, err = nsq.newproducer(ips[i], nsq.newconfig()) if err == nil { success = true } } the other function shares same code 1 takes nsq consumer , connects it: var err error i, success := 0, false; < len(ips) && !success; i++ { err = consumer.connecttonsqd(ips[i]) if err == nil { success = true } } i rid of repeated code without sacrificing legibility. ideas? you have backwards. solution should follow shape of problem, not sh...

dependency management - Prevent usage of unmanaged dependencies in modules of maven project -

for project, prevent in maven modules usage of dependencies not declared in dependencymanagement in parent pom, there way achieve ? thanks first, never able block user add dependency. user can still add jar manualy in code. secondly yo can decompres module jar , put in project. (actually same ant build) it's start maintain central place version of dependencies. in kind of "corporate parent pom". if company have nexus/artifactory, can "close door" @ point. i think that's utopic have same version of dependencies applications. want able use latest feature of latest version of dependency.

c# - WebClient no response and exception -

using webclient call post api: try { var webclient = new webclient(); var result= webclient.uploadstring('http://wewe.com/name', {...}) //log1 } catch(exception ex) { //log2 } sometime hit problem log1 , log2 not log. no response , exception after http call? reason why? the webexception give answer. read message , inner exception. example: string uri = "http://www.myurl.com/post.php"; try { using (webclient wc = new webclient()) { wc.headers[httprequestheader.contenttype] = "application/x-www-form-urlencoded"; string htmlresult = wc.uploadstring(uri); } catch (webexception webex) { webresponse errresp = webex.response; using (stream respstream = errresp.getresponsestream()) { streamreader reader = new streamreader(respstream); string text = reader.readtoend(); } }

ruby on rails - Datatables + JSON + best_in_place -

i can not add gem best_in_place table. class_datatable.rb: def data class.map |record| [ best_in_place(record, :name), best_in_place(record, :short_name) ] end end there error: nomethoderror (undefined method `best_in_place' classdatatable:0xa9283a44) my gem file: source ' https://rubygems.org ' # bundle edge rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.4' # use sqlite3 database active record gem 'ruby-oci8' gem 'activerecord-oracle_enhanced-adapter' # use scss stylesheets gem 'sass-rails', '~> 5.0' # use uglifier compressor javascript assets gem 'uglifier', '>= 1.3.0' # use coffeescript .coffee assets , views gem 'coffee-rails', '~> 4.1.0' # see https://github.com/rails/execjs#readme more supported runtimes # gem 'therubyracer', platforms: :ruby # use jquery javascript library gem ...

c++ - Static Object and how to create it -

i've got issue program, i'm working embarcadero xe8 c++ builder 32 bit. when want use method read/write stuff plc (programmable logic controller, used communicating machines) object null . i have main form want create connection plc. in main have this: static ceasyplchandler *pplchandler; in method on same page have: long readwritetest(void) { unsigned long ulstart; plcsymboldesc *psymbols; unsigned long ulnumofsymbols = 0; int inumofvars = 2; int i; char **ppszvars = new char*[inumofvars]; (i=0; i< inumofvars; i++) ppszvars[i] = new char[255]; long lresult = result_failed; lresult = pplchandler->getallitems(&psymbols, &ulnumofsymbols); if (lresult == result_ok) when debug, shows pplchandler = null when check out ceasyplchandle comes from, come page (which included library) , see these lines: class plch_dll_decl ceasyplchandler : public cplchandler { public: ceasyplchandler(rts_handle hlogfile = rts_invalid_handle); ceasyplchan...

How to make a multi-character parameter in UNIX using getopt? -

i'm trying make getopt command such when pass "-ab" parameter script, script treat -ab single parameter. #!/bin/sh args=`getopt "ab":fc:d $*` set -- $args in $args case "$i" in -ab) shift;echo "you typed ab $1.";shift;; -c) shift;echo "you typed c $1";shift;; esac done however, not seem work. can offer assistance? getopt doesn't support looking for. can either use single-letter ( -a ) or long options ( --long ). -ab treated same way -a b : option a argument b . note long options prefixed 2 dashes.

python - Filtering for multiple strings on f.read -

ive been playing various ways filter multiple strings on f.read() . cant seem find 1 works id expect to, apart multiple separate loops refuse believe there isn't more elegant solution. i trying akin to: if 'string' or 'string2' or 'string3' in f.read(): i have tried few variations such as: if ('string1', 'string2','string3') in f.read(): if f.read() ('string1', 'string2','string3'): of course i've not found way working in manner expect, , google , docs failing to, enlighten me? after kasramvd's enlightenment below shows both elegance , function. take note of finale line specifically. check_list = ['string1', 'string2', 'string3'] filename in files: f = open(root + filename) fi = f.read() if any(i in fi in check_list): you close in fist code need use or between conditions not objects, can change following : with open('file_name...

php - svn diff for non binary files like .jpg, .png -

i work svn , need find non binary file in between svn sub versions. find out files not '.php,.js,.html , .css' need lis out .jpg, .png, .ttf [font files], .txt svn diff svn diff -r 223:238 it possible list out non binary files ?

javascript - Change value inside directive template and watch for changes -

inside directive template have ng-disabled need change when validationscope changed.... here directive: var addcomment = { link: link, restrict: "e", replace: true, scope:{ validationscope:'@' }, template: '<button type="submit" ng-disabled="validationscope" class="btn btn-default pull-right">send</button>' }; in html put this: <mydirective validation-scope="<%maincomment.maintxt.$invalid%>"></mydirective> problem whith code ng-disabled allways true if maincomment.maintxt.$invalid% changed... also if in directive template put this: {{validationscope}} can see value change to: true/false... do might work now: template:'<button type="submit" ng-disabled="{{validationscope}}" class="btn btn-default pull-right">send</button>'

javascript - Google Maps API: TypeError: a is undefined -

Image
i have searched problem on web , none of them seem give me resolution. have simple script display map of south africa. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" /> <title>map test</title> <script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script> <style> #map-canvas { height: 300px; width: 980px; margin: 0; padding: 0; margin-top: 10px; } </style> </head> <body> <div id="map-canvas" class="map_canvas"></div> <script type="text/javascript"> function initialize() { var mapoptions = { center: new google.maps.latlng(-29.09958,26.18434), zoom: 5, maptypecontroloptions: { position: google.maps.co...

php - REGEX Capture the EURO Sign -

how can capture after total payout: ->capture<- ignore numbers confirmation code: payout: €66 x 7 nights: €461 airbnb service fee: -€17 total payout: €444 live example: use \k or lookbehind. \btotal payout:\s*\k.+

Counter in prolog -

i want create counter in prolog. something starting init/0. adding 1 increment/0, , get_counter/1. value. but don't know how start if have init/0 no inputs how set 0. can give me tips how should try this? i'm not native speaker, if it's not clear mean i'm sorry. here sort of trying achieve: ?- x0 = 0 /* init */, succ(x0, x1) /* inc */, succ(x1, x2) /* inc */. x0 = 0, x1 = 1, x2 = 2. the init giving variable value, incrementing done succ/2 , , getval implicit. however, said in comment, consider use case ! if trying keep track of how deep inside loop are, fine succ/2 or following suggestion @mat . so, count number of foo s in list: list_foos([], 0). list_foos([x|xs], n) :- ( dif(x, foo) -> list_foos(xs, n) ; list_foos(xs, n0), succ(n0, n) % or: n0 + 1 #= n ). you should try out both succ(n0, n) , n0 + 1 #= n see how can use them when either 1 or both of arguments list_foos/2 not ground. if, however,...

java - Grails default memory settings in IntelliJ -

i using grails 2.5.1 , java 8 intellij 14.1.4. whenever run grails command (eg: clean) using grails run target (ctrl+alt+g), intellij executes below command: c:\idocs\programs\java\jdk1.8.0_60\bin\java -dgrails.home=c:\idocs\programs\grails-2.5.1 -dbase.dir=c:\idocs\xxxx -dtools.jar=c:\idocs\programs\java\jdk1.8.0_60\lib\tools.jar -dgroovy.starter.conf=c:\idocs\programs\grails-2.5.1/conf/groovy-starter.conf -xmx768m -xms768m -xx:maxpermsize=256m -xx:permsize=256m -djline.windowsterminal.directconsole=false -dfile.encoding=windows-1252 -classpath c:\idocs\programs\grails-2.5.1\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.4.4.jar;c:\idocs\programs\grails-2.5.1\dist\grails-bootstrap-2.5.1.jar org.codehaus.groovy.grails.cli.support.grailsstarter --main org.codehaus.groovy.grails.cli.grailsscriptrunner --conf c:\idocs\programs\grails-2.5.1/conf/groovy-starter.conf "clean -plain-output" can give me location vm configuration (highlighted above) can edit, permsiz...

ios - Remove Empty lines using Regular Expression -

i'm new ios develoment, have data below , want remove empty lines, please let me know pattern applied: i have used pattern @"(\r\n)" , replaced @"", not work. please me sort out issue #extinf:-1 tvg-name="seedocs" tvg-logo="rt",rt http://rt.ashttp14.visionip.tv/live/rt-global-live-hd/playlist.m3u8 #extinf:-1 tvg-name="hsn" tvg-logo="hsn",hsn tv rtsp://hsn.mpl.miisolutions.net:1935/hsn-live01/_definst_/mp4:420p500kb31 #extinf:-1 tvg-name="us" tvg-logo="us",ustwit http://bglive-a.bitgravity.com/twit/live/high #extinf:-1 tvg-name="aljazeera" tvg-logo="aljazeera",aljazeera rtmp://aljazeeraflashlivefs.fplive.net/aljazeeraflashlive-live/aljazeera_eng_high #extinf:-1 tvg-name="bbc" tvg-logo="bbc",bbc world news #extinf:-1 tvg-name="vevo" tvg-logo="vevo",vevo http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/06/prog_inde...

java - Not getting size while downloading Excel from JSP file -

i wanted download excel .jsp file in application. have added following lines jsp's: <%@ page contenttype="application/vnd.ms-excel" %> response.setheader("pragma", "no-cache"); response.setheader("cache-control", "no-cache"); response.setdateheader("expires", 0); i able download but, in pages able see size while downloading , in not able to. want pages size. can please me?

algorithm - Finding a Number of Cycles in a Graph -

i have find number of cycles in graph. know tarjan's connected components algorithm have little bit confusion. can use dfs or bfs find number of cycles.why not.if it's tree answer change i asking if there 1 outgoing edge each node can use dfs.

php - Getresponse lookup contact to see if exists -

i have code find contact in getresponse see if exists. first part (getting campaign) works, getting contact fails in exception: request have return error: invalid params: <?php $jsonfile = 'jsonrpcclient.php'; if (file_exists($jsonfile)) { require_once $jsonfile; $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $api_url = 'http://api2.getresponse.com'; $client = new jsonrpcclient($api_url); $result = null; // campaign try { $result = $client->get_campaigns( $api_key, array ( 'name' => array ( 'equals' => 'my_customer_list' ) ) ); } catch (exception $e) { die($e->getmessage()); } $campaigns = array_keys($result); $campaign_id = array_pop($campaigns); ...

javascript - Reset google recaptcha in angular application? -

i'm using google's recaptcha in angular project, works expected can't figure out how reset it. i have form in user sends data , after successful post form reset form user can send mail. in controller have following method: var resetform = function () { //reset models //reset flags //here reset recaptcha } how can function inside angular controller ? if using version 1 recaptcha.reload(); if using version 2 grecaptcha.reset(); through selectors : jquery('#recaptcha_reload').click();

java - Pubnub channel group history -

i have gone through pubnub channel group design pattern, http://scalabl3.github.io/pubnub-design-patterns/2015/08/11/advanced-channel-groups-friend-lists-status-feed-and-presence.html but still stuck doubts implementing group chat consider have groups gp1,gp2 gp1--a,b,c (members) gp2--a,d,e (members) here need subscribe 2 groups,if 2 need add in both ? or 1 group abcde filtering how group history single api call (assuming if gp1 has more 100 friends) thanks the post referring wrote pattern creating shallow friend graphs , status feeds, can adapt chats pretty easily. for chat, can learn patterns here: http://scalabl3.github.io/pubnub-design-patterns/2015/03/05/inbound-channel-pattern.html if group chats have small groups, inbound pattern works well, i'd less 5-7 people in group chat. not work larger groups, ex. 50 people, because publishing every users' inbound channel every chat message send. in case of larger groups, group chat should have it...

java - Single table per class hierarchy without discriminator column -

i have existing table without discriminator column , need map single table hierarchy, how map this? here table vehicle ======== vehicle_id manufacturer load_capacity passenger_capacity i have 3 classes vehicle.java vehicleid; manufacturer; transportationvehicle.java loadcapacity; passengervehicle.java passengercapacity; one way use @mappedsuperclass on vehicle class , map transportationvehicle , passengervehicle same table. this way inherit mapped fields vehicle without having map entity.

ios - Issue with share only text on Facebook using FacebookSDK -

Image
in application want share text on facebook. using facebooksdk. my code below: nsdictionary *params = @{ @"name" :[nsstring stringwithformat:@"jinx share"], @"caption" : [nsstring stringwithformat:@""], @"description" :@"some text share", @"picture" : @"", @"link" : @"", }; // if session closed, open here, , establish handler state changes [fbsession openactivesessionwithreadpermissions:nil allowloginui:yes completionhandler:^(fbsession *session,fbsessionstate state, nserror *error) { if (error) { uialertview *alertview = [[uialertview alloc] initwithtitle:@"error" message:error.localizeddescription delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alertview show]; } ...

vaadin - BeanItem not updating associated Field more than one, when changing property by hand -

i'm scratching head, trying work out why beanitem's property isn't updating component field's value - more once :(. class mycomponent extends customcomponent { textfield firstnames beanitem<myobject> bean = new beanitem<myobject>(new myobject()) mycomponent() { layout layout = new formlayout() setcompositionroot(layout) firstnames = new textfield("first names") layout.addcomponent(firstnames) fieldgroup binder = new fieldgroup(bean) binder.bindmemberfields(this) } void setfromaccount(myobject newobject) { bean.getitemproperty("firstnames").setvalue(newobject.firstnames) } } the first time call setfromaccount value of firstnames text field updated on screen. second time isn't, , first value persists. does know what's going on? thought whenever set value on underlying property updated through internal listeners. why happening first time? ...

swift2 - Re open the review and converter to Swift 2.0-Xcode 7 -

Image
i open project (swift 1.2) xcode 7, , xcode suggestion me convert swift 2.0. canceled it, want open review , converter of xcode 7. how that? this answer looking to latest swift syntax @ latest menu.

python pip error pkg_resources.DistributionNotFound -

i'm trying install new module, found pip doesn't work - shows pkg_resources.distributionnotfound: 'pip==1.5.6' distribution not found , required application for each call performed. also, pip --help . found advises reinstall pip using pip or easy_install , easy_install doesn't works too: pkg_resources.distributionnotfound: 'setuptools==5.7' distribution not found , required application is there way fix issue without reinstalling python , modules? have linux ubuntu 14.04. apt-get install python-pip suggests installing pip (and heap of following software) don't have in system. afraid it, conflict here? upd. apt-get says want install following: build-essential dpkg-dev fakeroot g++ g++-4.8 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot libstdc++-4.8-dev python-chardet-whl python-colorama python-colorama-whl python-distlib python-distlib-whl python-html5lib python-html5lib-whl python-pip python-...

Selenium 1 - switch to iframe without ID -

the page crape have removed id iframe, have problem switching iframe, , can't find documentation me, maybe there here on stack? the url of page is: http://www.klappen.se/boka/onlinebokning/ i'm using selenium 1 , code looks this: $this->_driver->switchto()->getframebyname("mainframe"); in targetlocator.php have these functions: <?php // copyright 2012-present nearsoft, inc // licensed under apache license, version 2.0 (the "license"); // may not use file except in compliance license. // may obtain copy of license @ // http://www.apache.org/licenses/license-2.0 // unless required applicable law or agreed in writing, software // distributed under license distributed on "as is" basis, // without warranties or conditions of kind, either express or implied. // see license specific language governing permissions , // limitations under license. namespace seleniumclient; require_once 'webdriver.php'; class targetloca...

ios - UIAlertController tint color defaults to blue on highlight -

i'm use following code present uialertcontroller action sheet item text red. i've used tint property set color. uialertcontroller *alertcontroller = [uialertcontroller alertcontrollerwithtitle:nil message:nil preferredstyle:uialertcontrollerstyleactionsheet]; alertcontroller.view.tintcolor = [uicolor redcolor]; the text color seems defaulting blue on highlight or selection. normal , how stop this? this known bug, see https://openradar.appspot.com/22209332 to fix it, reapply tint color in completion handler. here's swift solution, able adapt objc: alertcontroller.view.tintcolor = uicolor.redcolor() // apply 1st time prevent flicker blue red when displaying navigationcontroller?.presentviewcontroller(alertcontroller, animated: true, completion: { // bugfix: ios9 - tint not applied without reapplying alertcontroller.view.tintcolor = ui...

function - Most efficient / Best way to call a javascript method contained within an object - by string -

alright - here's story: i have form definition: <form method="post" data-callback="object[callback]"> there global living object called: object has method callback(); what best method of parsing string in "data-callback", converting function name (but can object - - not global function) , calling specific params, applied specific context? :) thanks!

c# - Convert Anonymous type to IEnumerable<> in EF6 -

i developing mvc application using entity framework. want 5 columns table , return them in ienumerable type. code is: ienumerable<mst> n = new list<mst>(); n = db.msts.select(x => new { x.id, x.code, x.desc, x.l1, x.l2 }).orderby(h => h.code).tolist(); but gives me error cannot implicitly convert type 'system.collection.generic.list <anonymous#1> ' 'system.collection.generic.ienumerable <<mst>> ' how can solve it? first don't need tolist() because don't need list: db.msts .select(x => new { x.id, x.code, x.desc, x.l1, x.l2 }) .orderby(h => h.code) now need type mst . if type ef knew include directly in select : db.msts .select(x => new mst{ id = x.id, code =x.code, desc = x.desc, l1 =x.l1, l2 =x.l2 }) .orderby(h => h.code) but it's not, need break ef in-memory asenumerable , creation of mst after that: ienumerable<mst> n = db.msts .select(x => new { ...

Unit-Testing a service in Controller with Jasmine in AngularJS -

in controller i've defined following service: crudservice.getallgroups().$promise.then( function (response) { $scope.groups = response; }, function (error) { //error code.. } ); well, want test service whether gets response or not. in test script @ first i've defined function check whether service defined @ all. test code: describe('ctrl: testctrl', function () { beforeeach(module('testapp')); var scope, crudservice, ctrl, backend; beforeeach(inject(function ($controller, $rootscope, _crudservice_, $httpbackend) { scope = $rootscope.$new(); ctrl = $controller('testctrl', { $scope: scope }); crudservice = _crudservice_; backend = $httpbackend; })); it('should defined service getgroups', function () { expect(crudservice.getgroups).tobedefined(); }); //this wrong! it('should returns successful respon...

c# - How to set header value in asp.net web api -

i want able set header value/secret key in asp.net web api, can not use web service except or has secret key, , also, if set on api side, how user retrieves value/secret key on client side , use while consuming service. i have tried this, not sure whether right. below code: public iqueryable<paymentapi> getpaymentapi() { var re = request; var headers = re.headers; if(headers.contains("rtyuiopjhfghjuiopjklkljh")) { return db.paymentapi; } return null; } thanks response.

javascript - Using Phonegap download image and want to convert it into base64 in iOS -

i stuck in problem regarding base64. the situation - download image in ipad , getting path of download image :- {"isfile":true,"isdirectory":false,"name":"testimage.png","fullpath":"/testimage.png","filesystem":"","nativeurl":"file:///var/mobile/containers/data/application/4048f634-d44a-40f8-aca0-32bc9f401f56/documents/testimage.png"} in above object ,nativeurl getting image , able append on html page, want convert base64 ,& not been able till now. i know somewhere possible. making mistake. anybody,expert please me sort out issue, if provide example full in online editor. thanks shivam <div id='mainpostdiv'></div> //hello, need convert base64 // set data first in localstorage var imagedata = localstorage.getitem("imagedata"); var imgpost = document.createelement('img'); imgpost.setattribute(...

.net - SQL Server 2014 In-Memory previous transaction aborted exception -

i'm working on large scale project in production. have big process changed use in-memory tables sql 2014 performance efficiency. the process uses: 51 in-memory sql tables. 50 stored procedures loads data(insert) 150 regular sql tables. 300 validations (short stored procedure) selecting 50 in-memory tables (and insert in-memory table save validation errors if exists). we calling process ado.net, loads stored procedure first , validations, each sp use different sql connection . in normal use, works fine , takes 1.5 second. under stress test (6 clients x 100 tasks) 30 minutes. after several minutes starting sql exception (1 sql exception every 20 tasks): a previous transaction current transaction took dependency on has aborted, , current transaction can no longer commit. transactions in memory-optimized tables the exception not clear. not using begin transaction in process. sql exception occurs in different stored procedures each time. after days of invest...

mysql - Eloquent (Laravel) query in many to many relation -

i have many many relation(eloquent laravel) , want filter item tags. table_item table_item_tag table_tag id name id item_id tag_id id name 1 item 1 1 1 1 tag 2 item b 2 1 2 2 tag b 3 2 1 filter result should this: ` filter: name:tag a&b : sum of item 1 name:tag : sum of item 1 any ideas on how query should like? ive been struggling sum of items have both tags assuming eloquent relations set properly, want along these lines: $tags = ['tag a', 'tag b']; // or input or wherever item::wherehas('tags', function ($q) use ($tags) { foreach ($tags $tag) { $q = $q->where('name', $tag); } })->get();

mysql - How to use not mapped entity fields in query builder -

i have question. have entity has not mapped field type in it. how can use field in query builder building queries? problem since not mapped fields not available in mysql tables, cannot use them in sql queries directly. there way use them in doctrine query builder? ;) you've got several options : either map fields , ( why not ? that's doctrine for... :-) ) or use nativequery . docs here . or use doctrine dbal , pass on query using prepare/execute/fetchall ( this documented here ). : $sql = " select ... "; // query here $connection = $this->getdoctrine()->getmanager(); $qry = $connection->prepare($sql); $qry->execute(); $results = $qry->fetchall(); // can iterate through $results...

jquery - How to remove unicode Hex character in javascript? -

in javascript code given below, going multiply 2 variables. gives nan result of multiplication now. i alerted 2 variables going multiplied. 1 variable integer. variable contains rupee symbol (&#x20b9) decimal value. need remove symbol variable. i have tried below code remove unicode characters variable. price_per_day = price_per_day.replace(/[\ue000-\uf8ff]/g, ''); but showing nan after multiplication. total_days=10; price_per_day = price_per_day.replace(/[\ue000-\uf8ff]/g, ''); var total_amount = parsefloat(price_per_day) * total_days; instead of replacing symbol, extract money var price = document.getelementbyid("price").innerhtml.replace(/[^0-9.,]/g,""); alert(price) <span id="price"> &#x20b9; 50.99</span>

blackberry 10 - BB 10 cascade Listview textstyle color randomly updated after scrolling -

in bb10 app have listview textstyle having green color , red color random text. when scroll list view color shifts , set wrong texts example: apple ==> red bananna == > green after scrolling apple ==> green bananna ==> red this long list happens items visible after scrolling thanks in advance i have got solution below code label { id: alerttypelable text: qstr(listitemdata.alerttype) + retranslate.onlanguagechanged horizontalalignment: horizontalalignment.left verticalalignment: verticalalignment.center textstyle.fontsize: fontsize.xsmall textstyle.color: { if (listitemdata.success.tostring() == "true") { return color.green } else { return color.red } } }

javascript - jQuery UI autocomplete doesn't work in rails app -

i want use jquery ui autocomplete function in rails app. example in jquery website , want make in rails app. jquery-rails , jquery-ui-rails have been installed. i added below codes application.js $(function() { var availabletags = [ "c", "c++", "clojure", "cobol", "haskell", "java", "javascript", "perl", "php", "python", "ruby", ]; $( "#tags" ).autocomplete({ source: availabletags }); }); add codes show.html.erb : <div class="ui-widget"> <label for="tags">tags: </label> <input id="tags"> </div> but doesn't autocomplete when input something(like: "ja"..) anyone can me, in advance! try this: in gemfile gem 'rails3-jquery-autocomplete' `bundle install` in applicati...

javascript - How to attach handler/function to different objects -

need enlightened how define jquery ui slider , bind different objects on page. function setphrasefontsize() { f1 = $("#slider").slider("value"); f1 = 30 - (f1 * 15); f2 = $("#slider").slider("value"); f2 = 30 + (f2 * 15); $("#phrase1").css({ 'font-size': f1 + 'pt' }); $("#phrase2").css({ 'font-size': f2 + 'pt' }); } $("#slider").slider({ value: 0, min: -1, max: 1, step: 0.1, stop: function(event, ui) { setphrasefontsize(); $('input[name="weighting"]').val($("#slider").slider("value")); mydata = $('#feedback').serialize(); alert("ajax post: " + mydata); } }); <link href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet"> <link href="https://maxcdn.bootstrapcdn.com/...

javascript - CKEditor: add a button that opens a pop-up window to a specified URL -

i need add "image" button ckeditor shows pop-up browser window pointing url specify (always same) , inserts string returned pop-up @ cursor position. can manage creating plugin (i've done couple already) can't see how bring window , accept returned string. this allow integration media library. user should able navigate around library @ select image, window return fully-formed tag in string when closes, place in editor content. i can't see in docs allow me add behavior, may looking in wrong place - i'm no ckeditor expert. or pointers appreciated.

My C array gets corrupted during execution -

i'm writing c program card game, , i'm making algorithm deal cards each of players. problem is, seemingly no reason, 1 of array pointers getting set 0 during execution, , can't figure out why. seems happen @ specific spot in code. here declare array: struct hand *hands = (struct hand*)calloc(players, sizeof(struct hand)); (int player = 0; player < leftovers; player++) { //allocate spot these players, since take //extra card hands[player].cardv = (struct card*)calloc((cardsperplayer + 1), sizeof(struct card)); hands[player].cardc = cardsperplayer + 1; } (int player = leftovers; player < players; player++) { //allocate normal amount of cards rest of players hands[player].cardv = (struct card*)calloc((cardsperplayer), sizeof(struct card)); hands[player].cardc = cardsperplayer; } next, skip past part make deck of cards , fill cards values, point i'm shuffling cards in deck, ready deal them. seems shuffle finishes, pointer hands arra...

image - Specify limits to a plane's dimension, depending on data dimensions, so it exactly overlaps data -

Image
in matlab, plotting plane should overlap 3d data available. in cases (as shown below), plane's dimension becomes large. how can specify dimensions of plane more or less overlaps data , not appear huge? is in meshgrid function? should input be? dimension should adapt other (but similar) data. i have attached functions here . this how can use functions: displayreconstructedscene( pointcloud3d, j1 ); hold on load('n,v , p.mat') [ n,v,p,x,y,z ] = display_plane(n, v, p);

android - Implementing Oauth2 with login credentials from native login page -

i trying implement oauth2 based web service. have clientid, clientsecret, authorization endpoint, token endpoint , callback url(custom schema points android native page). when checked other oauth2 based apis, has login url , redirected login web page. in case there not login url, should redirected native login page , on success response should redirected logged in native page. how access token using oauth2? appreciated. from comments above, let's assume have had asp.net webapi server-side app, , if android client app uses httpurlconnection , can refer following sample code (of course, need modify more make works requirement): string address = "http://<ip>:<port>/token"; httpurlconnection urlconnection; string requestbody; uri.builder builder = new uri.builder(); map<string, string> stringmap = new hashmap<>(); stringmap.put("grant_type", "password...