Posts

Showing posts from January, 2014

When I use Entity Framework to find a model by using DbSet' s Find Method the VS will dump -

i want use dbset's find method search model has navigation attribute, times when application run code vs auto closed. there no such exceptions. want konw why. if query model doesn't have navigation attribute application run normal. let me show example: here 2 models. 1 named storage, other named storagearea. 1 storage associate many storageareas. query storage using following code 'storage s=efcontext.storage.find(1)' or 'storage s=efcontext.storage.firstordefault()'. once code run, vs auto close.

javascript - Save DZ.api response in variable -

using code below can console.log response in function(response) part, not in second console.log. how can extract string out of dz.api , child/any variable, when using dzsearch function? @injectable() export class deezerservice{ child:any; constructor(){ new dz.init({ appid : 'appid', channelurl : 'https://localhost:4200/src/channel.html' }); } dzsearch(){ console.log('testing dzsearch() init'); this.child = dz.api('/album/12720342/tracks', function(response){ console.log(response.data[0].title) return response.data[0].title; }); console.log(this.child); } }

c# - Adding role with UserManager -

i trying build simple method (just test how works), grant me (current user) new role (i have 1 role now, can simple query) public actionresult index() { using (var db = new mydbcontext()) { var manager = new usermanager<applicationuser>(new userstore<applicationuser>(db)); var id = user.identity.getuserid(); var role = db.aspnetroles.first(); manager.addtorole(id, role.name); } return view(); } i getting error: the entity type applicationuser not part of model current context. on manager.addtorole(id, role.name); line. novice asp.net don't know infrastructure, code mentioned lot of times (here, on stack) in questions user registration. by way, goal, have implement role system project database-first migration system, manager.addtorole(id, role.name); code add records in db? below stub (incomplete), shows adding newly created user role: dbcontext context = db; identityresult ...

reactjs - React Browserify Babel - Unexpected token error -

i'm attempting bundle dependencies using browserify via command line. command completes without error - can tell, loading page results in 'unexpected token <' error. here's command i'm using: browserify -t [ babelify --presets [ es2015 react ] ] main.js -o bundle.js main.js 'use strict'; var react = require('react'); var reactdom = require('react-dom'); var $ = require('jquery'); jsx: 'use strict'; var react = require('react'); var reactdom = require('react-dom'); var $ = require('jquery'); class sidenav extends react.component{ constructor(props) { super(props); this.state = {items: new array()}; } componentdidmount() { $.ajax({ url:"/json/sidenav.json", datatype: "json", cache: false, success: function(data) { this.setstate({items: data}); }.bind(this) }); } render() { var items = []; ...

javascript - Better approach for User Profile bar -

