Posts

Showing posts from February, 2014

How to measure distance covered across patches in NetLogo -

i have model setup in netlogo simulation space gis map 20 km radius constructed. the max xcor , ycor set 20 , min xcor , ycor -20. gives torus of 41 x 41. i have agents @ centre of map @ patch 0 0 , want maximum distance can cover 20 km i.e. extent of gis map. ask turtles [ set heading 360 fd 1 ] am right in saying if iterate code 20 times they'll @ centre of last patch (xcor 0 ycor 20) isn't quite 20 km? if that's right, how code agents move appropriate distance. feel i'm trying square circle here. i should can add following line patch scale comes out @ 975.6 set patch-scale (item 1 gis:world-envelope - item 0 gis:world-envelope ) / world-width if multiply patch scale world width 40000 looks right given radius of circle 20 km. thanks globals [km] test ca let extent 40 ;desired world-width, in kilometers set km (world-width / extent) crt 1 [set heading 360] ask turtle 0 [fd (20 * km)] end

Extract Columns from html using Python (Beautifulsoup) -

i need extract info page - http://www.investing.com/currencies/usd-brl-historical-data . need date, price, open, high, low,change %. i`m new python got stuck @ step: import requests bs4 import beautifulsoup datetime import datetime url='http://www.investing.com/currencies/usd-brl-historical-data' r = requests.get(url) soup=beautifulsoup(r.content,'lxml') g_data = soup.find_all('table', {'class':'gentbl closedtbl historicaltbl'}) d=[] item in g_data: table_values = item.find_all('tr') n=len(table_values)-1 n in range(n): k = (item.find_all('td', {'class':'first left bold nowrap'})[n].text) print(item.find_all('td', {'class':'first left bold nowrap'})[n].text) here have several problems: column price can de tagged or . how can specify want items tagged class = 'redfont' or/and 'greenfont'? . change % can have class redfont , greenfont. other columns ta

javascript - How does the spread operator in ES6 JS work as a function argument? -

ok, i'm trying understand how new spread works function parameter. imagine function unknown number of parameters , adds them together. let addnums = ...a => a.reduce ((a,b) => a+b); this function works. so, what's problem? here's observations, followed problem: the spread operator function parameter / argument seems designed 'spread' array of values separate arguments: based on research i've done, spread operator can used pass arrays functions not accept arrays arguments standard, e.g. array.prototype.push(), without having use apply : var x = []; var y = [1,2,3]; // array.push(arg1,arg2,...) requires separate arguments possible: x.push(...y); // 'spreads' 'y' separate arguments: x.push (arg1,arg2,...) but array passed push in case needs declared/defined beforehand (in case y ) this confirmed looking @ length of arguments object inside function if use addnums(1,2,3,4) , arguments.length still == 4. so, seems funct

regex - Python regular expression to replace everything but specific words -

i trying following with regular expression : import re x = re.compile('[^(going)|^(you)]') # words replace s = 'i going home now, thank you.' # string modify print re.sub(x, '_', s) the result is: '_____going__o___no______n__you_' the result want is: '_____going_________________you_' since ^ can used inside brackets [] , result makes sense, i'm not sure how else go it. i tried '([^g][^o][^i][^n][^g])|([^y][^o][^u])' yields '_g_h___y_' . not quite easy first appears, since there no "not" in res except ^ inside [ ] matches 1 character (as found). here solution: import re def subit(m): stuff, word = m.groups() return ("_" * len(stuff)) + word s = 'i going home now, thank you.' # string modify print re.sub(r'(.+?)(going|you|$)', subit, s) gives: _____going_________________you_ to explain. re (i use raw strings) matches 1 or more of character

jquery - Execution order of if else issue -

i have function, part of works non-correct. what need - 1) if window width < 768 (do smth) 2) if window width = 768 (do smth) 3) else (do smth) there part of function var windowwid = $(window).width(); if ($poselok.length > 0) { if (windowwid === 768) { var offset = 0.05; } if (windowwid < 768) { var offset = 0 - $el_full.offset().left - el_margin_left; } else { var offset = 0 - $el_full.offset().left + $sideleft + 15; } } else { var offset = 0 - $el_full.offset().left - el_margin_left; }; without if (windowwid < 768) condition if (windowwid === 768) works, - doesn't. i tried if (windowwid < 767) , if (windowwid <= 767) separate if nothing. i tried replace if , (windowwid === 768) works if (windowwid < 768) works incorrect. i think have mistake in execution order, don't know how fix it. help please! if (condition1) { block of code executed if condition1 true }

