Posts

Showing posts from July, 2014

How to filter an iron-list in polymer 1.0? -

the dom-repeat element offers filter attribute. is there similar way filter iron-list ? for example: given list of people, want filter ones born in specific city. as iron-list unfortunately doesn't offer filter attribute, there no declarative pattern making possible. you can either implement own simple list element making use of dom-repeat 's filter property. (with element inheritance coming in future releases, might extend iron-list ). however, best practice see use of computed property: <template> <iron-list items="[[filteritems(items)]]" as="item"> ... </iron-list> </template> <script> polymer({ ... filteritems: function (items) { return items.filter(function (item) { // array.prototype.filter return item.priority > 8; // filter condition }); } }); </script>

com - #Import directive fails with error "Request?" is not a valid C++ identifier -

i trying import type library in vc++ console application using following command. #import "c:\typelib.tlb" when build project following error: error c1196 'request?': identifier found in type library 'c:\typelib.tlb' not valid c++ identifier i haven't developed type library on inspection have found of functions in type library using null able parameters , assume that's causing problem e.g. sub schedulemanywithpossiblerequest(byval requester string, byval request? boolean, byval skipunschedulableactivities? boolean) is there way can import type library? i managed import using following directive import. #import "c:\typelib.tlb" rename("request?", "request")

c++ - How can I set the `c` variant for the `/RTC` option if I need it? -

Image
ms visual studio 2015. according msdn possible point c value of /rtc key. don't see variant in items of combobox: if choose default item see /rtc1 variant applied again: if set value manually: then see /rtc option disappeared command line: why /rtc key of visual studio c++ project absent variant c in combobox? how can set variant if need it? for unknown options (for ide, not you), can add manually additional options box in command line settings. but particular option not forgotten, next it, named smaller type check . not in combobox signal because independent of it. can compile /rtc1 alone, /rtcc or both /rtc1 /rtcc . you can argue /rtc1 /rtcs /rtcu , 2 independend. right, , of course, proper gui 1 checkbox each of options. way historical reasons.

ios - health kit observer query always called when the app becomes active -

the resulthandler of hkobserverquery called when app becomes active (background -> foreground) but, wrote code of query in didfinishlaunchingwithoptions method in appdelegate.swift . know method called when app launched not app become active. func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { healthstore.authorizehealthkit { ... } } // other appdelegate methods empty how make handler of query called when app launched? why want prevent updatehandler firing? you can't control when updatehandler of hkobserverquery fires while query running. can prevent being called @ stopping query. designed called whenever there might new healthkit data matching predicate. should design updatehandler such doesn't matter when called. if wanted observer query not fire when app returns foreground, need stop query -[hkhealthstore stopquery:] when app enters background, be

python - Extracting website (URL) from Google local search when URL not found in source? -

Image
i'm looking extract (with webdriver, xpath, css selector, class or id) url lives behind each of website images in google local search results page such this when mouseover of these, can see url reached if click image. yet if view full page source , search of these urls, they're not found. @ source around 1 of images: suggest urls perhaps read in dynamically, though knowledge of web design ends. possible construct xpath or css selector or indeed plain-text search these urls? clarification : when url, mean ultimate urls. mouseover of website images , you'll see urls such bodinbalanceny.com , lamchiropractic.com etc. – these urls i'm looking extract. you can use urlparse. once fetch href attribute, append " https://www.google.com " , try code below. >>> import urlparse >>> url = """https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0cbaqgu8

Integrate SonarQube C# ruleset to TeamCity for Code Analysis Build Break -

is there know here how integrate sonarqube c# ruleset in teamcity code inspection instead using resharper(inspection.net)? we don't want go sonar site(localhost:9000) check c# code issue instead want automate in team city build break if there validated rules in c# sonar. currently used fxcop code inspection ruleset fxcop not complete vs sonar ruleset c#, fxcop contain microsoft ruleset not rulset in rule list (bug,pitfall,cwe,convention etc...) please help. regards well, can launch sonarqube analysis, , web service call @ quality gate status example check not red. if red, free make build fail if you'd like. however, wouldn't recommend fail build, , take habit of going sonarqube visualize quality of project: indeed make sense times times introduce technical debt, you'll want make sure gets paid back, , technical debt doesn't grow in every single sprint. breaking build when new issues introduced saying borrowing money should banned altogether,

tcp - NS-3: Create a Bottleneck Link -

i have client , server, both running multipath tcp stack. multiple point point links created between them, want links share bottleneck link before reaching server. looked here , situation less complex mine. below code runs mptcp. suggest how should make changes create required topology. bit confused on this. lot help. here code topology have. nodecontainer nodes; nodes.create(2); client = nodes.get(0); server = nodes.get(1); mpinternetstackhelper stack; stack.install(client); stack.install(server); vector<ipv4interfacecontainer> ipv4ints; for(int i=0; < sf; i++) { pointtopointhelper p2plink; p2plink.setdeviceattribute ("datarate", stringvalue("5mbps")); p2plink.setchannelattribute("delay", stringvalue("100ms")); netdevicecontainer netdevices; netdevices = p2plink.install(nodes); std::stringstream netaddr; netaddr << "10.1." << (i+1) << ".0"; string str =

c++ - Does a reference declaration introduce a new name for the referent? -

in this question we've learnt rvo cannot applied expression p.first . in comments suggested rvo not applied expression r after declaration auto& r = p.first . less clear whether standard mandates behaviour. in return statement in function class return type, when expression name of non-volatile automatic object (other function parameter or variable introduced exception-declaration of handler ([except.handle])) same type (ignoring cv-qualification) function return type, copy/move operation can omitted constructing automatic object directly function's return value in following code, r name of object known o , extent rvo permissible when forms expression in return statement? int o = 42; int& r = o; cwg #633 addressed fact references, unlike objects, didn't have actual names. resolved n2993 , extended notion of variable encompass references, thereby giving them names. [basic]/6 reads (all emphasis me): a variable introduced declarati

c - Print Max Subarray Values From An Array After Running Divide And Conquer Algorithm -

i have implemented solution find maximum subarray array of values. can print out full array prior running divide , conquer algorithm, cannot seem figure out how print subarray after algorithm run. int newarray[] = {31, -41, 59, 26, -53, 58, 97, -93, -23, 84}; int arraysize = (sizeof(newarray)/sizeof(int)); printarray(newarray, 0, arraysize - 1); int total = maxsubdiv(newarray, 0, arraysize - 1); this snippet of main function. using printarray function print full array prior finding maximum subarray. maxsubdiv function follows: int maxsubdiv(int * array1, int left, int right) { if(left == right) { return array1[1]; } int middle = (left + right)/2; return findmax(maxsubdiv(array1, left, middle), maxsubdiv(array1, middle + 1, right), leftrightcross(array1, left, middle, right)); } int leftrightcross(int * array1, int left, int middle, int right) { int sum = 0; int leftsum = int_min; for(int = middle; >= left; i--) {

Applying a function to every combination of two columns in a dataframe using R -

i want apply function myfoo to every possible combination of 2 columns in dataframe mydf , result in matrix format myoutput . consider following dataframe, # example dataframe mydf <- data.frame(var1 = 1:10, var2 = 11:20, var3 = 21:30) head(mydf) # var1 var2 var3 # 1 11 21 # 2 12 22 # 3 13 23 # 4 14 24 # 5 15 25 to want apply following function every possible combination of 2 columns, # example function myfoo <- function(vara, varb) sum(vara * varb) myfoo(var1, var2) # [1] 935 in order output. # desired output myoutput <- matrix(c(0, 935, 1485, 935, 0, 4035, 1485, 4035, 0), 3, dimnames = list(names(mydf), names(mydf))) myoutput # var1 var2 var3 # var1 0 935 1485 # var2 935 0 4035 # var3 1485 4035 0 in case convert matrix (no reason keep data.frame when columns of numeric class) , run compiled crossprod function matrix cross product. m <- as.matrix(mydf) res <- crossprod(m, m) diag(res) <- 0 # ca

Drawing 3D voronoi polyhedrons over human body points in MATLAB -

Image
i trying draw voronoi polyhedrons in 3d around set of points (which coordinates of position of sensors) placed on human frame. found couple of ways in matlab. except none of them giving me right kind of polyhedrons. understand voronoi in 3d set of points should appear this. how expected graph like: for set of data points, voronoi polyhedrons not encapsulate of points. voronoi polyhedrons formed out of data points this: . the coordinates of data set : x= [116,191,0; 108,183,0; 120,175,0; 100,162,12; 116,166,8; 133,158,14; 100,150,0; 116,166,15; 125,144,8; 90,133,5; 108,133,2.5; 144,133,5; 116,116,15; 144,116,6.5; 108,100,-5; 150,100,15; 83,100,15; 108,83,14; 100,58,13; 133,50,13; 100,25,11; 133,30,12; 100,8.3,14; 133,8.3,14]; i used code in link ( http://www.mathworks.com/help/matlab/math/voronoi-diagrams.html ) drawing voronoi on these points , error this: error using convhull

php - yii2 hasOne relation work wrong -

Image
i have 2 tables : users , favorite following : now establish relation between them following in favorite model public function getuser() { return $this->hasone(user::classname(), ['id', 'user_favorited']); } in controller find list of user's favorites public function actiongetlist() { $favorite = favorite::find()->where([ 'user_favoriting' => yii::$app->user->id ])->all(); foreach ($favorite $key => $item) { # code... echo "<pre>"; var_dump($item->user); echo "<br/>"; die('123'); } return $favorite; } but when make request action error column not found: 1054 unknown column '0' in 'where clause'\nthe sql being executed was: select * `users` (`0`, `1`) in ((12, 80))", please me! according documentation have use: public function getuser() { return $this->hasone(user::classname()

c# - How to remove/delete ContentControl in Canvas WPF -

i'm starting wpf , have problem. please me. thanks, sorry bad english! i have added contentcontrol canvas, , want remove/delete it. draw contentcontrol code: contentcontrol cc = new contentcontrol(); cc.content = shape; cc.height = h; cc.width = w; style s = mycanvas.findresource("designeritemstyle") style; cc.style = s; canvas.setleft(cc, x); canvas.settop(cc, y); mycanvas.children.add(cc); i use hittest remove can remove shape private void mycanvas_mouserightbuttondown(object sender, mousebuttoneventargs e) { point pt = e.getposition((canvas)sender); hittestresult result = visualtreehelper.hittest(mycanvas, pt); if (result != null) { mycanvas.children.remove(result.visualhit shape); //it works shape // have changed mycanvas.children.remove(result.visualhit contentcontrol); //but didn't work contentcontrol } } it because contentco

email integration - Custom message in New Order Confirmation Shippin Method Magento CE -

i trying setup custom message in new order confirmation email "shipping method" when selects shipping method "store pickup" @ checkout. in db method name called flatrate2. here snippet attempting edit... if ($method) { foreach ($address->getallshippingrates() $rate) { if ($rate->getcode()==$method) { $amountprice = $address->getquote()->getstore()->convertprice($rate->getprice(), false); $this->_setamount($amountprice); $this->_setbaseamount($rate->getprice()); if (!$method=='flatrate2'){ $shippingdescription = $rate->getcarriertitle() . ' - ' . $rate->getmethodtitle();} else{ $shippingdescription = 'your merchandise ready pickup 45 minutes after completing order.<br/>store pickup available mon – friday 11:30 – 4:30 pm';} $address->setshippingdescription(trim($shi

c++ - Dereferencing iterator to pointer -

i have program using iterator print objects. pointers each object stored in vector. when try print these objects dereferencing iterator, prints memory location. believe because have 1 more layer of indirection due pointers, when dereference again, seg fault haven't been able track down. can find problem? int main(int argc, const char * argv[]){ objectfactory* objfact = readinput(); (objectfactory::const_iterator p = objfact->begin(); p!=objfact->end(); ++p){ std::cout << *p << " "; } return 0; } objectfactory* readinput(){ std::vector<myobject*> myobjects; objectfactory* objfact = objectfactory::get_inst(); std::string input; int years_passed; std::cin >> years_passed; std::cin >> input; int age = 0; float diameter = 0; while (std::cin){ try{ if (input == "int"){ int value;

c# - Universal Windows App disable Webview to cache all JSON Documents -

i developing uwp-app webview hosts javascript application. have traffic of json documents database , back. webview caches documents, needs during runtime extremly ram (up 2gb on machine). saves documents textdata in local folder. possible avoid that? set frame.cachesize = -1 , run webview.cleartemporarywebdataasync() in intervals. have no idea can furthermore , www isn't helpfull... kind regards

sql server - Error on opening qd.openrecordset -

what wrong in sample ? breaks indicated, while tbl name provided 1 of working linked table. sub showlinked(tbl string) 'tbl name of existing local linked table (sql server)' dim db dao.database, rs dao.recordset dim qd querydef set db = currentdb db.tabledefs(tbl) debug.print .name, .sourcetablename, .connect set qd = db.createquerydef("") qd.connect = .connect qd.sql = "select 1 xxx " & .sourcetablename qd.returnsrecords = true set rs = qd.openrecordset() 'breaks here: error 3146 - "odbc--call failed" debug.print "test connection:", rs.fields(0) end end sub found culprit: testing function on access table called data_archive_transaction , sourcetablename data_archive.transaction (not name, promise). since transaction reserved word, in select must surrounded brackets: data_archive.[transaction] . tried table more normal name , wor

c++ - Any way to Implement Excel LINEST function using boost libraries? -

does boost::math have functions used implement function similar ms excel linest function ? i parsed boost documentation (not in boost::math, looks more boost::ublas). now, couldn't find example simple enough not overkill non-mathematician. from saw, rather advise using armadillo , use seems straightforward. i have reproduced below simplified code example taken armadillo source archive : int main(int argc, char** argv) { // points fit line mat data = "1 6; 2 5; 3 7; 4 10"; // transform problem armadillo use-case (ax = b problem) vec b(data.n_rows); mat c(data.n_rows, 2); for(u32 i=0; i<data.n_rows; ++i) { b(i) = data(i,1); c(i,0) = 1; c(i,1) = data(i,0); } // compute least-squares solution, should "3.5; 1.4" vec solution = solve(c,b); cout << "solution:" << endl << solution << endl; return 0; }

tfs2013 - TFS 2013: Share a workspace across two computers? -

running problem, boss has 2 computers, 1 @ office , 1 @ office b. currently, has both tfs work spaces binded single, shared network folder can access. told me today having trouble checking files out office a, , checking them in @ office b. i didn't set setup him, apparently used work fine when using sourcesafe. there anyway can make setup work him? collection using "server" workspace collection, if helps. it's set let 1 user checkout file @ time. if need more information configuration, let me know. although i'm no tfs wizard. my initial research shows setup not "right" way, since it's 1 person i'd working him if possible, or if there proper solution wouldn't radically different. the workspace defined computer name , workspace name cannot have "same" workspace on 2 different computers. should check-in in office remap office workspace different (network shared) folder

httpresponse - HTTP request and response flow for get -

i having difficulties understanding http request , response flow. working system can "hijack" incoming http request , give own response. problem having type of request seem assume data sent in first request. for instance, jpeg image requests, no matter size (my tests include 0-20 mb jpeg files) seems assume entire data sent in first response. if don't send data , explicitly set range header 0 never response client asking data. other data request types, such mp4 video, client seems fine getting response header information no data , sends new request explicitly asking byte range 0-. is there kind of agreement between the client , server types should sent in 1 request while others can split in number of requests?

session - PHP PHPSESSID persists after calling session_name(***) -

can't seem find solution problem i'm having session. $framework['session_name'] = "genericsession"; session_name($framework['session_name']); session_set_cookie_params(0); session_start(); in $_server i find this: [http_cookie] => phpsessid=uc2h858qkktji15g3qojom2104; genericsession=4dde6ufeepq21kiro2r931vui7 can tell me why there still phpsessid ? how rid of it? phpsessid comes browser cookie. you need reset cookies website , you'll see new cookie.

c++ - Visual Studio 2008 Error "copying contents file" in MFC project -

i inherited legacy mfc project upgraded visual studio 6. the project compiles in debug mode, when put in release mode, had error file not compiled. i removed file causing problem, command line trying copy legacy file folder bin folder. is there way set properties nothing copied? relatively new c++.

java - Netty channelAcquired is not getting called -

i'm using netty channel pool http client , in channelpoolhandler implementation channelacquired not getting called when channelpool.acquire() invoked. i'm using netty 4.0.32.final . here's how created chanelpool. followed simple example listed @ netty.io. if can explain i've done wrong or if there bug that'll helpful. thanks. eventloopgroup group = new nioeventloopgroup(); final bootstrap b = new bootstrap(); b.group(group).channel(niosocketchannel.class); abstractchannelpoolmap<inetsocketaddress, simplechannelpool> poolmap = new abstractchannelpoolmap<inetsocketaddress, simplechannelpool>() { @override protected simplechannelpool newpool(inetsocketaddress key) { return new simplechannelpool(b.remoteaddress(key), new httpclientpoolhandler()); } }; final simplechannelpool simplechannelpool = poolmap.get(new inetsocketaddress(uri.gethost(), uri.getport())); final future<channel> acquire = simplechannelpool.acquire(); ac

loops - Python script to continue running -

i new python programming. want code continue running , continue checking ip address. ` #!/usr/bin/env python import os hostname = "192.168.254.102" #example response = os.system("ping -c 1 " + hostname) and check response... if response == 0: print(hostname, 'is up!') os.system("sudo python ../aquarium/nightlight_on.py 1") else: print(hostname, 'is down!') ` basically, cant code check phone ip address when got home script turn on light. tested script , works if run in terminal need sudo python scriptname.py first thank you you use python schedule open source project this: #!/usr/bin/env python def job(): import os hostname = "192.168.254.102" #example response = os.system("ping -c 1 " + hostname) if response == 0: print(hostname, 'is up!') os.system("sudo python ../aquarium/nightlight_on.py 1") else: print(hostname, &

python - ImportError: No module named google.protobuf.text_format -

i can find text_format.py file inside folder /usr/local/lib/python2.7/dist-packages/google/protobuf/ . in python program,i have error importerror: no module named google.protobuf.text_format . set pythonpath , echo $pythonpath gives me /usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages/google/protobuf: why line from google.protobuf.text_format import merge in python program can't import google.protobuf.text_format just create blank file in folder /usr/local/lib/python2.7/dist-packages/google/protobuf/ name __init__.py run command , it: touch /usr/local/lib/python2.7/dist-packages/google/protobuf/__init__.py check if issues thereafter.

loops - JAVA How to return list of elements with amstrong numbers from interval [100; 999] -

i new in java , have got assigment armstrong numbers. created new class armstrongnumber.java initialized method website: http://www.programmingsimplified.com/java/source-code/java-program-armstrong-number now in class main method created method calling armstrongnumber class , have return armstrong number interval [100 till 999]. there stuck . public static void armtrongnumbs() { armstrongnumber returnobj = new armstrongnumber(); // here m calling class. int start = 100; int end = 999; for(int = start; i<= end; i++) { number = + number; returnobj.armstrong(number); } //returnobj.armstrong(); } how loop return armstrong numbers? edit: armstrongnumber class class armstrongnumber { public void armstrong(int number) { int n, sum = 0, temp, remainder, digits = 0; scanner in = new scanner(system.in); system.out.println("input number check if armstrong numb

foreach - tcl loop through multiple lists -

i have 2 lists i'd manipulate.. ( tcl newbie..). i'd associate these 2 lists , create third list data added. the data have: set aes {ae0 ae3 ae6 ae1v1 ae1v8} set c {c1 c2 c3 k1 k2} foreach $aes { foreach c $c { puts ${a}_$c } } the data you'd expect is: ae0_c1 ae0_c2 ae0_c3 ae0_k1 ae0_k2 .. .. what want append data in front of this. ae-to-c = ae0_c1 ae0_c2 ae0_c3 ae0_k1 ae0_k2 .. end . % set aes {ae0 ae3 ae6 ae1v1 ae1v8} ae0 ae3 ae6 ae1v1 ae1v8 % set c {c1 c2 c3 k1 k2} c1 c2 c3 k1 k2 % foreach $aes { foreach c $c { # saving 'result' variable lappend result ${a}_${c} } } % set data "some more here" more here % set result ae0_c1 ae0_c2 ae0_c3 ae0_k1 ae0_k2 ae3_c1 ae3_c2 ae3_c3 ae3_k1 ae3_k2 ae6_c1 ae6_c2 ae6_c3 ae6_k1 ae6_k2 ae1v1_c1 ae1v1_c2 ae1v1_c3 ae1v1_k1 ae1v1_k2 ae1v8_c1 ae1v8_c2 ae1v8_c3 ae1v8_k1 ae1v8_k2 % set result [linsert $result 0 $data] more here ae0_c1 ae0_c2 ae0_c3 ae0_k1 ae0_k2 ae3_c1

De-duplicating many-to-many relationships in MySQL lookup table -

i've inherited database includes lookup table find other patents related given patent. so looks ╔════╦═══════════╦════════════╗ ║ id ║ patent_id ║ related_id ║ ╠════╬═══════════╬════════════╣ ║ 1 ║ 1 ║ 2 ║ ║ 2 ║ 1 ║ 3 ║ ║ 3 ║ 2 ║ 1 ║ ║ 4 ║ 2 ║ 3 ║ ║ 5 ║ 3 ║ 2 ║ ╚════╩═══════════╩════════════╝ and want filter out reciprocal relationships. 1->2 , 2->1 same purposes want 1->2. i don't need make edit in table, need query returns list of unique relationships, , while i'm sure it's simple i've been banging head against keyboard far long. here clever query can try using. general strategy identify unwanted duplicate records , subtract them away entire set. select t.id, t.patent_id, t.related_id t left join ( select t1.patent_id t1_patent_id, t1.related_id t1_related_id t t1 left join t t2 on t1.related_id = t2.patent_id t1.patent_id = t2

javascript - Typescript strongly typed key value pair declaration -

i declare typescript interface such json structure: { 404: function() { alert( "page not found" ); }, 400 : function() {...} } the key number, , value function, know how declare interface in typescript such data constraints? indexer you can use numbers keys in javascript if use [] key access... let's start desired code... var x = { 404: function() { alert( "page not found" ); }, 400 : function() { alert("...");} }; x.404(); the last statement above (the call 404 function) error missing ; before statement , have use... x[404](); while still type inference in typescript ( var = x[404]; - a type () => void ) - won't give auto-completion. interface this: interface httpcodealerts { [index: number]: () => void; } with auto-completion normally in javascript , typescript recommended use safer names. simplistically, need start them letter: var x = { e_404: function() { ale

javascript - JS Function declarations should not be placed in block -

Image
i have wrapped 95% of 'parentctrl' (controller) within 'if' statement, prevents functions triggering if user isn't signed in , authorized. since doing keep getting following jshint error! error jshint 104:5 function declarations should not placed in block? if remove 'if' statement error goes away! advice on how fix helpful! if statement if($scope.user){} controller js var fittingcontrollers = angular.module('fittingcontrollers',[]); // 1. parent controller fittingcontrollers.controller('parentctrl', ['$scope', 'auth', '$localstorage', '$filter', '$timeout', 'notification', '$sce', '$state', function($scope, auth, $localstorage, $filter, $timeout, notification, $sce, $state) { //// setup authentication $scope.auth = auth; $scope.user = $scope.auth.$getauth(); //// facebook login $scope.facebooklogin = function() { var scope = {scope: 'emai

python - Parse answer in Quora that contains code -

i want parse post quora or generic post code. example : http://qr.ae/rkplrt through using selenium, python library, can html inside of post: h = html2text.html2text() content = ans.find_element_by_class_name('inline_editor_value') html_string = content.get_attribute('innerhtml') text = h.handle(html_string) print text i single chunk of text. in case of tables contain code, html2text inserts many \n , not handle indices of rows. so can see this: https://imageshack.com/i/paekbzt4p (this principal div contains table code.) https://imageshack.com/i/hlixfayop (the text html2text extracts) https://imageshack.com/i/hlhfbxvqp (instead, final print of text, problems index rows , \n s.) i had tried different settings, bypasse_tables, present in guide on github: ( https://github.com/alir3z4/html2text/blob/master/docs/usage.md#available-options ), had no success. could tell me how use html2text in case? you don't need use html2text @ all.

javascript - Different values from different arrays and append together beside one another in a table -

so, trying pull out 2 different array values arrays chanarrid & chanarrname via express(socket.io) & node.js. then once have display them in table on same row e:g <tr class="exe"> <td>sip/487-00000060</td> <td>0000000001</td> </tr> <tr class="exe"> <td>sip/488-00000060</td> <td>0000000002</td> </tr> then next set take new row, same following channel values. when add pull next 2 out without repeating itself. have had kind of success fall short, wrong positioning or duplicated values. i have working fine 1 value not both so: call extension 488: add channel name , value page array etc. works first 1 works fine seen @ top works grand following when add second pair of values: <tr class="exe" id="e

swift - dynamicType + cast to protocol leads to crash -

i have these classes: appdataprotocol.swift public protocol appdataprotocol{ var logoimagepath : string! {get} var logotitle : string? {get} var logosubtitle : string? {get} var categories : [mainmenuoption]! {get} static func contentelements(filter: contentfilter?) -> [contentelement]! } appdata.swift class appdata{ static var shareddata : appdataprotocol! init(){} } customappdata.swift [class conforms appdataprotocol] class customappdata: appdata, appdataprotocol { // fulfills appdataprotocol, omitted brevity } so these classes given, try dynamically set class variable so: appdata.shareddata = customappdata() and access so: // need class can call class function let appdata = appdata.shareddata.dynamictype as! appdataprotocol.type /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*crash!*/ let contentelements = appdata.contentelements(nil) by calling dynamictype on instance

javascript - NodeJS RegExp: how to access full list of results -

i'm having trouble accessing full list of results when .exec() regular expression in node. here code: var p = /(aaa)/g; var t = "someaaa textaaa toaaa testaaa aaagainst"; p.exec(t); > [ 'aaa', 'aaa', index: 4, input: 'someaaa textaaa toaaa testaaa aaagainst' ] i 2 results, no matter what. error on regexp itself? any appreciated! exec return first matched result. results use match var p = /(aaa)/g; var t = "someaaa textaaa toaaa testaaa aaagainst"; var matches = t.match(p); var p = /(aaa)/g, t = "someaaa textaaa toaaa testaaa aaagainst"; var matches = t.match(p); console.log(matches); use while exec while(match = p.exec(t)) console.log(match); var p = /(aaa)/g, t = "someaaa textaaa toaaa testaaa aaagainst"; var matches = []; while (match = p.exec(t)) { matches.push(match[0]); } console.log(matches); read: match vs exec in javascript

ios - UICollectionview userinteraction disable of a first cell ,disables few other cells also on scroll -

hi want disable first cell of uicollectionview when in editing mode.i did following code in cellforrow - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { maincollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:reuseidentifier forindexpath:indexpath]; cell.curveimageview.image = nil; if(indexpath.item == 0){ [cell.curveimageview setimage:[uiimage imagenamed:@"addcell"]]; cell.subtitletext.text = @"new cell"; if(isediting){ [cell setuserinteractionenabled:no]; [cell setalpha:0.5]; } else{ [cell setuserinteractionenabled:yes]; [cell setalpha:1]; } } else{ [cell.curveimageview setimage:[uiimage imagenamed:@"flowerimage"]]; cell.subtitletext.text = [nsstring stringwithformat:@"%ld%@",(long)indexpath.row,@"hello looki

recursion - return keyword is not working correctly in php -

i using piece of function check if file exist. if file exist changing name function checkfileexist($filename,$z,$ext,$folderwithfilename){ $tmpnam=""; if (file_exists($filename."_".$z.".".$ext)) { $z=$z+1; checkfileexist($filename,$z,$ext,$folderwithfilename); }else{ $tmpnam=$filename."_".$z; echo "in else <br> ".$filename."_".$z."<br>"; } return $tmpnam; } and calling function like $definename=checkfileexist($folderwithfilename."/".$invid,$z,$ext,$folderwithfilename); echo "new name ".$definename; but gives me output this in else 444_2015-10-27/444_3 new name you can see return not working correctly, doing wrong here? you should use return checkfileexist($filename,$z,$ext,$folderwithfilename); in first block return value recursively made calls. use clean version: function ch

php - Several entities having a one to many relation with one specific entity -

imagine scenario have companies , bank accounts , , customers . both companies , customers can have many bank accounts bank account can belong either 1 customer or 1 company. i'd know best way design such database not involve complicated queries or business logic when comes point need delete bank account database. one solution i've seen reference id's of bank accounts json string array on either companies or customers this: in customer or company ====================== id name bank_account 1 bob [2,3,4,5] it's not bad solution i'm wondering if there's better way this. nb: i'm building application using symfony 2.7.5 , therefore using doctrine orm library. one way handle have both companies , customers inherit common ancestor, users (take @ doctrine inheritance ). there 1 many relationship between users , bank accounts, easy implement , take care of dependencies.

ruby on rails - Mysql2::Error Access denied for user -

i have rails applications on mac , work fine. have installed new 1 uses mysql2 gem, starting server when visiting application getting access denied error. trying follow solution mysql2::error: access denied user 'test'@'localhost' database 'depot_test' logging in root user when trying create new database getting access denied error. changes in config / database.yml user name root. test user not exist in mysql. think in development environment should like: example development: adapter: mysql2 database: depot_test pool: 5 host: localhost encoding: utf8 username: test password: change username root or create test user privileges. remember rails uses environments(test, development, production u other). in case depot_development or name not equal environment. i hope helps you.

mysql - How to handle role based authorization in AngularJS? -

i creating web app satisfy 2 requirements users. note: new angularjs web development platform. front-end - 1: search functionality users can search specific documents , studies based on keyword search , filters. has been implemented using mysql fetching data , display using angularjs. front-end - 2: users have option create account on web app. purpose of account is: save search queries. if administrator associates each user specific role, users access options such modifying documents present in database uploading new documents , host of other pages. my question: how handle role based authorization in angularjs? not able figure out how create framework involves following functionalities: - users role associated them - prevent users accessing pages or functionalities not associated roles i have read on few articles tutorials every tutorial ends author saying role based authorization should handled on server side , understand why true. it great if can point me tutori

php - Fatal error: Can't use method return value in write context in empty() -

i getting following error why this? fatal error: can't use method return value in write context foreach ($transfer_nids $nid) { $wrapper = entity_metadata_wrapper('node', $nid); $result[] = array( 's_name' => empty($wrapper->field_s->value()->title) ? 'no data' : $wrapper->field_s->value()->title, 'r_name' => empty($wrapper->title->value()) ? 'no data' : $wrapper->title->value(), 'max' => empty($wrapper->field_max->value()) ? 'no data' : $wrapper->field_max->value(), ); } return ai_wrap_result($result, 'info'); } in (older versions) of php (<5.5) can't use empty() on return of function directly, compiler reasons. what need instead save result in intermediary variable , check if empty() instead, i.e., foreach ($transfer_nids $nid) { $wrapper = entity_metadata_wrapper('node', $nid)

javascript - Why is my submit form not being executed in my Meteor app? -

i've got html in meteor app: <template name="addperson"> . . . <input id="inputbuttonperson" name="inputbuttonperson" type="submit" value="save person"> </template> ...and javascript event handler form submit: template.addperson.events({'submit form': function(event, template) { alert('reached addperson.submit form'); console.log('reached addperson.submit form'); event.preventdefault(); var firstname = template.find('#firstname').value; . . . ...yet "submit" button not firing; see no alert, nor console log text, nor there record added mongodb after mash submit button (inputbuttonperson). why doesn't template's submit button event handler respond clicking of submit button? the information provided not sufficient. i'll try construct whole picture out of put question. let's pretend have template: <template

Attempting to detect a string in c++ -

i have code assignment here. stringstream fnamestream(fname); stringstream lnamestream(lname); if (fnamestream >> word) { fnamestream >> names[count]; count++; } else { fnamestream << "john"; fnamestream >> names[count]; count++; } the error no values @ when check array later. i'm not sure issue is. when entered in values before without if loop able values, when way nothing. apologies if incoherent or not clear (just let me know) i'm quite hungover. does work? bool isword(std::string s) { (int = 0; < s.length; ++i) { if (!::isalpha(s[i])) return false; } return true; } int main() { while (fnamestream >> word) { if (isword(word)) { names[count++] = word; } else { // placeholder } } }

passport.js - Passport: session serialization failed with serialization functions present -

i'm adding authentication node app using `feathers-passport following configuration: .configure(featherspassport({ secret: 'some-secret', store: new mongostore({db: 'demo-session'}), resave: false, saveuninitialized: false })) and configure passport: var localoptions = { usernamefield: 'email', passwordfield: 'password' }; passport.serializeuser(function(user, done) { done(null, user._id); }); passport.deserializeuser(function(id, done) { api.service('users').get(id, {}, done); }); passport .use(new localstrategy(localoptions, function(email, password, done){ api.service('users').authenticatelocal(email, password, done); })) to authenticate, have route setup: .post('/users/authenticate', function(request, response, next){ passport.authenticate('local', function(error, user){ //error comes null , user valid object request.login(user, func

javascript - Show hide div containing gridview between postback -

hi new using jquery , having doubt how implement scenario :- i have div element should hidden on page load, whenever click button going postback , populate grid present inside div , div should become visible after postback. <asp:button id="btngetgrid" runat="server" onclick="btngetgrid_click"> <div id="mydiv" runat="server"> <asp:gridview runat="server" id="grddisplay"/> </div> on .cs file protected void btngetgrid_click() { code populate grid } if anyways going full page postback can use visible property of div this:- <div id="mydiv" runat="server" visible="false"> <asp:gridview runat="server" id="grddisplay"/> </div> then, in code behind if data data source set visible property true:- protected void btngetgrid_click(object sender,eventargs e) { //code populate grid if(records count