Posts

Showing posts from January, 2015

php - Middleware For actions into Controller, Laravel 5.1 -

i have controller have index method, have multiple levels of users have access method, single admin can view records of database how can add middleware select action corresponding user? have next code <?php namespace set\http\controllers; use illuminate\http\request; use illuminate\support\facades\session; use illuminate\support\facades\redirect; use set\http\requests; use set\http\requests\labrequest; use set\http\controllers\controller; use illuminate\routing\route; use set\lab; use validator; use auth; use db; class laboratoriocontroller extends controller { public function __construct(){ $this->beforefilter('@find', ['only' => ['show','edit','update','destroy']]); } public function find(route $route){ $this->laboratorio = lab::findorfail($route->getparameter('laboratorio')); } /** * display listing of resource. * * @return response */ public function index() { $labs = lab::all(); r...

c++ - Building Qt-4.3.2 from source on Linux machine -

i trying build , compile qt 4.3.2 on linux machine.i have downloaded package http://download.qt.io/archive/qt/4.3/qt-x11-opensource-src-4.3.2.tar.gz.mirrorlist configured options: ./configure -platform linux-g++ -debug-and-release -qt-zlib -qt-libtiff -qt-libmng -qt-libjpeg -openssl -v -opengl -glib after trying compile make , getting following error. ../../../include/qtcore/../../src/corelib/thread/qatomic.h: in instantiation of ‘qatomicpointer<t>::qatomicpointer(t*) [with t = qbytearray]’: ../../corelib/codecs/qsimplecodec.cpp:609:74: required here ../../../include/qtcore/../../src/corelib/thread/qatomic.h:207:7: error: ‘init’ not declared in scope, , no declarations found argument-dependent lookup @ point of instantiation [-fpermissive] ../../../include/qtcore/../../src/corelib/thread/qatomic.h:207:7: note: declarations in dependent base ‘qbasicatomicpointer<qbytearray>’ not found unqualified lookup ../../../include/qtcore/../../src/corelib/thread/qatomic.h...

c# - An object reference is required for the non-static field, method, or property -

ive looked @ duplicate errors havent found solution here method im implementing in business logic public void updatebooking(bookingview model) { using (var booking = new bookingrepository()) { var user = new applicationuser(); booking book = booking.getbyid(model.bookingid); if (book != null) { book.bookingid = model.bookingid; book.bookingdate = model.bookingdate; book.bookingtime = model.bookingtime; book.location = model.location; //book.status = defaultstatus(); //book.treatmentname = book.treatmentname; //book.addinfo = model.addinfo; booking.update(book); } } } but error on booking controller method [httppost] [validateantiforgerytoken] public actionresult postponebooking([bind(include = "location,bookingdate,bookingtime")]book...

java - Tomcat Virtual host Requests for different wars -

what best practices handling multiple host requests same context path :eg: "my-services" different environment(test, dev, prod) tomcat 7 server want webapplication different flavors of war, test.war, dev.war deployed on same tomcat instance. please let me know caveats in doing this? war file restful web service consumed different apache httpd server running on same machine of tomcat server. i followed tomcat documentation following links explain in more elaborative manner http://www.ex-parrot.com/pete/tomcat-vhost.html?bcsi-ac-0f50f852aecff21e=24aedc5100000002vjkkrulw4bxxzrg4kowom6tbvxodbaaaagaaactxdwasaqaaaaaaacmxaga=

javascript - Having trouble converting /Date(####)/ to MM/dd/yyyy local with MomentJS -

using external api that's sending me dates such as: /date(1439596800)/ the above date is: august 30, 2015 using momentjs this: moment("/date(1439596800)/").format("mm/dd/yyyy"); gets me this: 01/17/1970 :( i'm aware i'm supposed multiply * 1000 hoping there specific momentjs method. thank help. it's rather simple. your api gives unix timestamp - default, moment(arg) assumes arg passed milliseconds since 1st january 1970. for converting it, must first remove /date( , )\ . i'd use regex strips non-digit characters: mystring = mystring.replace(/\d/g,''); this leave numbers. now, can run moment.unix(mystring).format("mm/dd/yyyy"); moment.js reference unix timestamps

php - Paypal payment destroys Session on "Return" -

this question has been asked before. but, still unable find solution. i have integrated paypal payment website. created , installed "payment button" (the html code), , works perfectly. the problem, however, : after being re-directed paypal make payment, user's session on website destroyed. meaning : after payment successful (or canceled user, whichever).......the "return url" not work, because user has been logged out. i did contact paypal, of course; and, expected, next useless (exactly many people here have attested to). as said earlier, question has been asked before, here : anybody ever used paypal website payments standard session variables? the answer proposed "woppi" in thread seemed ok. but, when tried it, did not work. (of course, thread 3 years old). i don't know else do. i should point out following, (this makes no difference, want clear possible) : (a) on website's "log-out page", have set session...

javascript - Passing values from directive to controller -

below html template: <div ng-app="dr" ng-controller="testctrl"> <test color1="color1" data-method="ctrlfn(msg)"></test> </div> below code: var app = angular.module('dr', []); app.controller("testctrl", function($scope) { $scope.ctrlfn = function(arg) { alert(arg); } }); app.directive('test', function() { return { restrict: 'e', scope: { fromdirectivefn: '&method' }, link: function(scope, elm, attrs) { //way 1 scope.hello = "some message"; scope.fromdirectivefn(scope.hello); } } }); <div ng-app="dr" ng-controller="testctrl"> <test color1="color1" data-method="ctrlfn(msg)"></test> </div> why getting " undefined " instead of " some message ...

javascript - Clean way to post users web page shares to Facebook page -

i looking way show facebook engagement on our website on our facebook page. ie, when likes/shares etc. page on website, that activity reflected our facebook page in way. i planning on using graph api calls page updates, permissions granted users, not app itself, meaning possible existing administrators, defeating whole purpose (perhaps bit obvious in hindsight). is there good, clean way of posting page likes/shares of our web pages our facebook page feed? notes: i'm working in php and/or client side js a high volume of posts drowning our regular content not @ moment, however, advice how manage such beast in long run might helpful if understood correctly , want share content facebook website, behavior mention used exist via activity feed or recommendations feed . however, has been deprecated since graph api version 2.3. if want update comments people in website fb page, implement in backend listens content uploaded , uses page access token create custom sto...

java - Why is it impossible to serve connections from pool according to the prepared statement already executed with them? -

i've been researching around web efficient way design connection pool , tried analyze details available libraries (hikaricp, bonecp, etc.). our application heavy-load consumer webapp , of time users working on similar business objects (thus underlying sql queries executed same, still there numerous). designed work different dbms (oracle , ms sql server especially). so simplified use case : user goes on particular jsp page (e.g. enterprise). a corresponding bean created. each time realizes action (e.g. getemployees() , computeturnover() ), bean asks pool connection , returns when done. if want take advantage of prepared statement caching of underlying jdbc driver (as pstatements attached connection - jtds doc. ), understand optimal way of doing : analyze kind of sql query particular bean want execute before providing available connection pool. find connection same prepared statement has been executed if possible. serve connection accordingly (and use benefits of...

c# - Having troubles in ordering search results using Lucene -

i running search query following bring results dynamics crm. search working fine brining results based on relevance. want order them in descending order of 'createdon' field. displaying 10 results per page, can't sort result returned query. is there way order based on field? public ienumerable<searchresult> search(string term, int? pagenumber, int pagesize, out int totalhits, ienumerable<string> logicalname) { var searchprovider = searchmanager.provider; var query = new crmentityquery(term, pagenumber.getvalueordefault(1), pagesize, logicalnames); return getsearchresults(out totalhits, searchprovider, query); } private ienumerable<searchresult> getsearchresults(out int totalhits, searchprovider searchprovider, crmentityquery query) { using (icrmentityindexsearcher searcher = searchprovider.getindexsearcher()) { portal.storerequestitem("searchdeduplicatelistforaut...

django registration redux clean clean password -

i using django 1.8.2 , python 2.7 i novice in django. using django registration redux authenticate users. want manually define clean method on password field ensure password atleast 6 character long, , contains @ least 1 numeric n 1 special character. how that? shall define form inheriting registrationform class? or easier change in registrationform itself? it better override behavior instead of modifying source code subclass registrationform. recommended in comments : form registering new user account. validates requested username not in use, , requires password entered twice catch typos. subclasses should feel free add additional validation need, should avoid defining save() method -- actual saving of collected user data delegated active registration backend.

java - Why bubble sort is taking more time then selection sort -

i trying various scenarios bubble sort , selection sort. know best case bubble sort o(n) if use break statement. lets if not using break statement, there not swaps (as have if condition it), , should take same or less time selection sort. but strangely taking more time me. note : have taken same data set(1 900000) sorted. , using sorted data set, none of algorithms have swappings. please find program below : package sorting; import java.util.arraylist; import java.util.calendar; import java.util.date; import java.util.list; public class sorting<item extends comparable>//this item var/field can find while creatng object , hence non static { list<item> list=new arraylist<item>(); public static void main(string args[]) { sorting<integer> ss=new sorting<integer>(); system.out.println("adding item logic started : "+calendar.getinstance().gettime()); for(int i=0;i<90000;i++) { ...

ios7 - Ios :: dyld: Symbol not found: _OBJC_CLASS_$_UIAlertAction -

i have app works fine ios sdk 8.3 , xcode 6. when check backward compatibility ios sdks 7.1 , 7.1 simulator fails. app crashes following error dyld: symbol not found: _objc_class_$_uialertaction referenced from: /users/apogaeis/library/developer/coresimulator/devices/f48b2d65-9ee8-4737-a0ce-2882d105c6c9/data/applications/25b9dcde-4bc6-4568-8ebe-3474fe559cbc/appname.app/appname expected in: /library/developer/coresimulator/profiles/runtimes/ios 7.1.simruntime/contents/resources/runtimeroot/system/library/frameworks/uikit.framework/uikit in /users/apogaeis/library/developer/coresimulator/devices/f48b2d65-9ee8-4737-a0ce-2882d105c6c9/data/applications/25b9dcde-4bc6-4568-8ebe-3474fe559cbc/appname.app/appname please suggest resolve issue. how can make work ios versions? thanks in case, uikit.framework had marked optional rather required app works fine....

java - OpenImaj AdaptiveLocalThresholdContrast null pointer exception -

i'm trying learn how use openimaj's adaptivelocalthresholdcontrast thresholder process image 2 "segments" , view processed image. when run following code: adaptivelocalthresholdcontrast thresholder = new adaptivelocalthresholdcontrast(10); mbfimage input = imageutilities.readmbf(new file("/path/to/file.jpg")); fimage flat = input.flatten(); displayutilities.display(flat); thresholder.processimage(flat); displayutilities.display(flat); the original (flattened) image displayed, , following null pointer exception @ line thresholder.processimage(flat): exception in thread "main" java.lang.nullpointerexception @ org.openimaj.image.processing.threshold.adaptivelocalthresholdcontrast.processimage(adaptivelocalthresholdcontrast.java:74) i looked @ source code adaptivelocalthresholdcontrast @ line 74, it's not clear me what's causing null pointer exception. appreciated. http://www.openimaj.org/openimaj-image/image-processing/xref/org/o...

java.util.concurrent.ExecutionException: redis.clients.jedis.exceptions.JedisDataException: ERR max number of clients reached -

i trying connect redis database using jedis-client in web application after day application throwing exception below: java.util.concurrent.executionexception: redis.clients.jedis.exceptions.jedisdataexception: err max number of clients reached i tried figure out due redis not able handle connection or may have not close redis connection. //code snippet connect redis jedis jedis = new jedis("localhost"); jedis.connect(); i have not closed connection thinking connection close redis-server idle. may cause. you seem opening connection every time query redis server. after while many clients connected , server cannot accept new connections. there several options: disconnect idle clients server side if want redis server disconnect idle clients, should redis configuration: # close connection after client idle n seconds (0 disable) timeout 0 see reference redis conf . have value set @ 0. changing , restarting redis server should solve issue. clos...

powershell - Using a $Variable to Submit -Filepath Argument for Start-Process -

this question has answer here: powershell gui not set variable 1 answer i'm using powershell version 3. have weird problem fix. i've written powershell script reads config csv file (with application paths , names) , creates form application buttons. when try submit start-process filepath argument variable wont work. when echo variable correct. maybe here knows whats wrong , can me. error argument null or empty in: + $btn.add_click({start-process -filepath "$buttoncommand"}) i tried fix problem solution of stackoverflow thread: $buttoncommand = $buttoncommand.replace("\","\\").replace('"',"") and tried submit $buttoncommand , without '"' #search script path, locate config file in same path $fullpathincfilename = $myinvocation.mycommand.definition $currentscriptname = $myinvocation.m...

python - sklearn PCA not working -

i have been playing around sklearn pca , behaving oddly. from sklearn.decomposition import pca import numpy np identity = np.identity(10) pca = pca(n_components=10) augmented_identity = pca.fit_transform(identity) np.linalg.norm(identity - augmented_identity) 4.5997749080745738 note set number of dimensions 10. shouldn't norm 0? any insight why not appreciated. although pca computes orthogonal components based on covariance matrix, input pca in sklearn data matrix instead of covairance/correlation matrix. import numpy np sklearn.decomposition import pca # gaussian random variable, 10-dimension, identity cov mat x = np.random.randn(100000, 10) pca = pca(n_components=10) x_transformed = pca.fit_transform(x) np.linalg.norm(np.cov(x.t) - np.cov(x_transformed.t)) out[219]: 0.044691263454134933

c# - pass value from app.config from one console application to one class library -

in console application have on app.config <appsettings> <add key="microsoft.servicebus.connectionstring" value="endpoint=sb://xx.servicebus.windows.net/;sharedaccesskeyname=rootmanagesharedaccesskey;sharedaccesskey=xx/krm="/> </appsettings> the console application following: static void main(string[] args) { try { console.writeline("press key continue"); console.readkey(); queuehelper.receivemessage("empresa"); } catch (exception ex) { throw ex; } } however wanted isolate queing methods in different class library, actual implementation of receivemessage in class library /// <summary> /// receives message /// </summary> /// <param name="queuname"></param> public static void receivemessage(str...

xcode - How to round an NSDecimalNumber in swift? -

i can't find resources on this, , i've been trying sorts of stuff, nothing works. according apple's documentation, round nsdecimalnumber this: nsdecimalnumber.decimalnumberbyroundingaccordingtobehavior(<#behavior: nsdecimalnumberbehaviors?#>) it takes in nsdecimalnumberbehavior, i'm unsure how manipulate since (1) cannot initiated variable , have it's properties changed, , (2) roundingmode() method according documentation doesn't take parameters, xcode fills in parameter space "self". i'm totally lost on this. basic question; how can round nsdecimalnumber in swift? thanks in advance you can that let x = 5 let y = 2 let total = x.decimalnumberbydividingby(y).decimalnumberbyroundingaccordingtobehavior( nsdecimalnumberhandler(roundingmode: nsroundingmode.roundup, scale: 0, raiseonexactness: false, raiseonoverflow: false, raiseonunderflow: false, raiseondividebyzero: false))

jsp - Getting values from list<String> , split them and then slice them by parts, using JavaScript -

i have list <string> spring mvc want split, slice , print on browser. problem need enter start , end argument of slice() method variable text-field. code, doesn't work. can helps me that? code: <body> <form>first value: <br/> <input type="text" id="firstvalue" />last value: <br/> <input type="text" id="lastvalue" /> <button onclick="myfunction()">press</button> <p id="demos"></p> </form> <script> function myfunction() { var str = "${first}"; var arr = str.split(","); var first = document.getelementbyid('firstvalue'); var second = document.getelementbyid('lastvalue'); document.getelementbyid("demos").innerhtml = arr.slice('first', 'second'); ...

internationalization - How to make i18n support filenames in Drupal 7? -

so have standard file located at: /sites/default/files/hello.png i can access so: http://www.example.com/sites/default/files/hello.png however, i18n, nice if prefixed paths work these files. example, link doesn't work: http://www.example.com/us/sites/default/files/hello.png but doesn't. so question is, how can make these "country-specific" paths work files? i thinking might need in htaccess , create module filters , redirects these paths, sounds way effort , perhaps missing easy way enable this? you can use htaccess make language-version urls redirect default url files/images. if won't need further in drupal code (e.g. custom module). your rewrite rule this rewriteengine on rewriterule ^([a-za-z-]*)/sites/default/files/(.*)$ sites/default/files/$2 [r=301,l] updated if site in subdirectory e.g. 'drupal', modify rewrite rule this rewriterule ^drupal/([a-za-z-]*)/sites/default/files/(.*)$ drupal/sites/default/files/$2 [r...

active directory - Whether to use an SPN with a Kerberos loginmodule in JAAS -

i building kerberos login module jaas used jconsole. jconsole client used access process exposed mbeans, kerberos loginmodule authenticate user. the user log in via jconsole, , jconsole pass user data loginmodule, username , password handled kerberos loginmodule , users credentials validated against central active directory. i having problems configuration of kerberos. namely. require set of spn? or require single keytab set up? if asking user username , password on console need neither keytab nor spn. need plugin jaas ask password. kerberos session initiated jaas login module , have tgt inside of app. on other hand if planning accept existing kerberos session user ( current windows domain session ) need have spn in active directory, , user not prompted password application. the keytab copy of key stored in kerberos database, need spn generate keytab. converse not true can obtain session key active directory providing spn password.

javascript - Jquery get all checked box and group by checkbox name -

hi have checboxes different names: names - hours, , value - day. example: value="1" means monday, , name="0609" means 06am - 09am. <input type="checkbox" value="1" name="0609"> <input type="checkbox" value="2" name="0609"> ... <input type="checkbox" value="7" name="0609"> <input type="checkbox" value="1" name="0912"> <input type="checkbox" value="2" name="0912"> ... <input type="checkbox" value="7" name="0912"> i need take checked , non checked inputs , combine array name example: if days checked except monday '0609' => 0, 1, 1, 1, 1, 1, 1 how can solve ? i trying .map ungrouped values... var valuess = $('input:checked').map(function() { return this.value; }).get(); console.log(val...

ipython line number out of order creates NameError -

i have ipython notebook running in browser, , have nameerror 'x', in it's defined above in notebook, has numerically lower line number, believe reason nameerror. for example, looks this: in [12]: x = np.random.random((3, 4)) in [4]: print x --------------------------------------------------------------------------- nameerror traceback (most recent call last) <ipython-input-2-73c1d467e5a9> in <module>() 1 #your code here ----> 2 print x nameerror: name 'x' not defined how fix execution order here? the number of left indicates order of execution of block of codes. depending on how run each cell number changes. in example, need run [12] [4] change [13]. , x print. the order you. however, on top bar can click on run all, run blocks top-down. to avoid confusion , variables defined. suggest regularly restart ipython kernel (top bar also) , run all.

c# - How to Find Out Which Record Automapper Errors Out On? -

i using automapper. code looks this: var processedrecords = await queriedrecords.project(x => mapper.map<bsondocument, recordviewmodel>(x)).tolistasync(); my problem cannot put system.diagnostics.debug.writeline() inside map definition. there way know record automapper errors out on? way have been doing putting break point in , clicking continue, working db millions of records, that's not practical. the exception "object reference not set instance of object." assume means object doesn't have property trying map, it's irrelevant q. more interested in theory here. well, can put debug.writeline() in lambda here. make block instead of expression: var processedrecords = await queriedrecords.project(x => { system.diagnostics.debug.writeline(x); return mapper.map<bsondocument, recordviewmodel>(x); }).tolistasync(); you can put try / catch around mapper.map<,>() ca...

asp.net mvc - OWIN OpenIdConnect Single Sign On with Office 365 -

Image
i have managed single sign on over azure active directory openidconnect middleware: app.useopenidconnectauthentication( new openidconnectauthenticationoptions { authenticationmode = authenticationmode.passive, clientid = "{guid}", authority = "https://login.microsoftonline.com/common/", tokenvalidationparameters = new tokenvalidationparameters { validateissuer = false } }); we use multi-tenant application on azure , based on tenantid on returned token check whether user allowed (check tenantid our database whether comes our trusted clients). it works fine, if client single sign on our application. have sync users azure active directory , configure tenantid on our application. the thing is, assume clients have office 365. sync company user accounts office 365 , take advantage user accounts on office 365 , single sign on this. i know office 365 built on top of azure, , can config...

Yii2-Smarty: Cannot Access Methods of $this-object -

yii2-smarty: cannot access object methods i set yii2 smarty extension . now trying convert layouts/main.php file smarty template. need access current yii\web\view object given extension $this -smarty-variable . i've validated smarty $this variable same view-object through var_dump() -ing , comparing both. problem according smarty3 docs should able call method on $this -object smarty templates this: {var_dump($this->head())} . applying above script in template returns null let me guess no method call had happen. question how can call method object given smarty php ? define variable use in smarty: $template->assign('app', \yii::$app); call method on variable in smarty template: {$app->getsession();} what doing wrong ? (my current smarty layout: pastebin ) applying above script in template returns null let me guess no method call had happen. the head() method not return if see null correct. you can call method this: ...

javascript - Is it possible to set ID and Class of an element using jQuery method attr()? -

$("selector").attr("id","idname"); is possible use above setting id or class of element. hm feel i've said thousands of times. jquery class selector returns array of html elements class. so, if want data form elements need loop on array or access directly. $('.gg1').first().attr("id"); //returns id of first element class gg1 $('.gg1')[1].attr("id"); //returns id of second element class gg1 for(var = 0; < $('.gg1').legth; i++= { console.log($('.gg1')[i]); } //loops on cormplete html collection http://api.jquery.com/attr/ http://www.google.com

ios - How to adjust the baseline shift for a UiLabel? -

Image
my app using custom font display information whole app. but there problems base line in image below: i need fix "x 4" centered in vertical red box. how can fix this? you can create uilabel , set size same red box. , set it's text alignment center: youlabel.textalignment = nstextalignment.center another not option make uibutton of same size red box , set userinteractionenabled no . way text positioned in center horizontally , vertically. can set it's setcontentverticalalignment property

php - Two Instances of Simple HTML Dom -

i using php include source 2 files onto web page. the 2 different files 1.php , 2.php have 2 different instances using simplehtmldom. the issue 2.php when included onto web page, shows following error in position. fatal error: cannot redeclare file_get_html() (previously declared in /home/northsho/public_html/w/pages/simple_html_dom.php:70) in /home/northsho/public_html/w/pages/simple_html_dom.php on line 85 edit: further clarification. master.php (includes 1.php , 2.php) 1.php , 2.php both use simple_html_dom.php use structure, although without including 2 files , moving contents function , passing url parameter master.php <?php include 'simple_html_dom.php'; include '1.php'; include '2.php'; 1.php <?php $html = file_get_html('http://example.domain.com'); //do job //destroy object @ end $html->clear(); unset($html); 2.php <?php $html = file_get_html('http://anotherexample.domain.com'); ...

c# - Why Invoke is needed? -

i kinda understand point of threads , invokes, not great. i'm having server/client application made tutorial. i'm having 2 functions. in disconnect function need have invoke in received function don't. why (problem lstclient) ? and if have invoke in received function invoke looping reason, why? void client_disconnected(client sender) { invoke((methodinvoker)delegate { (int = 0; < lstclient.items.count; i++) { client client = lstclient.items[i].tag client; if(client.id == sender.id) { lb_id.items.removeat(i); lb_ip.items.removeat(i); lb_users.items.removeat(i); lstclient.items.removeat(i); break; } } }); } void client_received(client sender, byte[] data) { /*invoke((methodinvoker)delegate {*/ (int = 0; < lstclient.items.count; i++) { client client = lstclient.items[i].tag client; i...

sql server - How to change menu options above SSRS report? -

Image
i'm pretty new ssrs apologies if simple question. when generate report in browser, above report shows several menu options spread out vertically below: this takes lot of room , pretty ugly, how change arrange horizontly more this? you can approach issue following these steps: open report internet explorer, once have report opened, go tools or click on (alt + x), go compatibility view, , add server @ viewing report compatibility view list. fix issue on client level not server level though.

Resolving two types of YouTube channel URLs in API v3 -

i'm taking youtube url user input. logic have follows: if(url === link_to_video) video else if( url == link_to_channel) all_videos_of_channel. i doing via javascript , using youtube api v3. the problem is, seems youtube has 2 types of urls youtube channels. /channel/, eg: www.youtube.com/channel/ucahnfiob5ixv74f5on3lviw /user/, eg: www.youtube.com/user/calvinharrisvevo both above links take same channel, current uploader code supports /user/calvinharrisvevo. is there way make both urls behave in terms of obtaining channel videos? one solution parse url , apply logic: if there `channel` in url link call apiv3 **id** of channel ressource : youtube.channels.list else if there 'user' call apiv3 **forusername** of channel ressource : youtube.channels.list check : https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list

angularjs - $location.path in function is altering scope object -

$scope.copyorder = function() { console.log($scope.products); copyorder.copying = true; copyorder.orderinfo = $scope.orderinfo; copyorder.products = $scope.products; console.log(copyorder.products); $location.path('/neworder'); }; when logging $scope.products shows $scope.products[0].imprint empty array when not. if take out $location.path array inside object shows has 1 object in it. essentially, $location.path shows in log: $scope.products[0].imprint[0] (its length) without $location.path : $scope.products[0].imprint[1] i copying 2 large objects 1 controller (editing) (new). edit: more code, , less code $scope.copyorder = function() { console.log($scope.products); $location.path('/neworder'); }; this still returns $scope.products[0].imprint empty array when should have array 1 object. $scope.copyorder = function() { console.log($scope.products); // shows $scope.pro...

csv - How to add input parameters for matlab application execution -

i'm writing script in matlab , need execute program (written in c) 1 of lines (it generates output file). my current code is: !collect2.exe infile.csv <-- want able change variable can't my question is, there way me either: a. put variable in place of infile.csv such !collect2.exe filedir or b. run multiple files without variable thanks in advance :) edit: filedir = input('what directory quotes?'); !cd / cmdstring = ['cd ', filedir]; system(cmdstring); edit #2: never mind, fixed issue. of help! use system function. example: filename = 'infile.csv'; cmdstring = ['collect2.exe ', filename]; system(cmdstring);

merge - Sql Matching exact DataSets on same table -

i have table contains data such as: store,product a, 1 a, 2 b, 3 b, 2 c, 3 c, 1 d, 1 d, 2 d, 3 i trying write query gives me replacement store, since store d sells product store sells replacement store store not replacement store d since not have of product store d sells. so query return following table: store,store replacement a,- b,- c,- d,a *note couldn't figure out how make table, ',' represents separation of columns. - equals blank in space here version work: select sp.store, sp2.store (select sp.*, count(*) on (partition store) numproducts @storeproduct sp ) sp join @storeproduct sp2 on sp.product = sp2.product , sp.store <> sp2.store group sp.store, sp2.store, numproducts having count(sp2.product) = numproducts; here sql fiddle.

api - domcrawler loop and if statement to check if class exists -

hi i'm running little problem domcrawler. i'm scraping page , has div class of .icon3d . want go through page , every div class add "3d" item array, , every div without add "2d" item. here code have far. for ($i=0; $i < 10; $i++) { $divs = $crawler->filter('div.icon3d'); if(count($divs)){ $type[] = '3d'; }else{ $type[] = '2d'; } } check the domcrawler component documentation first. filter method returns filtered list of nodes, calling ->filter('div.icon3d') returned value list of div elements have icon3d class. first need find div elements, loop through them , add either 3d or 2d array depending on icon3d css class existance. $divs = $crawler->filter('div'); foreach ($divs $node) { $type[] = (false !== strpos($node->getattribute('class'), 'icon3d')) ? '3d' : '2d'; } update $cra...

sql - Reduce/Summarize and Replace Timestamped Records -

i have sql table has timestamped records server performance data. data polled , stored every 1 minute multiple servers. want keep data large period of time reduce number records data older 6 months. for example, have old records so: timestamp server cpu app1 app2 1 ... 00:01 host1 5 1 10 2 ... 00:01 host2 10 5 20 3 ... 00:02 host1 6 0 11 4 ... 00:02 host2 11 5 20 5 ... 00:03 host1 4 1 9 6 ... 00:04 host2 9 6 19 i want able reduce data every minute every 10 minutes or possibly every hour older data. my initial assumption i'd average values times within 10 minute time period , create new timestamped record after deleting old records. create sql query generates insert statements new summarized records? query like? or there better way accomplish summarization job? you might want consider moving summarized information different table don't end in situation you're wonderin...

string - How do I Remove text before a space in java? -

string str = "hello world"; int spacepos = str.indexof(" "); if (spacepos > 0) { string youstring = str.substring(0, spacepos - 1); system.out.println(youstring); } i want "world" result. how result? use substring(startindex) form of substring method. find index of space (' '), pass result + 1 substring method , output string starting position end. follows: string str = "hello world"; string youstring = str.substring(str.indexof(' ') + 1); system.out.println(youstring);

swift - iPhone to iPhone communication -

Image
i developing 2 apps in swift should communicate iphone device , waiting response on global. i using remote push notification , it's working fine, not receiving notification while app in foreground state , has push notification related issues. if used web service sending , receiving. app gets struck due lag response is method available iphone communication on internet without using apns? you can use multipeerconnectivityframework , has support discovering services provided nearby ios devices using infrastructure wi-fi networks, peer-to-peer wi-fi, , bluetooth personal area networks , subsequently communicating services sending message-based data, streaming data, , resources (such files). i adding sample code here , example application builds on multipeer connectivity framework discovering, connecting, , sharing data between "nearby" peers. application uses framework based ui connecting local peers , framework convenience api exhanging text messages...

javascript - Simple Modal Not Working Likely Due to Conflict -

this should have been simple. want insert simple js modal bootstrap 3 page here: http://www.redfuryrevenge.com/index2.html . literally copy , pasted bootstrap page follows: <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#mymodal"> launch demo modal </button> <!-- modal --> <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id...

angularjs - nested sortable angular repeat not populating with $http -

i'm angular newby, , i'm trying produce sortable array within sortable array using ng-sortable. when data directly javascript file works fine, when use $http retrieve same data, non-repeating data displays - don't error, repeaters don't display @ all. controller test data (which works): angular.module('demoapp').controller('testcontroller', function ($scope, testservice, testdatafactory) { $scope.testdata = testservice.gettestdata(testdatafactory.data); }); controller $http: angular.module('demoapp').controller('testcontroller', function ($scope, $http, testservice) { $http.get('test/index') .success(function (data) { $scope.testdata = testservice.gettestdata(data); }) .error(function (data) { alert("error getting test data"); }); }); view: <h1 class="dataname">{{data.name}}</h1> <div ng-model="testdata"...

Finding Dynamic text value of static field using mechanize browser python -

how can find dynamic text per user details entered of static field result using mechanize browser in python. can using "split" function splitting text , storing text in variable. there function directly give me results as: name: abc addr: pqr gender: male abc=mechanize.browser() abc.set_handle_robots(false) abc.open(url) abc._factory.is_html = true abc.select_form(nr=0) x=abc.submit() m=x.read() i tried using 'findall' not working well. here abc can name per login. data not of text box input values. appreciated. this should tell field names: for f in br.forms() print f.name fill in blanks: form["field1"] = ["input1"] hope asking for. cheers!

audio - Java - How do I load a .wav from inside the jar? -

this question has answer here: java.io.ioexception: mark/reset not supported 4 answers i've been trying play .wav file in java project , got working....or thought. when exported executable jar file, sounds won't play unless they're in same directory jar file. want load sounds inside of jar file. here's code i'm using right now: void playsound(string filename) { try (inputstream in = getclass().getresourceasstream(filename)) { try (audioinputstream audioin = audiosystem.getaudioinputstream(in)) { clip clip = audiosystem.getclip(); clip.open(audioin); clip.start(); } } catch (exception e) { e.printstacktrace(); } } i needed change to: void playsound(string filename) { try (inputstream in = getclass().getresourceasst...

java - Is this a valid case to use instanceof operator? -

i beginner in java , oop in general, , have question regarding inheritance in java. in project, have class order represents order placed asset. intend have several classes extend order including limitbuyorder , limitsellorder & likewise market orders. i have class position , consists of pair of orders. in order determine kind of position , must know type of order entered first. although instanceof operator work in situation, feel not appropriate solution. below stripped-down snippet, may illustrate problem: class position { //other fields , methods omitted clarity public void open(order o) { if(o instanceof limitbuyorder) //set position type long if(o instanceof limitsellorder) //set position type short } } or should define methods in order such islimitbuy() & etc, return false , override them return true based on subclass order extended by? class position { //other fields , methods omitted clarity...

php - Wordpress – Random post order -

i want have random post order, not work: order of posts still by date . can me? http://inge.timrodenbroeker.de <!-- t h e l o o p --> <?php query_posts(array('post_type' => 'post', 'orderby' => 'rand', 'posts_per_page' => -1)); ?> <?php if ( have_posts() ): $i = 0; ?> <?php while ( have_posts() ) : the_post(); $i++; ?> <div class="article-content <?php if ($i % 7 == 0) echo 'seventhclass'?>" id="post-<?php the_id(); ?>"> <div class="article-thumb"> <?php the_content(); ?> <!-- close article-thumb --> </div> <!-- close article-content --> </div> <?php endwhile; ?> <!-- /t h e l o o p --> hmm...if check documentation function: https://codex.wordpress.org/function_reference/query_posts you'll see it's not recomended using pluging / themes, suggesting alternati...

android - Espresso List header non-clickable -

in functional tests while using espresso want click on view inside header in listview . according https://code.google.com/p/android-test-kit/wiki/espressosamples#matching_a_view_that_is_a_footer/header_in_a_listview in order have access header in test need this: listview.addheaderview(headerview, header, true); and access this: public static matcher<object> isheader() { return allof(is(instanceof(string.class)), matchers.<object>is(testutil.header)); } & ondata(viewmatchers.isheader()) .inadapterview(allof(withid(r.id.list_view), isdisplayed())) .onchildview(withid(r.id.view_to_click)) .check(matches(isdisplayed())) .perform(click()); however, when that, header clickable. when use: listview.addheaderview(headerview, header, false); espresso not able access view anymore. how can access view test without making header view clickable? so far best workaround have found following: set data on headervie...

class - Swift Generics, create derived object -

i have store class coded generic, can manage kind of classes derived common base class. the store has new() method, creates , returns class manages. in theory, should return derived class. unfortunately, store returns base class. here code snippet explains it: import uikit class base: nsobject { var id:int=0 } class adress:base { var name = "" } class store<t:base> { var nextid:int = 0 func getnextid()->int { return ++nextid; } func new() ->t{ let n = t() n.id = getnextid() return n } } let store = store<adress>() var adr:adress = store.new() // should adress, base adr.name = "tom" // crash here, because adr not adress if debug new() method inside store, creates adress object. in calling code, base object. any idea whats going wrong here? i not understand intensions above code. if substitute class store<t: base> { by class sto...

iOS (Swift) - Casting root view controller of the app delegate's window works in simulator, but fails when app is loaded on phone -

when run app following lines of code (inside appdelegate.swift file): func locationmanager(manager: cllocationmanager!, didrangebeacons beacons: [anyobject], inregion region: clbeaconregion!) { let viewcontroller:viewcontroller = window!.rootviewcontroller as! viewcontroller viewcontroller.beacons = beacons as! [clbeacon] viewcontroller.tableview.reloaddata() ...... } it runs flawlessly when run app in simulator. otherwise, when run app on phone runtime error: could not cast value of type 'uitableviewcontroller' (0x198be57d0) 'beacontest.viewcontroller' (0x1000e15d0). viewcontroller subclass of uitableviewcontroller defined so: http://wwww.pastebin.com/1bm80ipp where window's root view controller being set? if in storyboard, ensure class of root view controller viewcontroller , not uitableviewcontroller .

javascript - Populate Datalist from the Database -

am new javascript , php want populate datalist mysql table have difficulties relevant codes presented below.i able fetch data database not able display them in datalist element. the html code <form class="form" action="insert.php" method="post" name="access_form"> <ul> <li> <h2>please fill form</h2> </li> <li> <label for="firstname">first name</label> <input name="firstname" id="keyword" type="text" placeholder="type first name (required)" required /> <datalist id="results"> </datalist> </li> this javascript code var min_length = 1; $( document ).ready(function() { $("#keyword").keyup(function() { var keyword = $("#keyword").val(); if (keyword.length >= min_length) { $.get( "auto-complete.php", { keyw...

failed to create a new maven project -

while creating new maven project getting error this. could not value parameter encoding plugin execution default-resources plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or 1 of dependencies not resolved: following artifacts not resolved: org.apache.maven:maven-project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-artifact-manager:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, org.apache.maven:maven-core:jar:2.0.6, org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.6, org.apache.maven.reporting:maven-reporting-api:jar:2.0.6, org.apache.maven.doxia:doxia-sink-api:jar:1.0-alpha-7, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-error-diagnostics:jar:2.0.6, commons-cli:commons-cli:jar:1.0, org.apache.maven:maven-plugin-descriptor:jar:2.0.6, org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4, classworlds:classworlds:jar:1.1, org.apache.maven:maven-artifact:jar:2.0.6,...

iOS Native credit card autofill function conflicts with mobile checkout -

in mobile safari ios 8,when have auto fill enabled credit card, in checkout, when try add new card, safari prompts save card or not, , if click on of options safari crashes. per research, please find below few links discussion on same topic on apple forums: https://discussions.apple.com/thread/6652733 https://discussions.apple.com/message/23512169 has 1 solution this??? @gupta120 : there different thread points case if have input type = password in same form has credit card form, credt card auto save native functionality becomes un responsive , crashes safary, pleas echeck link stop safari on ios7 prompting save card data need intercept form submit , change input password type thing other password $("#submit").on("click", function(){ try{ $("input[type=password]").attr("type", "hidden"); } catch(ex){ try { $("input[type=password]").prop("type", ...

android - genymotion emulator not working properly on ubuntu 14.04 LTS -

genymotion emulator working fine not working properly. my setup: ubuntu 14.04 lts genymotion v2.5 virtual device, google nexus 5-5.1.0-api 22 - 1080x1920 system configuration dell inspiron 3543 intel core i5-5200u ram 4gb ubuntu 14.04 lts 64bit the problem when tap on not respond until maximizes emulator window or change size. moreover, when change window mode changes black screen. also, emulator window pixels distorted. need in problem. thanks in advance

scripting - How do I open Photoshop projects in Illustrator using Applescript? -

i'm trying write script takes multiple projects have edited in photoshop , opens them in illustrator, makes changes, saves bunch of different ways, , closes project , opens next one. have working except opening photoshop files in illustrator. projects located in same folder tried setting files list using finder , in illustrator opening file. here code: tell application "finder" set thefiles files of folder posix file "/volumes/assets/blg.com images/images renaming/photoshop files" list end tell repeat f in thefiles tell application "adobe illustrator" activate open f options {class:photoshop options, preserve hidden layers:true, preserve layers:true} without dialogs set alllayers layers of document 1 set allimages page items of document 1 repeat lay in alllayers set visible of lay true end repeat repeat img in allimages set scalematrix scale matrix horizontal ...

Unable to complete password reset in Ruby on Rails 4 -

i trying complete password reset feature rails application. have of routes , views in place , work out problem. when user clicks on email sent system generated password reset token, taken password reset view. when user submits form (valid or not) update user record new password, view reloads no errors or not. have tried multiple configurations no luck. feel has strong parameters, can't seem work. this url generated password reset view http://localhost:3000/password_resets/x6hrhvsjx2nb8-u7zp9-7q/edit this have password reset controller: def edit @user = user.find_by_password_reset_token!(params[:id]) end def update @user = user.find_by_password_reset_token!(params[:id]) if @user.password_reset_sent_at < 2.hours.ago flash[:notice] = "password reset has expired." redirect_to(:action => 'new') elseif @user.update_attributes(user_params) flash[:success] = "password reset successful. please sign in." ...