amazon web services - How to reuse a string block in swagger -

i writing swagger file aws api gateway. have use block of text integration every single endpoint. how single end-point looking currently '/products/{productid}': get: tags: - product summary: detailed information product consumes: - application/json produces: - application/json parameters: - name: productid in: path required: true type: string responses: '200': description: 200 response schema: type: array items: $ref: '#/definitions/product' '404': description: product not found schema: type: array items: $ref: '#/definitions/product' x-amazon-apigateway-integration: requesttemplates: application/json: > ## see http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

SAP HANA - Activation warning: Could not found Naming Convention in table _SYS_BI.BIMC_CONFIGURATION for -

when activating procedure got following warning: could not found naming convention in table _sys_bi.bimc_configuration attributeview,analyticview,calculationview,procedure,analytic privileges,decision table . so made following inserts: insert _sys_bi.bimc_configuration values ('naming_convention_rule_analyticview', 'an_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_attributeview', 'at_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_calculationview', 'ca_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_procedure', 'sp_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_analytic_privileges', 'ap_'); insert _sys_bi.bimc_configuration values ('naming_convention_rule_decision_table', 'dt_'); after still warning: could not found naming convention in table _sys_bi.bimc_configuration . any ideas how

vb.net - String Compare with special characters -

i want compare 2 strings along hyphen characters , find out correct breaking point case 1: dim dictionarystr string = "un-cen-tered" dim textstr string = "uncen-tered" result: correct breaking. case 2: dim dictionarystr string = "un-cen-tered" dim textstr string = "unce-ntered" result: wrong breaking. first compare 2 words without hyphen make sure have exact same letters @ right place. then count number of letters on left side of each hyphen (without counting hyphen). if numbers found in textstr found in dictionarystr it's match. ex: un-cen-tered un (count 2 letters on left side of first hyphen) uncen (count 5 letters on left side of second hyphen) case 1: dictionarystr: 2, 5 textstr: 5 * 5 contained in previous list, good case 2: dictionarystr: 2, 5 textstr: 4 * 4 not in previous list, bad ' list of word hyphen dim dictionarywordswithhyphen new list(of string) ' p

Command for restarting all running docker containers? -

how restart running docker containers.. looking shortcut instead doing docker restart containerid1 containerid2 just run docker restart $(docker ps -q) update for docker 1.13.1 use docker restart $(docker ps -a -q) in answer lower.

orientdb2.2 - OrientDB error on query date -

i've table these fields: mytable code string fromdate date todate date the content of table following: 'abc', '2016-05-01 00:00:00', '2016-05-31 00:00:00' 'def', '1900-01-01 00:00:00', '2099-01-01 00:00:00' 'ghi', '1900-01-01 00:00:00', '2099-01-01 00:00:00' if try write query: select mytable fromdate <= '2016-05-01' or alternatively select mytable fromdate <= date('2016-05-01', 'yyyy-mm-dd') the result following: 'def', '1900-01-01 00:00:00', '2099-01-01 00:00:00' 'ghi', '1900-01-01 00:00:00', '2099-01-01 00:00:00' so, orientdb doesn't return row equal condition on date. where's fault? orient version i've used 2.2.0 from orientdb team notice arrive bug has closed , released on 2.2.5 version go here

bash - Curl: don't wait for response -

this question has answer here: run shell command , don't wait return [duplicate] 2 answers i have shell script relies on curl command this: curl --request post -u name:pass -h "content-type: application/json" --data "{data}" https://url.com --cacert ./my_crt i don't need response of command, , command in big loop, waiting responses take lot of time. so, there way in bash same thing, without waiting response? if have large number of requests want issue quickly, , don't care output, there 2 things should do: do more requests same connection. for small requests, it's faster 10 requests each on 1 connection, 1 request each on 10 connections. henry's http post test server , difference 2.5x: $ time in {1..10}; curl -f foo=bar https://posttestserver.com/post.php ; done dumped 1 post variables. view @ http

xml - xslt boolean aggregation of a children property -