Image
i stuck small issue here. have used mark-up this: snippet $(function () { $(".more-options").click(function () { $(this).closest(".user-profile").toggleclass("open"); return false; }); }); /* reset */ * {margin: 0; padding: 0; list-style: none; font-size: 12pt;} {text-decoration: none;} /* main css */ .user-profile {border: 1px solid #999; overflow: hidden; position: relative; margin: 25px 0;} .user-profile .user-thumb {border: 1px solid #999; margin: 5px; padding: 3px; border-radius: 3px; float: left;} .user-profile p:first-child {margin: 3px 0 0;} .user-profile .more-options {position: absolute; right: 0; top: 0; height: 100%; width: 30px; background: center center no-repeat #ccc; text-indent: -99px; overflow: hidden;} .user-profile .more-options-list {position: absolute; right: 0; top: 70px; border: 1px solid #999; width: 100px; display: none; background-color: #fff;} .user-profile .more-options-list li, .user-p...

symfony sonata - Get the id of current element in Admin::configureListFields -

how current object id in admin::configurelistfields ? $this->getsubject() returns null thank you since there many objects in list, question makes no sense. i'll go ahead , assume in child admin. if case, think looking $this->getparent()->getsubject()->getid()

java - Retrofit generic type call method -

is possible create generic type of calls example @post("/service/") fun<t> startrequest(@body loginreq: any): call<t> then call this val request = api.startrequest<mymodel_1>(loginreq) when write , run method, says: java.lang.illegalargumentexception: method return type must not include type variable or wildcard: retrofit2.call<t> try annotate function @jvmsuppresswildcards

Ruby on rails and JSON to create Select form -

this question has answer here: rails select json array 1 answer i want create form : <select> <option> </select> with ruby on rails, countries (and there lot of countries in world haha), don't want write on view, want put json file countries, , theme in option items ( each method maybe ) i don't know have put json file in rails app , how call in view, does me ? the easiest location put json file in same directory controllers -- although doing kind of thing repeatedly make mess out of controllers folder. once you've done can read controller this: file = file.read('./countries.json') countries = json.parse(file) and map countries data type options_for_select expects. once have working, i'd recommend making helper knows how read json file, cache it's data, , return it. store json file in same dir...

c++ - What's the difference between char str[] and char* str? -

this question has answer here: what difference between char s[] , char *s? 12 answers difference between [square brackets] , *asterisk 5 answers difference between char* , char[] 6 answers i have code , has problem. #include <iostream> #include <stdio.h> using namespace std; void main() { char* str="hello_world"; cout<<str<<endl; str[3]='\0'; cout<<str<<endl; } but if change char* str char str[] . works fine.why? when declare char str[] declaring array of chars (which accessible both read , written), , array initialized sequence of characters i.e. "this test string" copied elements in array. when declare char*...

how to extract multi level dictionary keys/values in python -

there 2 level dictionary in python: for instance here: index[term][id] = n how term , n when id = 3 ? or perfect if returns in form result[id] = [term, n] iterate on nested dict , create new dict map values in desired format. can create custom function like: def get_tuple_from_value(my_dict): new_dict = {} term, nested_dict in my_dict.items(): id, n in nested_dict.items(): new_dict[id] = [term, n] return new_dict or, simple dict comprehension like: {i: [t, n] t, nd in d.items() i, n in nd.items()} where d holding dictionary.

css - Manage nesting in LESS -

i want like .classa, .classb, .classc, .classd, .classe { color: white; } .classa .classi, .classb .classi, classc .classi { background: red; } is possible like .classa, .classb, .classc { color: white; .classi { background: red; } } class d , e shouldn't geht class i. hopefully know, mean for case shouldn't use .classd , .classe @ top level because nested selector doesn't apply of them. you should use .classa, .classb, .classc , use :extend other two. .classa, .classb, .classc { color: white; .classi { background: red; } } .classd, .classe { &:extend(.classa); } when compiled result in following css: .classa, .classb, .classc, .classd, .classe { color: white; } .classa .classi, .classb .classi, .classc .classi { background: red; }

javascript - Avoid popup block with attached event listener -

i've got 10 buttons of class "servicebutton" contain custom attribute called "about". this: <li> <button type="button" class="servicebutton servicebutton-red" about="http://blabla">identity service</button> </li> <li> <button type="button" class="servicebutton servicebutton-red" about="http://secondlink,etc">vpn</button> </li> i've got javascript on page loops through buttons of class , attaches listener them going value of attribute , open new window that. (i trying make site work both on mobile/touch events , desktop/click events). var classname = document.getelementsbyclassname("servicebutton"); var open = function() { var attribute = this.getattribute("about"); alert("start"); var win = window.open(attribute, '_blank'); win.focus(); alert("stop"); }; (var = 0; ...

osx - Mount 'pwd' in swarm service using Docker for Mac -

i have followed guide set swarm cluster in docker mac: https://medium.com/@alexeiled/docker-swarm-cluster-with-docker-in-docker-on-macos-bdbb97d6bb07#.2x5gqgrkq all seems work correctly , able see cluster. $ docker node ls id hostname status availability manager status 3ez478atbfrcwb66u892ccbpx worker-2 ready active 7qfb87e9n54q3at9enzgeeko1 worker-3 ready active cnr8tyaf1qqgkpjqnn4wmnb1e * moby ready active leader eyksqiw6ewfks7t8fr48rppia worker-1 ready active now want create docker registry inside swarm. the following fails: $ docker service create --name registry -p 5000:5000 \ --mount "type=bind,source=$pwd,target=/var/lib/registry" \ --reserve-memory 100m registry with $ docker service ps registry id name image node desired state current state error 2xflgt6jlqlbpgdjvfzbgbsbb registry.1 registry worker-1 ready re...

How to get event name at TestTrack calculated field? -

we want find event name of event item @ testtrack options "name" or "eventname" , other variants of not returning values. does know what's field name? item.events.at(0).fieldvalue(?????); //it asks "field name" thanks in advance, max. the fieldvalue function allows obtain value of field, not name of field/event. list of valid field values displayed when press "insert field" button on edit formula dialog. not possible obtain event name part of calculated custom field value.

sql - Automatically update people's ages in sqlite -

how automatically update people's age in sqlite database? have put dateofbirth column, , created column called today supposed display current date putting set today = date('now') function. made created age column calculates age subtracting birth dates current date (today-date of birth), seems job. but, problem today isn't automatically updated, do? in advance, cheers how automatically update people's age in sqlite database? you don't need since age computed column , while displaying data can calculate age , show accordingly. since have dob stored need teh difference currentday - dob age. use update statement update today column update your_table set today = date('now')

MySQL display rows from 2 tables with most recent data in table 2 -

i have 2 tables use, want display result depending on recent data in table2 owner in table1 = 'ownera': table1 : # id, name, owner ________________________________________________ 19782, device1, ownera 19783, device8, ownerb 19784, device2, ownera 19785, device3, ownera table2 : # nasid, sim, timestamp _______________________________________ 19782, 0, 2015-12-08 15:34:27 19782, 0, 2015-12-08 15:34:33 19772, 0, 2015-12-08 15:34:39 19752, 0, 2015-12-08 15:34:45 19783, 0, 2015-12-08 15:34:50 19712, 0, 2015-12-08 15:34:56 19783, 0, 2015-12-08 15:35:02 19782, 0, 2015-12-08 15:35:07 19784, 0, 2015-12-08 15:35:13 19784, 0, 2015-12-08 15:35:20 what want in output : # name, nasid, sim, timestamp _______________________________________ device8, 19783, 0, 2015-12-08 15:35:02 device1, 19782, 0, 2015-12-08 15:35:07 device2, 19784, 0, 2015-12-08 15:35:20 this tried, : select nasid, sim, max(timestamp) table1...

web - how do I put my python into my website -

how put code: import matplotlib.pyplot plt def fib(nooftimes): repeat=nooftimes a=1 print(a) b=1 print(b) r="ratio between" print(r,a/b) odd=[1] even=[] dtg=[1] fack=1 counter1=1 counter2=0 counter3=0 while nooftimes>0: c=a+b print(c) e=c/b counter1=counter1+1 if(counter1%2==0): even.append(e) if(counter1%2==1): odd.append(e) dtg.append(e) print(r,e) a=b+c f=a/c counter1=counter1+1 if(counter1%2==0): even.append(f) if(counter1%2==1): odd.append(f) dtg.append(f) print(a) print(r,f) b=c+a g=b/a counter1=counter1+1 if(counter1%2==0): even.append(e) if(counter1%2==1): odd.append(e) dtg.append(g) print(b) print(r,g) nooftimes=nooftimes-1 els...

java - ListView.addHeaderView() doesn't set parent -

i trying check in test if view added listview after calling listview.addheaderview(view) , view.getparent() seems null . intended behaviour? shouldn't addheaderview() set parent on added view ?

Post multiple lines with PHP -

Image
when presses submit button line added code: <html> <head> </head> <body> <form method ="post" action="" name ="formpje"> line<input type="text" name="name"><br> <input type="submit" name="submit"><br> </form> <?php $post = $_post['name']; echo $post; ?> </body> </html> the result: when add new line current 1 gets changed newest one. want stay add new one. heres like: try this, each time submit form place name session , print out bellow. <?php session_start(); if( isset( $_post[ 'submit' ] ) ) { $_session[ 'submissions' ][] = $_post[ 'name' ]; } ?> <form method ="post" action="" name ="formpje"> line<input type="text" name="name"><br> <input type=...

garbage collection - In R Studio I am getting Java Out of Memory (for RWeka) -

ok, looks familiar java world, where/how can allow more memory rweka in rstudio. error in .jcall("rwekainterfaces", "[s", "tokenize", .jcast(tokenizer, : java.lang.outofmemoryerror: gc overhead limit exceeded not sure how r interfaces java , if can allow more heap space. thanks in advance gary

hyperlink - Dot is missed in email link -

we send email our customers , have link this http://www.my-site.no/uploads/171116-091639-19.jpg the problem of dots missed, example like this: http://www.my-site.no/uploads/171116-091639-19jpg http://www.my-siteno/uploads/171116-091639-19.jpg we use sendgrid send messages , use link tracking feature there does meet issue? or can avoid that? can ensure links correct before send email? happens when send test yourself? i've worked various esps , have never had issue, link tracking should append parameter or create redirect link.

javascript - Two types of for loop - how come only one of them is working? -

this question has answer here: why using “for…in” array iteration bad idea? 22 answers i have following code in javascript: var controller = { initapp: function(){ var getcartdata = $.ajax({ url: '/cart' }), getcategorydata = $.ajax({ url: '/categories' }), getsupplierdata = $.ajax({ url: '/suppliers'}), getprodcuts = $.ajax({url: '/products'}); // main controller logic starts when data loaded in $.when(getcartdata, getcategorydata, getsupplierdata, getprodcuts ).done( function( cart, categories, suppliers, products ) { var model = new model(cart, categories, suppliers, json.parse(products[0])); console.log(model.products); console.log(typeof model.products); for(var = 0; i<model.products.length; i++){ console.log(model.products[i]); } ...

Teamcity hang on agent side git checkout -

teamcity build working "on server" vcs checkout mode. need have access .git folder. after switching checkout mode "on agent", build froze on checkout. repository doesn't contain big files, checkout 10 sec. authentication via login/password. reconfiguring vcs root didn't help. teamcity version: 9.1.7 output following: [vcs root: rootname] [c:\buildagent\system\git\git-3b190d20.git]: "c:\program files (x86)\git\bin\git.exe" remote add origin https://***@bitbucket.org/***.git [16:50:57][vcs root: rootname] cannot stop checkout on agent rootname. waiting operation finish. [16:50:47][vcs root: rootname] [c:\buildagent\system\git\git-3b190d20.git]: "c:\program files (x86)\git\bin\git.exe" -c core.askpass=c:\buildagent\temp\buildtmp\pass8866188247228629665.bat fetch --progress origin +refs/heads/master:refs/heads/master (30m) [17:20:47][[c:\buildagent\system\git\git-3b190d20.git]: "c:\program files (x86)\git\bin\git.exe"...

Matlab: Number of files in a folder excluding the file names information -

i looking way count number of files in folder path without caring names of files. dir function extracts names unnecessary specific application. since i'm looking @ 100 folders , each folder includes 35000 files in it, time consuming if use "dir" function. any appreciated. do somedir = 'c:\users\you\somepath\' //whatever directory want [status,cmdout] = system(['dir ' somedir '*.* /s']) and can parse out number of files cmdout this should faster because running system command lose overhead of matlab.

cloud - Getting gpg error while installing Apache CloudStack on ubuntu14.04 -

while installing apache cloudstack getting gpg error i.e. no_pubkey bbfcfe5386c278e3 . $ echo "deb http://cloudstack.apt-get.eu/ubuntu precise 4.3" > /etc/apt/sources.list.d/cloudstack.list $ wget -o - http://cloudstack.apt-get.eu/release.asc | sudo apt-key add - $ apt-get update error: fetched 4,936 kb in 26s (185 kb/s) reading package lists... done w: gpg error: http://extras.ubuntu.com trusty release: following signatures couldn't verified because public key not available: no_pubkey 16126d3a3e5c1192 w: gpg error: http://cloudstack.apt-get.eu precise release: following signatures couldn't verified because public key not available: no_pubkey bbfcfe5386c278e3 how resolve gpg error tried add using following commands: $ sudo gpg --keyserver pgpkeys.mit.edu --recv-key bbfcfe5386c278e3 $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys bbfcfe5386c278e3 but nothings works...

javascript - go on first page not working -

i'm trying create button go on first history page don't know why doesn't code work.this code: function firstpg() { var startpt = '-' + window.history.length; window.history.go(startpt); } <!doctype html> <html> <head> </head> <body> <button onclick="firstpg()">go first</button> </body> </html> what problem? the history includes current page need decrement 1 length in order go first page. var startpt = '-' + ( window.history.length - 1) ; or var startpt = -(window.history.length - 1) ;

How to perform a mean comparison in R, with a treatment factor, that have 3 levels? -

can please me understand how perform comparison of means in r? treatment factor has 3 levels , want compare mean of yield @ each level of treatment factor significance how write argument make r understand should compare mean.yield when treatment=75 (is factor, not numeric) mean.yield when treatment=100 , when treatment=125? you can all-pairwise comparison using multcomp package. library(multcomp) mydata <- data.frame(treatment=c("75", "100", "125","75", "100", "125","75", "100", "125"), mean.yield=c(10,20,30,20,25,27,3,15,12)) immer.aov <- aov(mean.yield ~ treatment, data = mydata) immer.mc <- glht(immer.aov, linfct = mcp(treatment = "tukey")) summary(immer.mc) simultaneous tests general linear hypotheses multiple comparisons of means: tukey contrasts fit: aov(formula = mean.yield ~ treatment, data = mydata) linear hypo...

Use a single VM with Vagrant to host Docker Containers across multiple projects -

i have 2 separate projects/src/code repos, using vagrant run application in docker containers. i using vagrant centos7 host vm host docker containers ( https://www.vagrantup.com/docs/docker/basics.html ). using duplicate copy of centos7 vm vagrantfile ( vagranfile.host ) in each project. - proj1/ -- vagrantfile -- vagrantfile.host - proj2/ -- vagrantfile -- vagrantfile.host each vagrantfile points vagrantfile.host spin centos vm host docker containers. the difference (effectively question) between 2 projects vagrantfile in proj1 points different docker image 1 in proj2 . when vagrant up in each project folder, each 1 create's it's own centos7 vm instantiation, end running 2 separate virtualbox vms. is there way change 1 or both of vagrantfile files end spinning single vm, , containers both run in same virtualbox vm? got work. not quite way wanted, documenting finds question later. point both docker vagrantfile's same vagrantfile.host linux par...

Java 8 Lambdas Pass Function or Variable as a Parameter -

i new java 8 lambdas. have code starts with: stringbuilder lemma = new stringbuilder("("); and 2 pieces of codes. first one: lemma.append("("); (string dt : dts) { lemma.append("label1:").append(labellist.getlabel1(dt)).append(operator); } lemma.delete(lemma.length() - operator.length(), lemma.length()); lemma.append(")"); second one: lemma.append("("); (string mt : mts) { lemma.append("label2:").append(mt).append(operator); } lemma.delete(lemma.length() - operator.length(), lemma.length()); lemma.append(")"); how can make function covers 2 pieces of code accepts arguments: list<string> (which -dts- or -mts-) and string (which -"label1:"- or -"label2:"-) and func() (which -labellist.getlabel1(dt)- or -mt-) is possible such thing java 8 lambdas? you write this public static <t> string dump(list<t> list, string desc, function...

javascript - How to spy a function with Sinon.js that is in the same js file as the function under test -

i have problem sinon.js while trying spy function in same javascript file function want test. furthermore assert spied function called once. unfortunately test fails. interesting thing is, if spied function in javascript file function under test works ! here code: mock_test.js: var sinon = require('sinon') var 1 = require('./one.js') var 2 = require('./two.js') describe('spy ', function () { it('spy method', sinon.test(function (done) { var another_method_spy = sinon.spy(one, 'another_method') one.some_method() sinon.assert.calledonce(another_method_spy) done() })) it('spy second method', sinon.test(function (done) { var second_method = sinon.spy(two, 'second') one.call_second() sinon.assert.calledonce(second_method) done() })) }) one.js: var 2 = require('./two.js') var some_method = function(){ console.log(...

Why must my C++ function have different pointer arguments? -

i made c function pointer-passing gives right result if pointers different. instance: void dotransform(point *pout, const point *pin, transform mat) { pout->x = mat[0][0] * pin->x + mat[1][0] * pin->y + mat[2][0] * pin->z + mat[3][0] * 1.0; pout->y = mat[0][1] * pin->x + mat[1][1] * pin->y + mat[2][1] * pin->z + mat[3][1] * 1.0; pout->z = mat[0][2] * pin->x + mat[1][2] * pin->y + mat[2][2] * pin->z + mat[3][2] * 1.0; } dotransform() supposed called this: //... transform toworldmat; point local; point world; dotransform(&world, &local, toworldmat ); the problem is, in team called this: point p; dotransform(&p, &p, toworldmat); it took me 1 week figure out why final output of program changed. what best style declare kind of function, avoid case? wrong write that? seeing you're passing transform object directly (though not const& : should instead) there reason can't write code so: po...

How to prevent python script from exiting when it hits [Errno 32] Broken pipe -

i have python script , i'm using while loop loop forever, script looks this: #!/usr/bin/python import socket,select,time,base64,os,sys,re,datetime def on_outbounddata(self): print "on_outbounddata" netdata = self.netdata if netdata.find('http/1.') ==0: ms = re.search(r"\^s(\d+)\^", payload) if ms: print "sleeping " + ms.group(1) + "ms" dec = int(ms.group(1)) / float(1000) time.sleep(dec) print self.request[self.s] try: self.channel_[self.s].send(self.request[self.s]) self.request[self.s]='' except valueerror: print "self.s not in list (on_outbounddata)" pass netdata='http/1.1 200 connection established\r\n\r\n' try: self.channel[self.s].send(netdata...

javascript - Formatting a number to have commas at every 1000 factor -

i need format number 1234567 1,234,567 don't know how this. tried using currency pipe of typescript gives usd or $ in front of number. want remove , format number in way 1,234,567 . how can this? simply use number pipe instead. to give example: {{ '1234567' | number:'.2'}} will produce output 1,234,567

embedded sql - embedding SQL in visual studio C++ code -

can tell me (showing sample code) how have embedded ms sql server sql queries in visual studio win32 console application c++ program (header files, keywords, etc.)? i've set c++ project source file , standard exec sql notation doesn't work. did connect database through server explorer window. far, i've had no luck. want little sample show class. here's basic code i've tried: // db test program #include <iostream> using namespace std; void main() { int customer; double balance; customer = 10013; exec sql select cus_balance :balance customer cus_number = :customer; cout << "customer " << customer << " has balance of " << balance; cin.ignore(); // hold screen }

r - Radio Buttons on Shiny Datatable, with data.frame / data.table -

pretty copy paste this example (which, assume, supersedes of other answers on so) except i'm trying use data.table instead of matrix. i'm unable figure out why isn't working. library(shiny) library(dt) shinyapp( ui = fluidpage( title = 'radio buttons in table', dt::datatableoutput('foo'), verbatimtextoutput('sel') ), server = function(input, output, session) { m = data.table( month1 = month.abb, = '1', b = '2', c = '3', qwe = runif(12) ) m[, := sprintf( '<input type="radio" name="%s" value="%s"/>', month1, m[, a] )] m[, b := sprintf( '<input type="radio" name="%s" value="%s"/>', month1, m[, b] )] m[, c := sprintf( '<input type="radio" name="%s" value="%s"/>', ...

python - Convert list of NDarrays to dataframe -

i'm trying convert list nd arrays dataframe in order isomap on it. doesn't convert. how convert in such can isomap on it? #creation , filling of list samples* samples = list() in range(72): img =misc.imread('datasets/aloi/32/32_r'+str(i*5)+'.png' ) samples.append(img) ... df = pd.dataframe(samples) #this doesn't work gives #valueerror: must pass 2-d input* ... iso = manifold.isomap(n_neighbors=4, n_components=3) iso.fit(df) #the end goal of dataframe that obvious, isn't it? images 2d data, rows , columns. stacking them in list causes gain third dimension. dataframes nature 2d. hence error. you have 2 possible fixes: create panel . wp = pd.panel.from_dict(zip(samples, [str(i*5) in range(72)])) stack arrays 1 on top of other, or side side: # on top of another: df = pd.concat([pd.dataframe(sample) sample in samples], axis=0, keys=[str(i*5) in range(72)]) # side side: d...

c# - ASP.Net , SQL Server 2016, AnqularJS Material -

i have been working on creating hr management/employee portal company workplace. while have been able user interface , simple coding completed have moved unknown terrain me. as title says using asp.net c# in the code behind sql being data base , angularjs material of user interface , body elements. brings me first item of issue. employee portal has "time off" tab. tab allows user see there past, current, , future requests. has section allows them submit new request. once employee inputs data the request form , clicks submit dialog appears explaining company policy. once read employee has option click cancel or submit. struggling. having hard time figuring out how when employee clicks "submit" dialog trigger actual submission through asp code behind. so thought process follows angularjs dialog "submit" ------> hidden asp:button ------> code behind sends information sql ----> page refreshes table show new request. i have been able label ...

angular - How to get data from Route or ActivatedRoute when subscribing to router.events.subscribe in Angular2? -

i'm trying data router whenever route changes i'm not having success. here set asdf property @ngmodule({ bootstrap: [appcomponent], declarations: [ appcomponent, logincomponent, dashboardcomponent, overviewcomponent, ], imports: [ browsermodule, formsmodule, routermodule.forroot([ { path: '', pathmatch: 'full', redirectto: '' }, { component: logincomponent, path: 'login' }, { children: [ { path: '', pathmatch: 'full', redirectto: 'overview', data: { asdf: 'hello' } }, { component: overviewcomponent, path: 'overview', data: { asdf: 'hello' } }, ], component: dashboardcomponent, path: '', }, ]), ], }) export class appmodule { } and here can url router when route changes asdf undefined :( import { component, ondestroy, oninit } '@angular/core'; import { router } ...

php - My PDO Statement doesn't work -

this php sql statement , it's returning false while var dumping $password_md5 = md5($_get['password']); $sql = $dbh->prepare('insert users(full_name, e_mail, username, password, password_plain) values (:fullname, :email, :username, :password, :password_plain)'); $result = $sql->execute(array( ':fullname' => $_get['fullname'], ':email' => $_get['email'], ':username' => $_get['username'], ':password' => $password_md5, ':password_plain' => $_get['password'])); if pdo statement returns false , means query failed. have set pdo in proper error reporting mode aware of error. put line in code right after connect $dbh->setattribute( pdo::attr_errmode, pdo::errmode_exception ); after getting error message, have read , comprehend it. sounds obvious, learners ove...

Remove Nth Node From End of List Runtime Error -

given linked list: 1->2->3->4->5, , n = 2. after removing second node end, linked list becomes 1->2->3->5. hi, run code in computer leetcode says runtime error . doing wrong in memory? ran same case leetcode said wrong. believe checked corner cases. input [1,2] output [2] /** * definition singly-linked list. * struct listnode { * int val; * listnode *next; * listnode(int x) : val(x), next(null) {} * }; */ class solution { public: listnode* removenthfromend(listnode* head, int n) { if(!head) return head; listnode* tmp =head; int size =1; while(tmp->next){ tmp=tmp->next; size++; } if(n>size) return head; listnode* prev = head; //delete head if (n==size){ if(prev->next){ prev=prev->next; delete head; head = prev; return head; } else { ...

c++ - function delete dont work in the second time i activate it -

i have function contains delete in it: void vector::reserve(int n){ //if there need increase size of vector if (n > _size){ int* tamparr; //check new size of array should _capacity = n + (n - _capacity) % _resizefactor; tamparr = new int[_capacity]; //put in new array element have in curr array (int = 0; < _size; i++){ tamparr[i] = _elements[i]; } delete[] _elements; _elements = null;//this //put new array in _element _elements = new int[n]; (int = 0; < _size; i++){ _elements[i] = tamparr[i]; } delete[] tamparr; } } the class field is: private: //fields int* _elements; int _capacity; //total memory allocated int _size; //size of vector access int _resizefactor; // how many cells add when need reallocate for reason first time use function doesn't show errors , work perfect in second time stops in...

vb.net - Validate if any changes were made in TabPage -

so i'm wondering if can give me idea how something. have tabcontrol in application - load page - tabpage1 - 25-30 fields. on loading data - run loop save each control value .tag. have function called isdirty() checks each control's ctr.tag.tostring <> ctr.text. i'm having hard time figuring out how build quick handler check controls on form. tried using tagpage1.validating, doesn't anything. my isdirty() function looks this... private function isdirty() boolean isdirty = false each ctr control in tabpage1.controls if typeof ctr textbox , ctr.enabled = true if ctr.tag.tostring <> ctr.text isdirty = true end if end if 'more if statements comboboxes , such next end function i'm hoping able plug function in somewhere , call on if isdirty() msgbox "you have made change form" end if do have call on each control's selection changed? ...

php - Fetching country from IP using wordpress plugin GeoIP detection? -

i've installed plugin: https://tah.wordpress.org/plugins/geoip-detect/ the plugin seems work fine when test "lookup" within plugin, returns geo-information. when try implement code within 1 of wordpress pages doesn't work. $ip = $_server['remote_addr']; $userinfo = geoip_detect2_get_info_from_current_ip($ip); echo $userinfo->country->name; i'm calling function native woocommerce page single-products shown. fucntion returns nothing. have include more call function geoip_detect2_get_info_from_current_ip() ? i tried: <?php echo do_shortcode("[geoip_detect2 property='country']"); ?> it doesn't return either. i'm doing editing within godaddy's code editing tool, might missing errors. i have try implement geo ip in wordpress site http://iradiofind.com/stations/ . using http://www.geoplugin.net country info. got ip address using function function get_client_ip() { $ipaddress = ''; ...

scala - List processing in DStream -

i have of list of words dstream. eg: list(car, speed, accident, speed, bad). want form bi grams list. have rdds facing issues dstreams. using foreachrdd function. below have - am trying print contents of rdd after transformation. def printrdd(rddstring: rdd[string]) ={ val z = rddstring.map( y => y.tostring.split(",").filter(_.nonempty). map( y => y.replaceall("""\w""", "").tolowercase) .filter(_.nonempty) .sliding(2).filter(_.size == 2).map{ case array(a, b) => ((a, b), 1) }) .flatmap(x => x) println(z) } val x = lines.map(plaintexttolemmas(_, stopwords)) val words = x.flatmap( y=> y.tostring.split(",")) words.foreachrdd( rdd => printrdd(rdd)) is there way show contents after transformation function printrdd. if use println(z) inside print definition, returns mappartitionsrdd[18] @ flatmap. using kafka spark streaming read inputs, words value on con...