Posts

Showing posts from March, 2015

laravel - creating different type of users -

im creating app haves 2 type of users (employers , candidates). in app have 4 tables (users, candidates, employers, account_types), users table : - email, - name, - surname, - password - account_type candidates table: - id; - user_id - other columns employers table: - id; - user_id - other columns accounts_type: -id; - title so have 2 different routes each type of user, if candidate "domain.com/candidate/register" , if employer "domain.com/employer/register". im looking @ ready code laravel im kinda strugglying right way it. im on authcontroller looking @ function create, need create 1 more record, beside record users table, need example if employer, create record , insert in employers table , vice versa if candidate. need first check type of account being passed, thought in using hidden field in registration form indentify in create function type of user , create conditionals in create function, dont think approach. can guide me in best way in passi...

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum ...

layout - Syncronize ui file with cpp on Qt -

i writing simple app using qt. project contains ui file because easier change layouts. well, edit cpp file add new. ui file not show it. for example, in cpp use qwidget *logo = new qwidget(this); logo->setstylesheet("background-color: red"); logo->setgeometry(qrect(50,50,500,110)); but when open ui file within design mode, new red rectangle not there. how update layout on ui file?

mysql - Failure To Execute SQL Subquery With Join -

please can tell me i'm not doing right. here query want execute, nothing happens when run command. i'm new sql pardon mistake, if any. select t.*, count(distinct t.subjects) subjectenrollment, u.urefnumber, u.uresidence ( select r.*, @currank := if( @prevrank = finalscore, @currank, @incrank ) position, @incrank := @incrank + 1, @prevrank = finalscore studentsreports r, ( select @currank := 0, @prevrank = null, @incrank := 1 ) c order finalscore asc ) t left join studentstbl u on t.studref = u.urefnumber t.author = :staff , t.studentname = :student , t.academicyr = :year , t.academicterm = :term , t.program = :program , t.classes = :level , t.subjects = :subject; as can seen code, i'm trying fetch students records, , include column position in each subject, number of students offering each subject. more over, want include each student's residential status, in different table. at point, want add accumulated raw scores...

c# - Look for words in a textbox text and display in data grid -

i need program windows form in c#, needs textbox , button. in textbox have type programming instruction example: for(i=0;i<10;i++) then click button , in datagrid should displayed this: for - cycle ( - agrupation i - variable = - asignation and on how can identify parts of text? i've tried foreach char i'm messed :( please here solution can use cobbled together. highly recommend familiarise regular expressions: https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx and here nice tester used: http://regexstorm.net/tester using system.text.regularexpressions; string input = "for(i=0;i<10;i++)"; string pattern = @"^(\w+)(\w)(\w)(\w).*$"; matchcollection matches = regex.matches(input, pattern); string cycle = matches[0].groups[1].value; string agrupation = matches[0].groups[2].value; string variable = matches[0].groups[3].value; string asignation = matches[0].gr...

r - Frequencies data table multiple columns -

i have data table this require(data.table) dt <- data.table(a= c("a","a","b","b","b"), b= c("a","a","c","c","e"), c=c("d","d","b","b","b")) i want count frequencies all columns . know how 1 one, want in 1 instruction because data has lot of columns. result must one: dt[,a1:=.n, = c("a")] dt[,a2:=.n, = c("b")] dt[,a3:=.n, = c("c")] require(data.table) dt <- data.table(a= c("a","a","b","b","b"), b= c("a","a","c","c","e"), c=c("d","d","b","b","b")) #dt # b c #1: a d #2: a d #3: b c b #4: b c b #5: b e b l=lapply(seq_along(colnames(dt)), function(i) dt[,eval(colnames(dt)[i]),with=f][...

c# - Store Select Results In DataTable -