i aggregate boolean value exists in children of node , add parent. xml document looks like: <?xml version="1.0" encoding="utf-8"?> <module> <entity name="test" > <attributes name="att1" translatable="true"> <attributes name="att2" translatable="false"> <attributes name="att3" translatable="false"> <attributes name="att4" translatable="true"> </attributes> </entity> </module> and transform to: <?xml version="1.0" encoding="utf-8"?> <module> <!-- @ entity level property translatable shall result of or aggregation of children attributes.translatable i.e. iterate attributes (true or false or false or true = true ) ==> entity.translatable=true --> <entity name="test" translatable="true&

php - Laravel package controller alias in routes -

i'm trying create package in laravel 5.2 routes. have controller in http/controllers folder (with namespace vendor\package\http\controllers\mycontroller ). want create alias don't know how. don't want call controller in routes.php that: route::get('myurl', vendor\package\http\controllers\mycontroller::class . '@action'); but that: route::get('myurl', 'mycontroller@action'); i tried search in application class api can't find information. this code in package provider doesn't work. $this->app ->alias(vendor\package\http\controllers\mycontroller::class, 'mycontroller'); my service provider: class packagerouterserviceprovider extends serviceprovider { /** * bootstrap application services. * * @return void */ public function boot() { // } /** * register application services. * * @return void */ public function register() {

c# - If I'm using Guid Identity Web Api 2 It gives me an error -

so here exmaple: model: [table("items")] public class item { [key] [databasegenerated(databasegeneratedoption.identity)] public guid id { get; set; } [required] public string name { get; set; } } and web api 2 controller part: // post: api/items [responsetype(typeof(item))] public async task<ihttpactionresult> postitem(item item) { if (!modelstate.isvalid) { return badrequest(modelstate); } item.id = guid.newguid(); db.items.add(item); await db.savechangesasync(); return createdatroute("defaultapi", new { id = item.id }, item); } on insert receive error, if use string , guid.newguid().tostring(); works fine, there no problem develop app in way want understand problem, using guid works on mvc5. because of using guid id type, can't defined property identity, remove annotation above id: [databasegenerated(databasegeneratedoption.identity)] and add guid.newguid() in construct

json - Django REST API configurations receiving image from android -

hi new django , using create web service. connecting android django , upload , image android django imagefield. using serializer save data in json. code works on normal web, however, not sure image file format send on server , how configure server's file handling this views.py looks : `def post(self, request): serializer = photoserializer(data=request.data) if serializer.is_valid(): serializer.save() return response(serializer.data, status=status.http_201_created) return response(serializer.errors, status=status.http_400_bad_request)` hi should try create serializers class save image way: class modelnamesaveserializers(serializers.modelserializer): image_field = serializers.imagefield() class meta: model = modelname fields = ('id'.. antoher_fields, 'image_field')

dns - Can I use a custom root domain for a bluemix CF application? -

i want use bare domain bluemix cf app. (a bare domain known zone apex, domain bought nothing on front of it, e.g. "azquelt.co.uk") the bluemix docs configuring custom domain must configure cname record hostname want associate bluemix application. however, cannot create cname record bare domain (e.g. "azquelt.co.uk"). limitation of dns. is possible use bare domain name bluemix application or not supported? yes, can use bare domain name in bluemix. have set record bare domain point bluemix domain ip address region. find ip address ping hostname corresponding region. example south region should user 75.126.81.68: $ ping secure.us-south.bluemix.net ping secure.us-south.bluemix.net (75.126.81.68): 56 data bytes the link mentioned has hostnames other bluemix regions well. to configure application: 1) create custom domain in bluemix using bare domain (for example azquelt.co.uk 2) in bluemix application add new route , select new custom domai

e commerce - Tracking the products using Enhanced Ecommerce with Google Analytics -

i have implemented google analytics multiple trackers using url : https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers#working_with_multiple_trackers have tried implement enhanced ecommerce in it,but product categories not being tracked.in analytics panel , showing (not set). don't know went wrong since not seo expert. in header : <script> //google analytics (function(i,s,o,g,r,a,m){i['googleanalyticsobject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new date();a=s.createelement(o), m=s.getelementsbytagname(o)[0];a.async=1;a.src=g;m.parentnode.insertbefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'ua-123', 'auto'); ga('create', 'ua-456', 'auto', 'abc'); ga('create', 'ua-789', 'auto', 'xyz'); //ecommerce tracking cod

java - Antialias on clipPath on layout -

i have layout, has several views inside of - toolbar, recyclerview , few separators (which simple views height of 2dp , match_parent width). wanted put mask on layout - important part of round corners whole layout (and not views itself). decided create own linearlayout class overloaded dispatchdraw function , managed nice result... except 1 thing - corners not antialiased. tl;dr there way put antialias clippath function? know can turn on in paint , use xfermodes mask layout, have no clue how draw mask , draw else (without knowing what's inside). here layout code (except classname, simple constructors , path field): @override protected void dispatchdraw(canvas canvas) { if (path == null) { path = new path(); float margin = myapplication.getinstance().getmetrics().density * 5; path.addroundrect(new rectf(margin,margin,getwidth()-margin, getheight()-margin), margin*2, margin*2, path.direction.cw); } canvas.clippath(path);

Proper way to utilize .loc in python's pandas -

when trying change column of numbers object float dtypes using pandas dataframes, receive following warning: a value trying set on copy of slice dataframe. try using .loc[row_indexer,col_indexer] = value instead now, code runs fine, proper , intended way avoid warning , still achieve goal of: df2[col] = df2[col].astype('float') let noted df2 subset of df1 using condition similar to: df2 = df1[df1[some col] == value] use copy method. instead of: df2 = df1[df1[some col] == value] just write: df2 = df1[df1[some col] == value].copy() initially, df2 slice of df1 , not new dataframe. why, when try modify it, python raises error.

javascript - Pagination shown even though there is no data in angular -

here code: buttons: <li ><a data-ng-click="data1 = true;data2 = false; search.status = ''" href="">all projects</a></li> <li ><a data-ng-click="data2 = true;data1 = false" href="">notifications</a></li> populated data on click of button: <ul> <li ng-show="data1" dir-paginate="wd in workorderslist | filter: search.status | filter: search.name | itemsperpage: 10"> <a href=""> <h4>{{wd.name}}</h4> </a> <p>status: {{wd.status}}</p> </li> <li ng-show="data2"> <div ng-show="!notificationdatadashord.length"> <span>no notifications</span> </div> </li> </ul> <dir-pagination-controls auto-hide="true"></dir-pag

java - How to fire onProgressChanged () per segment -

i working on android application , facing optimization problem : have seekbar whenever user drags thumb near middle (the max value 100 near middle mean between 55 , 45 ) thumb should automatically jump middle . @override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { x=seek.getprogress(); if (x>45 && x<55) {seek.setprogress(50);} socket.emit("move1", x); } it works whenever thumb jumps onprogresschanged event keeps firing continuously until user moves thumb away middle area , consumes resources . want while progress of seekbar between 45 , 55 onprogresschanged fires once. this may - fromuser parameter tells whether progress changed due action user or programmatically. if changed user, , if not @ 50, set 50. seekbar.setonseekbarchangelistener(new seekbar.onseekbarchangelistener() { @ov

git branch for multiple remotes -

when running git branch -r see branches on remote repository. there way see in same working directory, branches of multiple repositories? goal create file lists branches in couple of repositories, this: repo1:master,dev,qa,fy-2473 repo2:master,dev,fy-1128,staging repo3:master,fy-1272,staging so on , forth. have print branches right way: git branch -r | awk -f' +|/' -v ors=, '{if($3!="head") print $3}' >> repolist.txt i need have functionality work couple of repositories without having clone each , of them single purpose. thanks. add repos remotes local repo git remote add , git fetch --all them , adapt awk command produce result want. this command produce output expect git branch -r | awk ' # split remote , branch { remote = substr($1, 0, index($1, "/") - 1) branch = substr($1, index($1, "/") + 1) } # eliminate head reference branch == "head" { next } #

javascript - Open url/file when clicking bootstrap accordion -

i need twitter's bootstrap accordion. need when click accordion title, title opens href to. <div class="container"> <p class="max-width-700 lead">testing</p> <div class="col-md-6 col-sm-6 mb-sm-30"> <div class="accordion"> <div class="accordion-title"> <a href="">2014 (opening)</a> </div> <div class="accordion-title"> <a href="">2015 </a> </div> <div class="accordion-content"> </div> something this, when click 2014, opens document or file have linked to (1) use boostrap-collapse.js event. see http://getbootstrap.com/2.3.2/javascript.html#collapse give each title unique id , add following js end of html. $('#myitem1').on('show', function () { window.location.href = '1.0.pdf'; }) (2) accordion designed open underlying hidden content. using open e

sql - Retrieve full path of attachment from multiple linked tables in Microsoft Access 2013 -

Image
i have used union query select values other queries select * 1dbform union select * 2dbform union select * 3dbform; queries can retrieve attachment without error select users.name, client_details.folio_number, client_details.date_of_registration, client_details.erv, client_details.jina, client_details.slp, aina_ya_viwanda.aina_ya_viwanda, aina_ya_viwanda.ada, client_details.cfullpath aina_ya_viwanda inner join (users inner join client_details on users.id = client_details.uid) on aina_ya_viwanda.id = client_details.[aina ya viwanda] order client_details.folio_number; . how can combine 3 queries without affecting attachment capability? i'm assuming cfullpath attachment field? if that's true, believe can append .filename attachment field display path in query client_details.cfullpath.filename

drools coercion fail somethings -

according documentation,"coercion in favor of field type , not value type" i tried , it's not true. the rule: rule "get event field " when m : message( geteventfield("bigdecimalb") > "7.5" ) system.out.println( "hit" ); end the message class: public class message { private map<string, object> map = new hashmap<string, object>(); public object geteventfield(string key) { object object = map.get(key); if (object != null) { //class=java.math.bigdecimal in test system.out.println("geteventfield, fieldname=" + key + ", class=" + object.getclass().getcanonicalname()); } return object; } //setter , getter } and test: string str = "{\"bigdecimalb\":10.2}"; map<string, object> map = json.parseobject(str); message message = new message(); message.setmap(map

opengl es - How effectively interpolate between many color attributes in GLSL ES 2.0 -

i'm working on project opengl es 2.0. every vertex in mesh has fixed number of color attributes (lets 5). final per-vertex color computed interpolation between 2 selected color attributes. in implementation, choice of 2 colors based on 2 given indexes. i'm aware if statement may big performance hit choose put attributes 1 array , use indexing retrieve wanted colors. still see significant performance drop. attribute vec4 a_position; //the glsl es 2.0 specification states attributes cannot declared arrays. attribute vec4 a_color; attribute vec4 a_color1; attribute vec4 a_color2; attribute vec4 a_color3; attribute vec4 a_color4; uniform mat4 u_projtrans; uniform int u_index; uniform int u_index1; uniform float u_interp; varying vec4 v_color; void main() { vec4 colors[5]; colors[0] = a_color; colors[1] = a_color1; colors[2] = a_color2; colors[3] = a_color3; colors[4] = a_color4; v_color = mix(colors[u_index], colors[u_index1], u_interp); gl_po

ios - How to add system icons for a UIButton programatically? -

Image
it's easy add custom image or background uibutton , there seems no programmatic way set 1 of following default ios icons uibutton , know can applied navigation bar buttons, don't need that, want apply simple uibutton , hints? from apple's documentation: init(type:)

java - JTable - same items displayed -

Image
as can see when trying new items got repetition. should do? i wrote jtable redisplayer class. have add button table. when click button should exp addded 1. after add 2. should display 1 2 only. not 1 1 2 that. jtable1.removeall(); jtable1.revalidate(); try{ class.forname("com.mysql.jdbc.driver"); } catch(classnotfoundexception e){ system.err.println("driver yok"); return; } connection con=null; try{ con=drivermanager.getconnection("jdbc:mysql://localhost:3306/kutuphane","root",""); system.out.println("veritabnı baglandıldı"); statement stmt=con.createstatement(); resultset rs=stmt.executequery("select * kisiler "); while(rs.next()){ model=(defaulttablemodel) jtable1.getmodel(); model.insertrow(i,new object[]{rs.getstring("adsoyad"),rs.getint("telefon"),

JavaScript function remove <img> by src -

i have problem in javascript , can't figure out: i have write javascript script (no jquery) remove <img> tags have src="file.jpg" , adds round corners <p> , <div> tags having background image "file.jpg" . i can't work out. if desired file has different name, not file.jpg example funnyimage.png or change image name (and path before it) if needed: remove <img> tags file.jpg source: array.from(document.queryselectorall('img')).foreach(img => { if(img.src === 'file.jpg') { img.parentnode.removechild(img); } }); rounded corners: array.from(document.queryselectorall('p, div')).foreach(node => { if(node['background-image'] === 'file.jpg') { node.style['border-radius'] = '10px'; // example 10px } }); or (much more intelligent , efficient way): const style = document.createelement('style'); style.textcont

PHP sendmail, values not passing through to email -

i have contact form on html page using php script on seperate php page send text values entered input boxes in email everything working except text entered in forms input boxes not passing through, blank below doing: html <form class="form-inline" action="mail_handler.php" method="post" enctype="multipart/form-data"> <div class="fullwidth"> <div class="left-feild col-md-6"> <div class="form-group"> <input type="text" class="form-control color01 background13 border-color08" name="name" placeholder="name" required> </div> <div class="form-group"> <input type="email" class="form-control color01 background13 border-color08" name="email" pl

tomcat - java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException -

what causes kind of error in tomcat? severe: exception loading sessions persistent storage java.io.writeabortedexception: writing aborted; java.io.notserializableexception: bean.projectareabean @ java.io.objectinputstream.readobject0(objectinputstream.java:1333) @ java.io.objectinputstream.readobject(objectinputstream.java:351) @ java.util.arraylist.readobject(arraylist.java:593) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke( delegatingmethodaccessorimpl.java:25) just implement serializable if you're getting notserializableexception follows, java.io.notserializableexception: bean.projectareabean then means class identified qualified name in exception message (which bean.projectareabean in case) not implement serializable interface while been expected code behind. fixing relatively simple, let class imp

c++ - wxDataViewModel: What is it and how do i use it? -

i read documentation http://docs.wxwidgets.org/3.0/classwx_data_view_model.html several times hardly answers questions. maybe i'm confused function of class? so riddle this: is view model know mvvm? how implement derivative? how set data in containing wxdataviewlistctrl? is right/recommended way make table? as name subtly hints, wxdataviewmodel indeed model in usual mvc design (while wxdataviewctrl both view , controller). you can see couple of examples of custom models in dataview sample . notice wxdataviewlistctrl compatibility class made transitioning code using wxlistctrl wxdataviewctrl , defines own trivial list model. don't recommend using unless need.

android - GCM on app and on aar. Push notifications sent to the aar are also received by the app -

i've created library project uses gcm receive push notifications. while installed library on app does not have push notifications enabled, i'm receiving , parsing push notifications expected. the problem if app has implementation of gcm. i've faced issue pushes sent library not received. because library registered in manifest com.google.android.gms.gcm.gcmreceiver . overcome this, in library, i've created class extends gcmreceiver , register in library manifest. like: <receiver android:name=".gcm.custompushnotificationsreceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> <!--for pre-4.4 kitkat devices--> <action android:name="com.google.android.c2dm.intent.registration" /> &

javascript - Concat two arrays But concat is not working -

i have 2 arrays. i want concat both array values .but here shows me error, newsarr.contact not function my code var globalnews = []; var commentarray = []; var commentarr = {}; commentarr['comment'] = comment; commentarray.push(commentarr); var newsarr = {}; newsarr['newsno'] = $("#newsnumber").val(); newsarr['desc'] = $("#desc").val(); //globalnews.push(newsarr.concat(commentarray)); // not working globalnews= newsarr.concat(commentarray); you can use $.merge( commentarray, newsarray ); concatenate arrays: $(document).ready(function() { var globalnews = []; var commentarray = []; var newsarray = []; var commentarr = {}; commentarr['comment'] = 'aaa'; commentarray.push(commentarr); var newsarr = {}; newsarr['newsno'] = 'bbb' newsarr['desc'] = 'vvv'; newsar

php - Understanding laravel 'auth' and 'web' middleware -

i have strange behavior on 1 of route groups have defined e.g route::group(['prefix' => 'admin', 'middleware' => ['web','auth']], function (){ //admin routes } ); whenever defined 'middleware' => ['web','auth'], routes accessible after login , without 'web' redirected / home. what thought that , 'web' default middleware injected ,please correct me if wrong. otherwise there other setting affecting behavior ? laravel comes web middleware groups contains common middleware may want apply web ui routes. web middleware group automatically applied default routes.php file routeserviceprovider .

material design lite - How to focus an MDL TextField -

what proper way focus material design lite textfield? this works: $("#mytextfield").focus(); this not work: document.getelementbyid('mytextfield').parentnode.materialtextfield.focus(); however, similar code works disable textfield: document.getelementbyid('mytextfield').parentnode.materialtextfield.disable(); you don't need jquery. input.focus(); input.parentnode.classlist.add('is-dirty');

How do I add fields dynamically in web2py forms? -

i have form field(with label "person1"). add more fields of same type add more people. how add specific fields dynamically in web2py forms clicking button? u cant add automatically fields form.it should done manually field('name',label='',widget='').in way u can add fields form

algorithm - Timecomplexity with given input and time -

what's easiest way time-complexity of function when input , time per input given? for example: n | 10 20 40 80 160 320 640 time | 1 3 9 60 475 3732 29835 how find time-complexity of table? assuming, interested in polynomial complexities ( o(n) , o(n 1.5 ) , o(n 2 ) ...). the easiest way estimate time-complexity of function implementation @ last 2 largest datapoints. you doubled (*2) input size n 320 640. , execution time increased factor of 8 (29835/3732 =7.994...). thus, time complexity estimate o(n 3 ) since 2 3 =8. 1 should pay attention, estimate correct if tested on large enough datasets ( n large) , lower-order terms not influence solution anymore. moreover, time-complexity of implementation of algorithm, not algorithm itself. another useful technique understand complexities of code plotting them ( t versus n ) on log-log plot. since degree of polynomial determining complexity become slope of line on log-log plot, can give un

spring mvc - JSON Data not being displayed in Angular 2 component -

Image
i new spring mvc , angular 2. have been working on building web application side project. have been able pretty far spring mvc app wanted migrate angular 2 front end. have followed quick start procedures on angular.io , seem doing okay. next step angular service retrieve data spring mvc rest controller. i have been able send controller retrieve list of users , controller sends application/json object. problem users not showing in browser. not seeing errors in lite-server window , not sure how troubleshoot why data not getting displayed. can find issue? usercomponent.ts: import { component, oninit, ondestroy } '@angular/core'; import { router } '@angular/router'; import { user } './user'; import { userservice } './user.service'; import { role } '../roles/role'; @component({ templateurl: '/app/users/user.component.html', providers: [ userservice] }) export class usercomponent implements o

c# - Message Queue service messages don't arrive -

i've got wcf service on message queuing. the service configured this: <service name="emailservices.emailservice" behaviorconfiguration="servicebehaviour"> <endpoint address="mex" binding="mexhttpbinding" bindingconfiguration="" name="mexemailservice" contract="imetadataexchange" /> <endpoint name="netmsmqemailservice" address="net.msmq://w2k8services/emailservices_w2k8services" contract="emailservices.iemailservice" binding="netmsmqbinding" bindingconfiguration="netmsmq" /> <host> <baseaddresses> <add baseaddress="http://localhost:8008/emailservice" /> </baseaddresses> </host> </service> the binding this <netmsmqbinding> <binding name="netmsmq" exactlyonce="true" receiveerrorhandling="move" rec

wcf - why message contract if we can achieve through datacontract and security -

message contract can use when have pass authentication detail soap header instead passing paratmeter in datacontract ex. license key or user credentials. passing parameter not secure. can secure datacontract using security(transport or message). why need messagecontract? difference bewteen message contract , data contract/ "message contract has full control on soap message , can add protection level , message can encrypted , secure. signing or encrypting soap header information. mixing message , data contracts cause runtime error when generate wsdl service."

How to perform JOIN operation in elasticsearch -

how perform join operation in elasticsearch on same index? this set of field fow each documents: "@version": "1", "@timestamp": "2016-04-26t15:56:05.379z", "phone": "..." "path": "...", "host": "...", "type": "...", "clientip": "...", "ident": "-", "auth": "-", "timestamp": "...", "verb": "...", "uripath": "...", "httpversion": "1.1", "response": "200", "bytes": "515", "timetaken": "383", "event_type": "type1" } if phone of documents have ( event_type of type1 , timestamp between date1 , date2 ) , ( event_type of type2 , timestamp b

c - How to use dynamic allocation instead of static int? -

int* asciicode(char c1, char c2){ static int asciicode[126]; /code/ /code/ return asciicode; } can use allocation instead of static int situation ? don't know number of elements of above pointer array ? if yes, how can ? this example may find useful. array allocated , used in subsequent calls in order emulate use of static array hold values between calls. #include <stdio.h> #include <stdlib.h> int* asciicode(char c1, char c2, int *asciicodearr, int size ){ int static counter = 0; if(asciicodearr==null) { asciicodearr = (int *) malloc( sizeof(int)* size); if(!asciicodearr) return null; } printf("c1=%c ",c1); printf("c2=%c ",c2); asciicodearr[counter] = c1; counter = counter + 1; asciicodearr[counter] = c2; counter = counter + 1; return (asciicodearr); } int main(void) { int i; int *array=null; int size = 128; // hold 128 - 7bits standard ascii characters

c# - Why does Entity Framework ignore order by when followed with distinct? -

i'd know why following join returns values in unordered fashion. distinct imply order of iqueryable passed not guaranteed, therefore ef not bother generating order clause in sql. var currentutc = datetime.now; var data = (from in itemsa join c in customers on a.fk_customerid equals c.id customersubset cs in customersubset.defaultifempty() cs.age > 18) orderby a.id ascending select new { a.id, a.someproperty, cs.customeruid, customername = cs.name, updateutc = currentutc }).distinct().take(1000).tolist(); the strange thing removing distinct adds order clause in inner query of generated sql (you can use linqpad see sql generated eg.) now if replace last line with .distinct().orderby(x => s.id).take(1000).tolist(); i'm getting order clause in sql, whether or not have orderby a.id ascending in inner query. makes sense, why

angular - unable to call services in agGrid(Angular2) by cell renderer option -

i using ag-grid displaying list of user .if edit user details,then want click update button in grid edit corresponding user details. this coloumn header in ag_grid { headername: 'update', field: "update", width: 80, cellrenderer:this.updaterenderfunction} i using cell renderer updaterenderfunction(params){ var espan = document.createelement('button'); espan.innerhtml = "update"; var data = params.node.data; espan.addeventlistener('click',()=>{ //here want call service }) return espan; } try worked me...give bind(this) after updaterenderfunction below. { headername: 'update', field: "update", width: 80, cellrenderer:this.updaterenderfunction.bind(this)}

javascript - Dynamic images don't load -

app downloads images @ every start in './res/' folder near index.android.js using rnfs l|: var logopath = rnfs.documentdirectorypath+'/res/'; rnfs.downloadfile({ fromurl: host+'logos/'+i.logo, tofile : logopath+i.logo }).catch(function(e){console.log(e)}) and try load image following code: <view style={styles.conferenceverticalitemimagewrap}> <image style={[styles.conferenceverticalitemimage,{height: height*264/1920, width: height*264/1920}]} resizemode='contain' source={{uri:logopath+this.props.logo}}/> </view> images downloads correctly , folder contains images don't appear on screen. try use absolute url instead. e.g. rnfs.mainbundlepath + "/res/" + image to adapted folders. , maybe should use 1 of other constant here: https://github.com/johanneslumpe/react-native-fs#constants btw, don't know how local image downloaded, should try make d

C#:How to evaluate a excel formula consisting of Name ranges using NPOI or any other library -

i have formula in excel cell using name range defined using name manager. how can evaluate formula using npoi or other library in c#? example: have formula below =if(isblank(\_namerange1\_),"0",2) where _namerange1_ defined "sheet1!$a$9:$ds$9" i managed after going through few blogs. may there better way below approach resolved issue using npoi library. string sheetname="sheetname"; // sheetname workbook int row=2;//some desired row int col=5 //some desired col xssfworkbook hssfwb = new xssfworkbook(new file("filepath"); isheet sheet = hssfwb.getsheet(sheetname); xssfformulaevaluator evaluator = new xssfformulaevaluator(hssfwb); //get cell formula defined names string formula=sheet.getrow(row).getcell(col).cellformula; //extract defined names formula var regexcollection=regex.matches(formula,"_\\w+"); foreach (match item in regex_regexcollection)