i querying sql server table , storing result in data table, needing pass values datatable parameter second query. results of query stored in second datatable. syntax can not right. have, have multiple compile errors. can assist me syntax , proper syntax? sql.datatable datatable1 = new sql.datatable(); string constring = @"server=hometest;database=testing;integrated security=sspi;"; stringbuilder query = new stringbuilder(); sql.datatable datatablesupervisors = new sql.datatable(); query.append("select top 1 supervisorid activesupervisors"); using (sqlconnection cn = new sqlconnection(constring)) { using (sqldataadapter da = new sqldataadapter(query.tostring(), cn)) da.fill(datatablesupervisors); } foreach (datarow row in datatablesupervisors.rows) { using (sqlconnection conn = new sqlconnection("server=hometest;database=testing;integrated security=sspi;") { sqlcommand command = new sqlcommand(); command.commandtext = "s...

extends - Java: Break-up "implement" into two+ classes -

i've got plugin architecture java application i'm working with. all examples show: public class specialname implements baseextenderclass, classb, classc { //stuff } where "specialname" name have name class in order recognized plugin, , baseextenderclass, classb, classc different api functionality extended in 1 class operations. each 1 has own methods must implemented. what i'm wondering if there way in java can put classb , classc in separate files baseextenderclass specialname, , still have behave intensive purposes if original code listed above. the code lot neater , more organized since plugin i'm writing extend 6-8 of available api interfaces. if not, can have 1 massive file... doesn't feel right way things. are trying split interface definitions or implementation code them ? i assuming saying don't want put implementation code 3 interfaces in same class rather need separate 2 or more files (classes) because comm...

c# - How to check dictionary if string value exist for conditional comparison -

if want use dictionary given values conditional comparison in if-statement pass implementation avoid if-statement listing of values , dictionary. how check dictionary, contains 400 strings, if string value exist: dictionary<int, string> set1 = new dictionary<int, string>() {{ 1, "string1" }, { 2, "string2" } ... }; // 400 values so seems way wrong: string str = "string1"; if (set1.containskey(str) == true) { console.writeline("contains"); } else { console.writeline("does not contains"); } to result further condition containsvalue(value); string str = "string1"; if (set1.containsvalue(str) == true) { console.writeline("contains"); } else { console.writeline("does not contains"); } or linq: using system.linq; ... string str = "string1"; if (set1.values.any(x => x == ...

android - App bar items collapsing with status bar when scrolled.And app not being scrolled on scrolling list items -

Image
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.chandan.halo.mainactivity" > <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingtop="@dimen/appbar_padding_top" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent"...

(Python) How to access/use variable from different method in class? -

here's code class circle(object): def __init__(self, radius = 1): self_radius = radius def __str__(self): return "circle radius {}".format(self_radius) i took teacher's slide, took integer (radius) when called (a = circle(25) -for example) return --circle radius 25-- when print it the problem when that, instead getting it, got error saying self_radius not defined (in str method), question how use variable in different method it's origin? thank you qualify instance attributes self. , not self_ : class circle(object): def __init__(self, radius = 1): self.radius = radius def __str__(self): return "circle radius {}".format(self.radius) if name variable self_radius , become local variable; not accessible method.

android - Activity context null pointer error when checking for permissions at runtime -

i trying ensure on first run of alarm clock app permission read external storage newer devices. i keep getting null pointer error context. on line: if (contextcompat.checkselfpermission(context, manifest.permission.read_external_storage) != packagemanager.permission_granted) and getting error: caused by: java.lang.nullpointerexception: attempt invoke virtual method 'int android.content.context.checkpermission(java.lang.string, int, int)' on null object reference i tried (activity) context, getparent(), this.context, getapplicationcontext , can see below context. of them had same result. thanks in advance help. this whole code: public class mainactivity extends appcompatactivity implements fragmentaddalarms.ontabchangedlistener { public static final int my_permissions_request_read_external_storage = 123; context context; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layou...

SQL query to insert select from two tables to one table with condition -

i have table a(primarykey, maximum) , b(primarykey, name, value, owner). b's owner refers a's primarykey. table primarykey maximum 1 11 2 22 table b primarykey name value owner 1 name1 11 1 2 name2 12 1 3 name3 13 1 4 name4 14 1 5 name1 21 2 6 name2 22 2 7 name3 23 2 8 name4 24 2 i need insert data in these 2 tables 1 table c(primarykey,maximum,name1,name2,name3,name4). here value name 'name1' should under name1, value name 'name2' should under name2 , on.. query wrote is: insert c(primarykey, maximum, name1, name2, name3, name4) (select distinct a.primarykey, a.maximum, (select value b name = 'name1' , owner = a.primarykey), (case when (select value b name = 'name2' , owner = a.primarykey) = 12 0 else 1 end), (select value b name = 'name3' , owner = a.primarykey), (select value b name = 'name4' , owner = a.primarykey) ...

c# - GroupBy and Count with condition using LINQ -

i have exam table, , examresults includes questions of specific exam. table contain question, answer selected, , answerpower indicate if answer correct or not: 1 (means correct), 0 (means wrong), null (means not answered , considered wrong). i trying count of wrong answers of specific exam grouped chapters. the following give me count of answers grouped chapter, don't know set condition count wrong answers can answerpower!=1 var query = ex.examresults .groupby(p => new { p.question.chapter.chaptername, p.answerpower }) .select(g => new { g.key.chaptername, mistakes = g.count() }); inside count can give condition below, note have removed answerpower groupby var query = ex.examresults .groupby(p => new { p.question.chapter.chaptername }) .select(g => n...

node.js - Can two http request come together? If it can, how nodeJS server handles it? -

Image
yesterday giving presentation on nodejs. 1 asked me following question: as know nodejs single threaded server, several request coming server , pushes request event loop. if 2 request coming server @ exact same time, how server handle situation? i guessed thought , replied following: i guess no 2 http request can come server @ exact same time , request come through single socket in queue . http request has following format: timestamp of request contained in it's header , may pushed event loop depending upon timestamp in header. but i'm not sure whether gave him right or wrong answer. i guess no 2 http request can come server @ exact same time, request come through pipe in queue. this part correct. incoming connections go event queue , 1 of them has placed in queue first. what if 2 request coming 2 server @ exact same time, how server handle situation? since server listening incoming tcp connections on single s...

android - Handler not updating ActionBar title -

i writing code music player , seems working fine except actionbar. when song playing, thread probes service every second change in song , if there change in song, handler object changes ui elements. final handler uihandler = new handler() { @override public void handlemessage(message msg) { bundle data = msg.getdata(); song = data.getparcelable("song_info"); songtext.settext(song.getsongtitle()); artisttext.settext(song.getsongartist()); seekbar.setmax(mservice.getduration()/1000); //all these work assert getsupportactionbar() != null; getsupportactionbar().settitle(mservice.getsongname()); //not updating super.handlemessage(msg); } }; what when there message thread, updates ui. can confirm works , invoked when need to. text views , seekbar updated required. however, getsupportactionbar().settitle(...) doesn't update title bar. same method of setting action bar title works if in other met...

django - Detailed documentation of pydanny's cookiecutter? -

i tried using it instead of kick-starting me caused lot of confusions. there book or article somewhere explains every single file cookiecutter generates does? mean there's documentation not help. feel free delete if not belong here. you can check "two scoops of django: best practices django".

android - App crash when onClick on 2nd item and so on in listview -

i beginner in programming. having issue code. whenever try click on 2nd item in list, app crashes. this code: public class mainactivity extends appcompatactivity { listview lvcategories; string[] categories = { "school", "work", "family outings", "friends outings", "groceries" , "appointments", "indoor activities", "outdoor activities", "games","overseas travelling" }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); lvcategories = (listview)findviewbyid(r.id.listviewcategories); final arrayadapter<string> adapter = new arrayadapter(this, android.r.layout.simple_list_item_1, categories); lvcategories.setadapter(adapter); lvcategories.setonitemclicklistener(new adapterview.onitemclicklistener() {...

performance - F5 bigip load balancer real time monitoring of requests / responses timing -

i'm looking way monitor requests / responses timing in real time. how many requests processing right now, , how long each request being processed ( when started, pool / server ) there way push / pull information f5 when request start processing , finished processing to/by external tool show information in real time ? are there tools allowing f5 load balancers or other http load balancers ? tia. if understand question properly, think should looking either tcpdump or use cs-command generates tabular output , gives information on following: when using tcpdump in case, may want include option output written file. recommend because can examine file ethereal bit more user friendly , enables filter on lot more things might in search of. syntax follows: using tcpdump tcpdump -vvni 0.0:nnn -s0 host 1.1.1.1 or host 2.2.2.2 or host 3.3.3.3 -w /var/tmp/filename.pcap or tcpdump -nvvv -i -c 20 '((port 80 or port 443) , (host 10.0.3.169 or host 10.0.3.1)) , dst ...

javascript - how to create a link to next page (currentpage+1) -

i have 30 pages. sort numbers ?page1 ?page2 ?page3......?page30 assume now, stay on page=1 http://localhost/flowplayer/manga/manga_demo2.php?page=1 and if want add button link next page (current page+1) how should do? this try not work. <input type="button" onclick="location.href='<?php echo $_server['request_uri'] + 1;?>';" value="next"> <input type="button" onclick="location.href='<?php echo $_server['request_uri'] + 1;?>';" value="next"> instead of can : <input type="button" onclick="nextpage()"/> function nextpage() { var urlname=$_server['request_uri']; var newurlname=substr(urlname,0,urlname.length-6)."page="; var appendedvalue=$_get["page"]+1; location.href=newurlname.appendedvalue; }

jquery - Calling webpage JavaScript methods from browser extension -

i developing firefox extension using webextensions me ease work scenario below. i have click around 50-60 buttons on site update task status. on click of button, web page calling webpage's updtask(id) javascript function making web-service call update task. i not able content script using code below: manifest.json : "permissions": [ "activetab", "cross-domain-content": ["http://workdomain.com/","http://workdomain.org/","http://www.workdomain.com/","http://www.workdomain.org/"] ] content-script code: function taskupdate(request, sender, sendresponse) { console.log(request.start + 'inside task update'); updatetask(45878); chrome.runtime.onmessage.removelistener(taskupdate); } function updatetask(id) { //todo: code buttons , task id's updtask(id); // not working } plugin script: document.addeventlistener("click", function(e) { if (e.target.classlis...

java - Query Environment Variables values defined in Jenkins Global Properties using API -

i have configured environment variable under: manage jenkins -> configure system -> global properties. i'm able use environment variable in jobs can't seem find way query remotely using api. is displayed anywhere? we setting global environments this: for (nodeproperty in hudson.model.hudson.instance.globalnodeproperties) { sitespecific.global_environment.each {key, value -> println "info: adding: ${key}:${value}" nodeproperty.getenvvars().put(key, value) } hudson.model.hudson.instance.save() } so should able read them same way, not through api, couldn't find way that.

java - Selenium WebDriver with Polymer website and Shadow root -

in google chrome console can click on shadow root element this. document.queryselector('html /deep/ next-tab').queryselector('a').click() but did same thing web-driver java code did not work . here web-driver & java code. webelement result = driver.findelement(by.cssselector("html /deep/ next-tab")).findelement(by.cssselector("html /deep/ a"); result.click(); can me this? simple thing somehow not figure out. you should use shadowroot property in javascript rather deep deprecated: javascriptexecutor jsexecuter = (javascriptexecutor)driver; webelement result = jsexecuter.executescript('return arguments[0].shadowroot', element) result.click(); where argument[0] html in case. elaboration: webdriver have option execute javascript after cast driver executor. javascriptexecutor run javascript code directly page. selenium doesn't support shadowroot out of box, need casting. in order want (clicking e...

javascript - Chart.js - cannot read property -

i want create chart multiple lines (multiple datasets) using django , chartjs. i'm adding data data attribute, separated dash (-) each line , comma (,) every value. js splits , use draw chart. <canvas id="product-linechart" data-labels="" data-charts="95.0,98.0,158.0,160.0,191.0,106.0,51.0,158.0,89.0,154.0-89.0,104.0,62.0,190.0,172.0,109.0,183.0,88.0,89.0,106.0-133.0,173.0,102.0,151.0,119.0,172.0,139.0,177.0,174.0,141.0-72.0,108.0,175.0,81.0,123.0,188.0,52.0,196.0,199.0,117.0-174.0,154.0,180.0,87.0,193.0,105.0,106.0,115.0,185.0,159.0-83.0,111.0,185.0,199.0,133.0,142.0,61.0,74.0,168.0,128.0-77.0,120.0,116.0,60.0,179.0,162.0,151.0,123.0,138.0,109.0-156.0,69.0,126.0,67.0,97.0,193.0,96.0,64.0,117.0,190.0-93.0,71.0,59.0,101.0,86.0,139.0,110.0,75.0,183.0,156.0" data-data_list="" width="1648" height="447" style="width: 1465px; height: 398px;" class=""></canvas> the problem raises errors: ...

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...

Azure cloud service: Modify the service definition -

i have virtual machine inside cloud service need install ssl certificate on cloud service saw post https://azure.microsoft.com/en-gb/documentation/articles/cloud-services-configure-ssl-certificate-portal/ but how can make step 2? tried rest of steps , made them have no idea step 2, don't have web role have vm copying answer @bruno faria on server fault ( https://serverfault.com/questions/722796/install-ssl-certificate-on-azure-cloud-service-vm/722811#722811 ) not allowed mark question duplicate of 1 asked there: the tutorial following web/worker roles cloud services , not virtual machines. although vm uses cloud service layer, it's not same thing. have install certificate in windows server machine , add host register dns provider. ssl certificates csr creation :: iis 8 , iis 8.5 iis 8 , iis 8.5 ssl certificate installation update : in case of apache (linux) openssl csr creation apache ssl apache ssl certificate instal...

sql - How do I delete one row for two duplicate entries in a postgres table? -

the 2 rows have same columns except timestamp column - created_at i want retain 1 of these rows - doesn't matter which. this how able select 1 of each of these duplicate rows can delete on basis of created_at column has lesser value. select e.id, e.user_id, e.r_needed, e.match, e.status, e.stage, e.created_at employee e, employee e2 e.id=e2.id , e.user_id=e2.user_id , e.status = 12 , e2.status=12 , e.stage=false , e2.stage=false , e.match=true , e2.match=true , e.user_id=12 , e.r_needed=true , e2.r_needed=true , e.created_at<e2.created_at , date(e.created_at)='2015-10-08'; however, cannot figure how can delete row such both of duplicates not deleted , ones selected above do? basically, want delete rows match columns in select query above , row has lesser value created_at. my table has no primary key or unique key. you can use correlated subquery instead of join: select * employee e exists ( select * employee e2 e.id=...

Youtube Player API for Android -

i'm trying use youtubeplayerview in android listview . possible have youtubeplayerview each item of listview ? should in order working? yes, possible have youtube player in each item of listview. mentioned here , need migrate application use iframe api or embedded<iframe>players . youtube android player api enables incorporate video playback functionality android applications. using api, can load or cue videos player view embedded in application's ui. you need initialize youtubethumbnailview . when thumbnailview initialized, app can callback either oninitializationsuccess or oninitializationfailure . if it's success put loader , setvideo runs server retrieve thumbnail. for more information, may use official google documentation including sample application: https://developers.google.com/youtube/android/player/sample-applications

Clojure associative data type with heterogeneous key/value hash strategy? -

how having data type key (in maps) work. for example: (defn foo [a] (identity a)) (def dict {1 "one", foo "foo", true "true", "etc." "ecetera", [1 2 3] "really?"}) which strategy used keys don't collide? edit the link in leon's comment has more value referenced question. however; accept has been answered.

java - Some nethods in my main Activity are showing as never used -

these 2 methods adduser() , viewdetails() methods not being used in main activity file. find reason, don't know have call them. using android studio. public class mainactivity extends appcompatactivity { edittext username, password; databaseadapter databasehelper; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); username = (edittext) findviewbyid(r.id.edittextuser); password = (edittext) findviewbyid(r.id.edittextpass); databasehelper = new databaseadapter(this); } public void adduser(view view) { string user = username.gettext().tostring(); string pass = password.gettext().tostring(); long id = databasehelper.insertdata(user, pass); if (id < 0) { message.message(this, "unsuccessful"); } else { message.message(this, "successful");...

mysql - Primary key on isolated table -

i cannot find solution problem , question is: have create primary key here? details my website has table in database called translations in put each single sentence/word different translations. have structure: id | lang | text ------------------- 01 | 01 | hello 01 | 02 | ciao 01 | 03 | salut 02 | 01 | surname 02 | 02 | cognome 02 | 03 | nom the field id connected word, field lang number indicates translation (01 = english, 02 = italian, 03 = french) , text translation of word. in case, if need (for example) word hello know has id = 1 , can choose language. is way create kind of table? not sure find easy because can call: select text tablename id = ? , lang = ? you can see ? because bind params pdo. 'lang' constant retrieved form cookie (01,02,03). important note: here have no primary keys, have set id , lang unique if want keep table structure , have one translation per language each word, can use id + lang primary...

Make Karma works with Ember.js -

i want use karma in ember app. i have conf file : // karma configuration // generated on sun nov 13 2016 10:50:12 gmt+0000 (utc) module.exports = function(config) { config.set({ // base path used resolve patterns (eg. files, exclude) basepath: '', // frameworks use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha'], // list of files / patterns load in browser files: [ 'app/**/*.js', 'tests/**/*test.js' ], // list of files exclude exclude: [ ], // preprocess matching files before serving them browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { 'app/**/*.js': ['babel'], 'tests/**/*.js': ['babel'] }, // test results reporter use // possible values: 'dots', 'progress' // available reporters: https://n...

java - Creating immutable view of object using Proxy classes -

i'm newest @ using proxy classes. need create fabric method of immutable view object (musicalinstrument.class) view must throw exception when i'm trying invoke setter , invoking of other methods must transfer object. maybe have got examples or sources can find answers! thanx! public class musicalinstrument implements serializable { /** * id of instrument. */ private int idinstrument; /** * price of instrument. */ private double price; /** * name of instrument. */ private string name; public musicalinstrument() { } public musicalinstrument(int idinstrument, double price, string name) { this.idinstrument = idinstrument; this.price = price; this.name = name; } public int getidinstrument() { return idinstrument; } public void setidinstrument(int idinstrument) { this.idinstrument = idinstrument; } public double getprice() { return price; } public void setprice(double price) { this.price = price; } public string getname() { retu...

angular - angular2: The hierarchic Json data cannot displayed correctly -

i test angular2-seed ( https://github.com/angular/angular2-seed ) displaying repo-detail, pure json string, in table. appending following code in repo-detail.component.html: <table> <tr> <td>{{repodetails.id}}</td> <td>{{repodetails.owner.login}}</td> <!--it's ok without line--> </tr> </table> now data not correctly displayed. in console, got: zone.js:388 unhandled promise rejection: error in ./repodetailcomponent class repodetailcomponent - inline template:7:12 caused by: cannot read property 'login' of undefined ; zone: angular ; task: promise.then ; value: viewwrappederror {_nativeerror: error: error in ./repodetailcomponent class repodetailcomponent - inline template:7:12 caused by: ca…, originalerror: typeerror: cannot read property 'login' of undefined @ debugappview._view_repodetailcomponent0.…, context: debugcontext} typeerror: cannot read property 'login' of...

elasticsearch - How to run a query with the properties from a stored document? -

let's have index docs contain following fields: uid , hobbies. how can run query find similarities between 1 , other users, without having retrieve user first , run new query hobbies? you use more this query , ask es retrieve documents given document (e.g. user uid=1 ) (without having retrieve document first). so in like array below give reference document needs used reference "more this" query (you can give more 1 document , verbatim hobbies strings). es retrieve document, check hobbies field , perform "more hobbies" query on other documents. post /users/user/_search { "query": { "more_like_this" : { "fields" : ["hobbies"], "like" : [ { "_index" : "users", "_type" : "user", "_id" : "1" <---- fill in uid of user here ...

cypher - Neo4J - Test nodes on path with unknown depth, with MATCH only -

i want test nodes in path node node b (with match statement), depth changing (could number). in example below depth 2. start = node(86) match p0 = a-[*..2]-b (b.attr = 'true') , (a.attr = 'true') return p0 my question how test nodes between , b attribute ( attr = 'true' ), using match statement, without knowing depth required. i find using filter method can filter out unwanted nodes. like: start = node(86) match p0 = a-[*..2]-b return filter(x in nodes(p0) x.attr = 'true') but not need, need use match . take @ cypher refcard , list predicates section . all() function should trick. something like: start a=node(86) match p0=(a)-[*..2]-(b) all(node in nodes(p0) node.attr = true) return p0 this match patterns nodes in pattern have attribute true.

Matlab: Matrix with all combinations of 0s and 1s with at least k 1s in each row -

so choose row length, n, , each row contain 0s , 1s , have @ least k 1s. have matrix possible combinations in matlab. for example, n=3 k=2: 1 1 0 1 0 1 0 1 1 1 1 1 you can use dec2bin create of bit patterns , keep patterns correct number of 1 s: n = 3; k = 2; allcombs = dec2bin( (2^k-1):(2^n-1) ) - '0'; % use -'0' convert integers outcombs = allcombs(sum(allcombs, 2) >= k, :); outcombs = 0 1 1 1 0 1 1 1 0 1 1 1

c# - Infinitely adding to an array -

is there way of infinitely adding array? far know have initialize , declare array int myarray = new array[10]; what if dont know how many items going go array , want give user option? you should use list list<int> mylist = new list<int>();

is there any alternative to send_keys() for input text field in python-selenium? -

i want send data text field in html page using selenium python .is there method other send_keys() using python-selenium ? assuming windows, can try using pywinauto uses microsoft's uiautomation , has access sending keys windows , dialogs, e.g. driver = webdriver.firefox() elem = driver.find_element_by_name('j_username') elem.clear() app = application.application() app.window_(title_re='*.firefox.*').typekeys('username')

docker - Why does container does't execite scripts inside /etc/my_init.d/ on startup? -

i have following dockerfile: from phusion/baseimage:0.9.16 run mv /build/conf/ssh-setup.sh /etc/my_init.d/ssh-setup.sh expose 80 22 cmd ["node", "server.js"] my /build/conf/ssh-setup.sh looks following: #!/bin/sh set -e echo "${ssh_pubkey}" >> /var/www/.ssh/authorized_keys chown www-data:www-data -r /var/www/.ssh chmod go-rwx -r /var/www/.ssh it adds ssh_pubkey env /var/www/.ssh/authorized_keys enable ssh access. i run container following: docker run -d -p 192.168.99.100:80:80 -p 192.168.99.100:2222:22 \ -e ssh_pubkey="$(cat ~/.ssh/id_rsa.pub)" \ --name dev hub.core.test/dev my container starts fine unfortunately /etc/my_init.d/ssh-setup.sh script does't executed , i'm unable ssh container. could me reason why /var/www/.ssh/authorized_keys doesn't executed on starting of container? i had pretty similar issue, using phusion/baseimage. turned out start script needed executable, e.g. ...

javascript - Not able to upload file using Angular JS $http Post -

my form data is: var fd = new formdata(); //take first selected file fd.append("file", document.getelementbyid('file').files[0], "abc"); my api request is: var config = { withcredentials : false, transformrequest : angular.identity, headers : { 'content-type': undefined } } return $http.post(url, fd, config) at backend i'm still not getting object in params. let me know why i'm not getting form data @ backend.

xunit - MemberAutoDataAttribute only auto generates values every second execution -

i tried combine member-data , auto data attribute way: using xunit; using ploeh.autofixture.xunit2; class memberautodataattribute : compositedataattribute { public memberautodataattribute(string membername) : base( new memberdataattribute(membername), new autodataattribute()) { } } this test implements it: [theory, memberautodata(nameof(currentweatherresponses))] public void parsecurrentweather_weatherparsed( string response, weather expectedweather, temperatureunit tempunit) { // ... } and here currentweatherresponses member: public static ienumerable<object[]> currentweatherresponses { { yield return new object[] { currentweatherresponse.tostring(), new weather() {} }; } } why every second test execution values generated , not temperature unit?

java - Why do we use Constants? -

why use constants , initialize them in code?i don't why use them. example here: public class utils { public static final string base_url = "api.openweathermap.org/data/2.5/weather?q="; public static final string icon_url = "api.openweathermap.org/data/2.5/weather?q="; } constant use maintain , manage constant value in 1 place. example, if going hit server url multiple time can avoid multiple time declare same url. need set delay runnable on time can create constant value (i.e public static final integer delay = 5000; ). use runnable. see below example. private static final integer delay_time = 3000; private handler mhanlder = new handler(); mhanlder.postdelayed(manimrunnable, delay_time)// same delay using 1 constant variable. mhanlder.postdelayed(mtextupdaterunnable, delay_time)// same delay using 1 constant variable. private runnable manimrunnable = new runnable() { public void run() { //your animation...

c++ - Debug mode or Release mode -

recently, i'm working on intergrating physics engine graphics engine program. before this, build program in debug mode because feel debug means safe , more information let me know wrong. in program, built assimp in release mode, still used in debug mode until now. now, build bullet physics in release mode beacuse of performance huge different in debug mode. if want know how slow is, see this . the important thing not use *.lib file in debug mode ever, have question, when or why change release mode debug mode or on other hand . or using release library in debug mode either? now, think need change release mode permanently bullet physics, , don't know if or bad. edit: i know benifit release , debug mode, because there lot of possible duplicated articles in stackoverflow, want know when make program decision choosing or because encounter performace problem need rebuild program release mode me. want clarify little different between posiible duplicated articles :) there...

php - How to make sure all data are inserted into database? -

i have 3400 data , want insert of data database. but, seems data skipped during process. how make sure data inserted. thank you. here code: <?php include 'koneksi.php'; mysql_query("truncate token"); $komentar=mysql_query("select * dataset_komentar") or die(mysql_error()); $stopwords=mysql_query("select * stopwords") or die(mysql_error()); $index=0; $arrsw=array(); while ($result1=mysql_fetch_assoc($stopwords)) { $arrsw[$index]=$result1['kata']; $index++; } if (mysql_num_rows($komentar)>0){ while ($result2=mysql_fetch_assoc($komentar)) { $str2=$result2['komentar']; $newstr=preg_replace('/[^a-za-z]/', ' ', strtolower($str2)); $newstr=str_replace("'", '', $newstr); $token=strtok($newstr, " "); $kata=""; while ($token) { ($i=0; $i<count($arrsw); $i++) { if (trim($ar...

highcharts - Proportional Pie-charts using High-Charts -

i working high charts plot 2 pi charts need proportional. have calculated radius of each, can't find way specify radius each pi chart. how can this? use pie series size property. from docs: size: string|number the diameter of pie relative plot area. can percentage or pixel value. pixel values given integers. default behaviour (as of 3.0) scale plot area , give room data labels within plot area. consequence, size of pie may vary when points updated , data labels more around. in case best set fixed value, example "75%". defaults . example

html - css border not showing but css is applied -

Image
i'm trying apply border tr 's in thead . css(stylus): table thead tr border: solid #000; border-width: 0 10px; according chrome styles applied, border doesn't show up: tr need table have border-collapse: collapse border work table.first { border-collapse: separate; /* property default */ } table.second { border-collapse: collapse; } table thead tr { border-bottom: 2px solid gray; } /* demo */ div { margin: 25px 20px 10px; text-decoration: underline; } <div>this table's tr (in thead) has no border</div> <table class="first"> <thead> <tr> <td>left head</td> <td>right head</td> </tr> </thead> <tbody> <tr> <td>left</td> <td>right</td> </tr> </tbody> </table> <div>this table...