Posts

Showing posts from July, 2015

R code inside math notation R Markdown -

in r markdown, can inline r code chunk run inside single $ math notation (only * before), not double $$ math notation: * $h_o = `r 1 + 1`$ works, but: $h_o = `r 1 + 1`$ doesn't work, , neither does: $$h_o = `r 1 + 1`$$ the double $$ more flexible being able put math notation on multiple lines, how can add inline code chunks inside? i ran example , worked fine me! here link pdf , github .md documents generated. , here link rmarkdown document. i'm using r 3.4.1, knitr 1.16, , rmarkdown 1.6. perhaps should check version of rmarkdown , knitr. have noticed on years version updates, , using recent dev version, can fix litany of small issues arise.

Find the next date before a date with a matched ID number Excel -

i have list of data 200k plus lines. need search next order date before date, matches id number in excel. know can use index match find next date before given date, how when need id numbers match given id? have attached sample format of data searching in. problem not search range of dates, need next date before date. there multiple dates before given date, need pull 1 before. index match formula find next given date. =index(orders!b:b, match(min(abs(orders!b:b-f3)), abs(orders!b:b-f3), 0)) id date 1 7/22/2015 2 4/27/2016 3 7/6/2016 2 4/23/2016 another way state requirement find maximal date in b:b < f3 , has in a:a id specified in e3 . following formula does: =aggregate(14,6,orders!b2:b999/(orders!b2:b999<f3)/(orders!a2:a999=e3),1) aggregate(14, ...., 1) max result in given array the divisions criteria generate div!0 in array entries don't match criteria parameter 6 instructs function ignore error entries, including divisions 0 n...

angular - Getting multiple items out of this.router.events.subscribe() -

i subscribing on router events change title of page when routes change, so this.routersub$ = this.router.events .filter(event => event instanceof navigationend) .map(() => this.activatedroute) .map(route => { while (route.firstchild) route = route.firstchild; return route; }) .filter(route => route.outlet === 'primary') .mergemap(route => route.data) .subscribe((event) => { title = event['title'] ? `${event['title']}` : 'default title' this.title.settitle(title); }); my issue on scenarios, want set title value in url (part of route). how do here? know cannot subscribe url events having hard time figuring out map inside. here trying failing this.router.events .filter(event => event instanceof navigationend) .map(() => { return this.activatedroute }) .switchmap(route => { return ...

Adobe Acrobat Pro's PDF database has strange auto-formatted dates -

date number of people 11-jul-17 101-500 11-jul-17 20-nov july 17,2017 10-jan 18-jul-17 21-50 10-jul-17 20-nov 06-jul-17 21-50 12-jul-17 10-jan 13-jul-17 10-jan 10-jul-17 10-jan july 10,2017 21-50 the pdf form , pdf responses data looks fine, after exported csv, has strange vlues. for example date, date format no longer consistent. for number of people, responses such "1-10" people recognized "10-jan". how can , should fix it?

xslt 1.0 - Passing values from one template to another -

i trying passing value 1 template template. although found couple of example in forum i'm unable make it. below xml: <pi:paygroup xmlns:pi="urn:com.sample/file"> <pi:header> <pi:version>17</pi:version> <pi:payroll_company_name>abcd</pi:payroll_company_name> <pi:pay_group_id>0307</pi:pay_group_id> </pi:header> <pi:employee> <pi:summary> <pi:employee_id>12345678</pi:employee_id> <pi:name>test employee</pi:name> </pi:summary> <pi:position> <pi:business_title>lead learning specialist</pi:business_title> <pi:worker_type>p</pi:worker_type> <pi:position_time_type>full_time</pi:position_time_type> <pi:compensation_effective_date>2017-07-01</pi:compensation_effective_date> <pi:base...

javascript - Sequelize - Promise.All returning array of undefined -

the following query log out queried results: loans.findall({ attributes: option.loanattributes, include: option.loanincludes }).then(results => { console.log(extractquery(results)); }); however when wraps within promise.all function, returns array of undefined: promise.all([ loans.findall({ attributes: option.loanattributes, include: option.loanincludes }) ]).then(results => { console.log(extractquery(results)); }) promise.all(promisearraysizen).then(fulfilledpromisearraysizen) you have promise array of size 1 return fulfilled promise array of size 1. therefore need check results[0]. promise.all([ loans.findall({ attributes: option.loanattributes, include: option.loanincludes }) ]).then(results => { console.log(extractquery(results[0])) })

Best practices for Android Git branching -

help settle argument, in android project, our androidmanifest.xml has env variable build apk @ correct env s3 , other stuff. we have 3 separate git branches, dev, qa, , prod. should dev , qa manifest files point prod env? no, if using android studio, handled configuring build types. also not practice use branch differents environments, , if using secret ids not should committed this. you can create 3 buildtypes, debug, qa , release, when signed app, env vars of production. link buildtypes

Stack and git are incompatible in Windows 7? -

i have been using stack dependencies management , building system haskell programs in windows 7 pro without problems. stack --version version 1.3.2, git revision 3f675146590da4f3edf768b89355f798229da2a5 x86_64 hpack-0.15.0 i have installed git windows, , stack cannot download lts files anymore. seems stack trying using new git client instead of internal one. git --version git version 2.13.3.windows.1 the error when try create new project following: c:\proj>stack new newproject downloading template "new-template" create project "newproject" in newproject\ ... looking .cabal or package.yaml files use init project. using cabal packages: - newproject\newproject.cabal selecting best among 11 snapshots... fetching package index ...fatal: not git repository: '.git' process exited exitfailure 128: c:\dev\git\apps\git\cmd\git.exe --git-dir=.git fetch --tags failed fetch package index, retrying. removedirectoryrecursive: permission denied (a...

optimization - How optimize css/less by webpack? -

i have optimized js, how optimize css , less files? i'm not sure code (it have): { test: /\.less$/, loader: "style!css!autoprefixer!less" }, i tried use: https://github.com/webpack-contrib/less-loader no result, result error on build. maybe reason have 1 less file , inside lot of different import. , can import css, min.css, less. @import "hud/styling/hud.less"; @import "~video.js/dist/video-js.min.css"; @import "canvas/spots.css"; the main goal should have 1 js file (as have) css without comments , spaces generated less or css. there packaged called optimize-css-assets-webpack-plugin . simple css webpack setup use var webpack = require('webpack'); var path = require('path'); var extracttextplugin = require("extract-text-webpack-plugin"); var optimizecssassetsplugin = require("optimize-css-assets-webpack-plugin"); module: { rules: [{ use: [{ test: /\.(l...

azure documentdb - Unable to queryDocuments using a CosmosDb Sproc -

Image
i attempting create sproc in cosmosdb collection, unable execute query shown in examples: querydocuments api - https://azure.github.io/azure-documentdb-js-server/collection.html example using querydocuments - https://github.com/azure/azure-documentdb-js-server/blob/master/samples/stored-procedures/simplescript.js i wrote own sproc based off of simplescript.js looks like function() { function callback(err, docs, opt) { if (err) getcontext().getresponse().setbody(json.stringify(err)); else getcontext().getresponse().setbody(json.stringify(opt).concat(json.stringify(docs))); } var collection = getcontext().getcollection(); var collectionlink = collection.getselflink(); var x = __.querydocuments(__.getselflink(),{ query: "select * root r"},callback); } i'm using documentdbstudio 0.72 create sproc, , run it. response body (from setbody in callback function): {"currentcollect...

unity3d - Make IDE start parenthesis in second line -

Image
when create new unity script, contains stub: // use initialization void start (){ } i find myself rewriting // use initialization void start () { } because find easier read. i tried find settings under tools->option have ide automatically default, didn't find any. can achieved automatically somehow? the problem not visual studio script template used unity when create new script. modify script template , give left curly braces new line both start , update functions. the file named "81-c# script-newbehaviourscript.cs.txt" , can find @ path below: windows : c:\program files\unity\editor\data\resources\scripttemplates mac : /applications/unity/editor/data/resources/scripttemplates mac (since 5.2.1f1): /applications/unity/unity.app/contents/resources/scripttemplates 1 .open "81-c# script-newbehaviourscript.cs.txt" file notepad. should this: 2 .position mouse caret before start function's left curly braces pre...

ios - Tab Bar Item oversizing when using free PNG icon -

Image
i'm trying set tab bar item (tab image) apps. i'm using 1 of many png cc/free icons site; when attempt set them through storyboard, i'm getting visual bug oversize. i wanted know why happening/how fix it. i'm downloading them black thenounproject; they're not sizing correctly, nor color black. i've placed png in assets , dragged 3x slot, did make smaller (the picture shows smallest; 1x being quite larger). any idea how fix this? navigation bar, tool bar, , tab bar icons has fixed sizes mentioned in apple documentation. please check : human interface guidelines - custom icons tab bar icon size has be: recommended: 75px × 75px (25pt × 25pt @3x) 50px × 50px (25pt × 25pt @2x) maximum: 144px × 96px (48pt × 32pt @3x) 96px × 64px (48pt × 32pt @2x)

multithreading - C# Lock Statement -

im going use c# lock statement , im wondering if call function while inside lock, , function lock on same object program freeze? for example: object object; public void f0() { f1(object); } public void f1(object obj1) { lock (obj1) { f2(obj1); } } public void f2(object obj2) { lock(obj2) { /// operations using obj2 } } here function f0 calls function f1 lock, inside lock calls f2 lock. program freeze in f2 waiting object locked in f1? i have big program functions calling each other passing objects around, , need lock objects, may happen function call may lock same object, may locked twice, causing possible deadlock. it may difficult know if same objects gets passed around , may end getting locked twice. also program has multi-threading , multiple classes. also if 1 thread gets exception inside lock, somehow unwind , fix itself? anybody knows proper way this? have big program before start changing decide better find out proper way it. ...

does g++ with extern "C" really gives the same environment as gcc does? -

i writing code using other packages in c languages , in c++ langauges. code, needs work c routines, , c++ classes well. plan is, include header files in c extern "c" {} method , use g++ compile. so, copied headers in c directory , added headers , footers like, #ifdef __cplusplus extern "c" { #endif //... #ifdef __cplusplus } #endif however, still doesn't compile. made mock c program make clear how problem shows up. main.c #include <stdio.h> #include <a.h> //this problematic header file. int main() { struct mmm m; //some struct in a.h printf("how many times have compile this? %d\n",1000); return 0; } a.h #ifndef _a_h #define _a_h #ifndef ... #define ... ... #endif #include <b.h> #include <c.h> #endif and gives me same error messages while compiling mock program ones during compilation of real code working on. , preprocessor macro functions defined in b.h , c.h. want assure these header f...

Angular 2 Wildcard Subdomain Routing -

i'm new angular 2, understand concepts when routing subdomains, have wildcard dns record setup , want 1 angular application pick request when comes in. to make things little more fun client has api require unique api key each subdomain, need lookup clients api based on subdomain , there include in every request without making subsequent requests initial lookup service obtain api key before making subsequent requests data i'm interested in. a few questions arise on approach 1) create service lookup information based on subdomain. if how store on initial lookup in order not having keep requesting it. 2) better keep sort of information in json file , if how kept secure , more of config type of resource. 1) how persist data looked based on subdomain? (i don't want hit endpoint every time request loaded clients api key in order pass onto further api requests). 3) there way persist initial client data through services build dynamic headers in order wrap in every r...

What happens to the TCP congestion window when packet loss occurs at slow start stage? -

in tcp, packet loss can detected in 2 ways: timeout , 3 acks (for 1 packet, ie. loss packet). assume timeout has not been reached yet, happens congestion window if packet loss happens during slow start stage? congestion window still increase 1 when receiving first duplicated ack? for example, @ view of sender, window size 3: [1 2 3] packet 1 , ack (the ack packet 1) sent , received. therefore window size increases 1, ie. 4: [2 3 4 5] packet 2 sent it's lost. when packet 3 sent successfully, duplicated ack (still packet 1) arrives, window size @ point? 1) if window size increase due receiving of first duplicated ack (note sender doesn't know packet loss because there 1 duplicated ack , timeout has not been reached yet), should be: [2 3 4 5 6] 2) otherwise, perhaps because ack packet 1 has been received (because packet 1 sent successfully), window size may remain 4: [2 3 4 5] which 1 true tcp? many thanks! although might off topic @ stackoverflow, sti...

python - How can I check if one list is a subset of the another? -

here current code have: a = input('enter words: ') b, c = a.split() q = [] z = [] in b: q.append(i) j in c: z.append(j) letters in q: if letters in z: print('yes') it output 'yes' if letter in q in z . is there someway check if instances of characters in 1 list in another. like: for letters in q: if letters in z: #all print('yes') i believe want: if all(letter in z letter in q): print('yes') simplified full working code: q, z = input('enter words: ').split() if all(letter in z letter in q): print('yes') sample runs: $ python test.py enter words: cat tack yes $ python test.py enter words: cat bat

authentication - Cakephp 3 - Auth Login Return False -

what's problem code? controller , identify return false! database column senha (password) , email. , can not sign in. using hash, password 255 characters , right. it's not working! contacontroller.php public function initialize() { $this->loadcomponent('flash'); $this->loadcomponent('auth', [ 'authenticate' => [ 'form' => [ 'fields' => ['email' => 'email', 'senha' => 'senha'], 'usermodel' => 'conta', 'finder' => 'auth', ] ], 'authorize' => ['controller'], 'loginaction' => [ 'controller' => 'conta', 'action' => 'index', ], 'loginredirect' => [ 'controller' => 'conta', '...

c++ - Can I add padding to a QwtText object? -

Image
i adding qwtplotmarker qwtplot using following code: qwtplotmarker *tooltip = new qwtplotmarker(tr("tooltip")); qwttext label("02/01/17\n06:00:00\nvoltage: 4.02"); qcolor blue(qcolor(30, 140, 220)); label.setcolor(blue); label.setborderpen(qpen(blue, 1)); label.setborderradius(5); label.setbackgroundbrush(qcolor(65, 177, 225, 50)); qfont font("ms shell dlg 2", 8); label.setfont(font); tooltip->setlabel(label); tooltip->setlabelalignment(qt::aligncenter | qt::aligntop); tooltip->attach(this); this->replot(); where this points qwtplot object. with code above i'm getting following result: note in image letter v voltage overlapped border. is possible add padding qwttext (or maybe qwtplotmarker !?), can result following one? i'm using qt 5.3.2 , qwt 6.1.0 .

django - Connecting to stream -

i building web app using django use get-stream,i have tried before using tutorial, got working first time earlier year, when run of web apps (test , official) error seem not understand, error seems api keys , correct , have double checked them. error running server, making migrations , syncing databases. followed steps again , did not luck. thank in advance help. screen shot of get lekau@lekau ~/documents/mentorearth.com/mentorearth $ python manage.py runserverunhandled exception in thread started traceback (most recent call last): file "/usr/local/lib/python2.7/dist-packages/django-1.11-py2.7.egg/django/utils/autoreload.py", line 227, in wrapper fn(*args, **kwargs) file "/usr/local/lib/python2.7/dist-packages/django-1.11-py2.7.egg/django/core/management/commands/runserver.py", line 117, in inner_run autoreload.raise_last_exception() file "/usr/local/lib/python2.7/dist-packages/django-1.11-py2.7.egg/django/utils/autoreload.py...

Log in to different Firebase Database Via command line -

i trying access firebase database via command line. have had database have been working without problems. today created second database work command line can not figure out how access one. have tried logout , log in via command line doesn't work , doesn't give me options choose database want work from. help! edit: can access database command line when run python scripts call database says still unauthorized.

android - java.lang.ClassNotFoundException: com.mysql.jbdc.Driver with .jar in the libraries -

i've inserted .jar driver libraries, still have issue: java.lang.classnotfoundexception: com.mysql.jbdc.driver @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderbase.java:1285) @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderbase.java:1119) @ java.lang.class.forname0(native method) @ java.lang.class.forname(unknown source) @ conectamysql.obtemconexao(conectamysql.java:12) @ logindao.inserirlogin(logindao.java:8) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.apache.axis2.rpc.receivers.rpcutil.invokeserviceclass(rpcutil.java:256) @ org.apache.axis2.rpc.receivers.rpcmessagereceiver.invokebusinesslogic(rpcmessagereceiver.java:121) @ org.apache.axis2.receivers.abstractinoutm...

javascript - YouTube iFrame API Video Intermittently Playing on Mobile Devices -

i've spent way many hours on little success. have client site has youtube video popup when page loads. autoplays on desktop , shows youtube play button on mobile since autoplay not supported on mobile. using iframe js api instantiate video player (code examples below). setup working perfectly on desktop, on mobile devices (android or ios), between myself , coworkers, clicking youtube play button plays video 80% of time. rest of time video loading spinner spins , nothing happens. if close reload player using site controls play, not initially. i know not issue majority of users viewing site know our client going go ape crazy if, out of 100 reloads on iphones, 10 of them result in behavior. i instantiating player follows: 1) including "hard copy" of youtube iframe api js on site first. 2) have object controlling display of youtube "modal" window contains player target -- when function called following: // write div element container _instance....

scripting - rerun a batch file including a script after it had a timeout -

i have script want running 24/7. experiences lot of timeout errors. tried putting script instructions in batch file , write instruction x100 times crashes timeout, there way make sure after each crash script gets reran? thanks!

powerpoint - How to change slide orientation without changing text size -

my company has moved powerpoint 2010 powerpoint 2016. i've noticed annoying difference in how slide orientation change functionality works. previously, text font sizes remain same. now, text font sizes smaller every time orientation changed. how can prevent text font size changing? (i'm happy provide custom code buttons)

algorithm - Most probable path taken to reach a particular node in graph -

we have system customer comes , interacts, triggers jobs , many actions. have 1000s of such users. each job has name , our backend database has data customer interactions. these jobs fail often. know why particular job failed based on inputs, want find path taken user (journey) before reached failure job. want see if can improve experience before failure avoided. example (hypothetical), login->create file-> save file -> download file. download file failing error. happens when save has completed. if have done operation between save file , download, down load not fail. hidden bug possibly. the question - given history of 3000 users graph traversal (take paths of size 5 [as moving window]) build system when asked ** "what probable paths reach node x" gives top 5 paths reach x. i have created nodes [jobname][state], example, loginsuccess->createfilesuccess->savefilesuccess->downloadfailed. x typically [job name]failed node query. have 50 jobs...

Python word match -

i have list of urls , i'm trying filter them using specific key words word1 , word2, , list of stop words [stop1, stop2, stop3]. there way filter links without using many if conditions? got proper output when used if condition on each stop word, doesn't feasible option. following brute force method: for link in url: if word1 or word2 in link: if stop1 not in link: if stop2 not in link: if stop3 not in link: links.append(link) here's couple of options consider if in situation. you can use list comprehension built in any , all functions filter out unwanted urls list: urls = ['http://somewebsite.tld/word', 'http://somewebsite.tld/word1', 'http://somewebsite.tld/word1/stop3', 'http://somewebsite.tld/word2', 'http://somewebsite.tld/word2/stop2', 'http://somewebsite.tld/word3', 'http://somewebsite.tld/stop3/wor...

Xamarin Android Google Map - Add marker where user clicks -

in xamarin forms, using custom renderer in android map have implemented using android.gms.maps want write functionality adds marker in area user clicked on map. public async void onmapready(googlemap googlemap) { map.mapclick+= handlemapclick; } in handlemapclick() function, how use addmarker() function add marker area user clicked on map? the googlemap.mapclickeventargs contains "point" contains lat/long of user' click. create markeroption , assign point , add map. googlemap.mapclick += (object sender, googlemap.mapclickeventargs e) => { using (var markeroption = new markeroptions()) { markeroption.setposition(e.point); markeroption.settitle("stackoverflow"); // save "marker" variable returned if need move, delete, update it, etc... var marker = googlemap.addmarker(markeroption); } };

How to permanently delete a specific entry from Vim's command-line history without losing the changelists of the recently edited files? -

when execute vim ex command, gets saved in command-line history, can access opening command-line window q: . however, sometimes, want able remove of them permanently. example, if execute command :a , subsequent commands in command-line window recognized elements of syntax group viminsert , linked highlight group string , colored in cyan in colorscheme. to fix syntax highlighting, try delete :a command command-line window hitting dd , entry removed while window opened. close it, , reopen later, :a command back. make removal permanent, tried add autocmd in vimrc : augroup my_cmdline_window au! au cmdwinleave * call s:update_history() augroup end fu! s:update_history() abort let new_hist = getline(1, '$') call histdel(':') in new_hist call histadd(':', i) endfor endfu it calls function, updates command history reading current window, before closing it. works while current vim session running, quit start new one, delete...

javascript - How to cycle through tasks and keep track of it in PHP -

i'm developing web application in php in user can create tasks other users compete. those tasks stored in mysql database. my question is, how can cycle through tasks database , present users while keeping track of tasks user has completed avoid presenting same task user. while providing user created task number of users have completed his/her task. how can accomplish in php? well, far can see, think many - - many relational tables looking for, assuming user can many tasks , task can done multiple users. need 3 tables: tasks: task_id , task_name , whatever_else_you_need_like_details users: user_id , w/e relations: task_id , user_id , status <- last 1 checking weather specific task done specific user or in general see tasks assigned user status , vica versa. read on mano-to-many relations , foreign keys , left/right joins :)

amazon web services - Undefined resource AWSEBLoadBalancer -

i trying create eb application using eb cli multiple docker container. have applications running on 2 ports need listen on ports. tried configuration on .ebextensions/elb-listeners.config encounter error of error: service:amazoncloudformation, message:template error: instance of fn::getatt references undefined resource awsebloadbalancer . below configuration. option_settings: aws:elb:listener:8745: listenerprotocol: http instanceprotocol: http instanceport: 8745 aws:elb:listener:3517: listenerprotocol: http instanceprotocol: http instanceport: 3517 resources: port8745securitygroupingress: type: aws::ec2::securitygroupingress properties: groupname: {ref : awsebsecuritygroup} ipprotocol: tcp toport: 8745 fromport: 8745 sourcesecuritygroupname: { "fn::getatt": ["awsebloadbalancer", "sourcesecuritygroup.groupname"] } sourcesecuritygroupownerid: { "fn::getatt": ["a...

java - Spring WebFlux: Emit exception upon null value in Spring Data MongoDB reactive repositories? -

i'm trying learn how use mongodb reactive repositories using spring-boot 2.0.0.m2 , fear i'm not doing things intended. this 1 of methods, tries find user email. if there none, method should throw exception. @override public mono<user> findbyemail(string email) { user user = repository.findbyemail(email).block(); if(user == null) { throw new notfoundexception("no user account found email: " + email); } return mono.just(user); } the repository extends reactivecrudrepository<user, string> , fear using .block() i'm preventing method being reactive. i'm new reactive programming, , i'm having hard time find documentation on it. can please point me in right direction? reactive programming requires flow end-to-end reactive gain actual benefits come reactive programming model. calling .block() within flow enforces synchronization , considered anti-pattern. for code, propagate mono obtain reactivecrudrepo...

Error in Jenkins Gradle builds. NEGOTIATE authentication error: Invalid name provided (Mechanism level: KrbException: Cannot locate default realm) -

Image
i building gradle project in jenkins. have used jenkins extensively earlier, maven , without corporate proxy. scenario: 1) systems behind corp proxy 2) gradle project gradle wrapper build. 3) working jenkins master( linux based) 4) gradle.properties file complete proxy details. so in scenario, have proxy, have created gradle.properties necessary proxy details , triggered jenkins build. seeing error( or warning) in jenkins build log. the build compiles , creates jar file. any idea on why happening , workarounds / solution. i have checked this, solutions not working. gradle issue contents of gradle.properties. systemprop.http.proxyhost=somehost systemprop.http.proxyport=8080 systemprop.http.proxyuser=username systemprop.http.proxypassword=somepasswrd systemprop.https.proxyhost=somehost systemprop.https.proxyport=8080 systemprop.https.proxyuser=username systemprop.https.proxypassword=somepasswrd systemprop.http.nonproxyhosts=localhost|...

php - shortest code to find the field value of any node in drupal -

i have been using code in drupal 7 value of node's field: $node = node_load($nid); $rate = $node->field_rate[und][0][value]; how $rate value without using long array syntax? after research $field = field_get_items('node', $node, 'field_rate') $rate = $field[0]['value']; but still long if need n number of fields. field_get_items best way value because manage language. otherwise can make sql query if want more field. can create custom function : /** * @param $entity_type * @param $entity * @param array $field_names // field_names * @param null $langcode * @return array */ function multi_field_get_items($entity_type, $entity, $field_names = array(), $langcode = null){ $field_values = array(); foreach ($field_names $field_name){ $data = field_get_items($entity_type, $entity, $field_name, $langcode); if(is_array($data) && count($data) > 1){ foreach ($d...

xamarin.android - Xamarin Forms - passing value from Xaml.cs to custom renderer -

i have page called mappage.xaml.cs , on page's constructor have argument called bool isfirehazard . in custom renderer custommaprenderer.cs in android project, want check boolean see whether true. how reference boolean custom renderer? you need store isfirehazard passed constructor in custommap object member. in custommaprenderer can access protected override void onelementchanged (elementchangedeventargs<xxx> e) { base.onelementchanged(e); if (e.newelement != null) { var formsmap = (cusommap)e.newelement; if(formsmap.isfirehazard) { } } }

angular - Angular2 Router URL breaks at & -

after updated latest angular v4.3.2 urls break @ & value, example have route /:value want value from: http://localhost:4200/one&two but redirects me to: http://localhost:4200/one and since value url dynamic, many can have & cannot display correct result. using customurlserializer managed replace %26 & , navigating thru router inside app works still @ initial page load url gets splitted: import { urlserializer, urltree, defaulturlserializer } '@angular/router'; export class customurlserializer implements urlserializer { parse(url: any): urltree { const dus = new defaulturlserializer(); return dus.parse(url); } serialize(tree: urltree): { const dus = new defaulturlserializer(); const path = dus.serialize(tree); return path.replace(/%26/g, '&').replace(/%2b/g, '+'); } } is there solution disable url breaking @ & ? ok know & used special character inside router if need ...

javascript - how to export the 'hidden div' element as PDF without showing it on the UI -

please consider following hidden div element. using hidden element construct pdf contents , trying download pdf. html elements declared below. <div id="griddata" style="display:none;"> <div id="reportheader" style="display:none;"> consider other elements want show in pdf here </div> </div> and below kendo export chart pdf code, call through loadpdf function. function loadpdf() { try { $("#griddata").show(); $("#reportheader").show(); if ($("#chartdiv").html() != null && $("#griddata").html() != '') { settimeout(function () { kendo.drawing.drawdom($("#griddata")) .then(function (group) { // render result pdf file return kendo.d...

sql server - Sql find Row with longest String and delete the Rest -

i working on table approx. 7.5mio rows , 16 columns. 1 of rows internal identifier (let's call id) use @ university. column contains string. so, id not unique index row, possible 1 identifier appears more once in table - difference between 2 rows being string. i need find rows id , keep 1 longest string , deleting every other row original table. unfortunately more of sql novice, , stuck @ point. if help, nice. take @ sample: select * #sample (values (1, 'a'), (1,'long a'), (2,'b'), (2,'long b'), (2,'bb') ) t(id,txt) delete s ( select *, row_number() on (partition id order len(txt) desc) rn #sample) s rn!=1 select * #sample results: id txt -- ------ 1 long 2 long b

typescript - Ionic3, Angular 2, rxjs object assign page variable -

i doing ionic3 project. , here's question. back-end : used rxjs firebase simple , nice realtime data. front code here: i want data keep consistency. made service brings data , assign each page variable this. [.ts file] public dogmodel = new dogmodel(); constructor( ,public testservice: testservice) { this.dogmodel = this.testservice.dogmodel; } [html file] <div>{{dogmodel.state}}</div> and works well. when data changed in service, don't know how service data re-assign page variable @ all. , 1 more, if change code this, this.dogmodel.state = this.testservice.dogmodel.state; i can see log changing data in service, couldn't see change in page. know this? part of service.ts constructor( public db: angularfiredatabase ) { db.object( this.firebaseurl + '/dogstate/test1234') .subscribe( (dogstate) => { object.assign(this.dogmodel, <dogmodel>dogstate); console.log(this.dogmodel); }); ...

Android MVVM DataModel with Context -

i trying learn & implement mvvm databinding in app. facing difficulties in understanding/deciding few things. i have 1 header view in app need use in multiple activities, created this view_header.xml headerviewmodel.java (implements java.util.observer) headerdatamodel.java (extends java.util.observable) where headerviewmodel bound view_header.xml . include view_header.xml in activity_xyz.xml & set viewmodel of header view xyzactivity this, xyzviewbinding.setheadervm(new headerviewmodel(new headerdatamodel(mcontext))); now have questions based on this: 1) headerdatamodel needs context work sharedpreference & broadcastreceiver , initialize inside xyzactivity instead of headerviewmodel - correct approach? 2) had rely on broadcast receiver update header view, registered inside constructor of headerdatamode . headerdatamodel observable , whenever receive broadcast, call notifyobservers() observer(headerviewmodel) detects & updates view.- correct ap...

Convert a lists in list to a CSV file by Python -

i hope convert data [[2,3,1],[11,2,4],[8,9,14]] csv file , format (numbers in each line in different columns) line1: 2 3 1 line2: 11 2 4 line3: 8 9 14 however, when use following codes ( list name of list should converted): myfile = open('/users/user/desktop/list245.csv', 'wb') wr = csv.writer(myfile, quoting=csv.quote_all) wr.writerow(list) the result is: line 1: [2,3,1],[11,2,4],[8,9,14] . namely, every numbers in first line different groups. you need convert list of list list first. from itertools import chain row = list(chain.from_iterable([[2,3,1],[11,2,4],[8,9,14]])) then can write csv file with open('/users/user/desktop/list245.csv', 'w') myfile: wr = csv.writer(myfile, quoting=csv.quote_all) wr.writerow(row)

php - Sum of two indexes which are having same values with multi dimension Array -

i working multi dimensional array below php, $return_array= array ( [0] => array ( [0] => 3_mar_2017 [1] => 0 [2] => 19 [3] => 7 [4] => 13 [5] => 3 [6] => 0 [7] => 42 ) [1] => array ( [0] => yet closed [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 1 [6] => 0 [7] => 1 ) [2] => array ( [0] => 3_mar_2017 [1] => 0 [2] => 7 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 7 ) [3] => array ( [0] =...

mysql - How to find out which columns are similar in two sql tables based on their values? -

i have 2 tables in mysql 100+ columns. need figure out columns in both tables have of same values. need way find out columns matching in terms of type , values in them can use them in joins , extract results them. can convert tables in excel sheet , apply vb script well. kind of appreciated. there's no magical sql query can run determine logic behind how database designed. can check table schema see if there foreign keys enabled, that's it. select * information_schema.columns table_schema = 'my_database_name' , table_name ='my_table'; based on how describe tables, given design sounds... odd. hope whoever designed left documentation. last resort going dumping data , looking patterns.

php - How do I calculate the average rating of the detail rating? -

Image
my code : <?php $rating = 5; $rating_detail = '{"3":"1","4":"2"}'; $array_data = json_decode($rating_detail, true); if(array_key_exists($rating, $array_data)) { $value = $array_data[$rating]; if ($value !== false) { $array_data[$rating] = (string)((int)$value + 1); } $rating_detail = json_encode($array_data); } else { $data = substr($rating_detail, 0, -1); $rating_detail = $data.',"'.$rating.'":"1"}'; } echo '<pre>';print_r($rating_detail);echo '</pre>';die(); ?> if code run, result : {"3":"1","4":"2","5":"1"} it's detail rating of store note : 3 = rating 3, 1 = number of users giving ratings : 1 4 = rating 4, 2 = number of users giving ratings : 2 5 = rating 5, 1 = number of users giving ra...

ios - didDeselectRowAt never called -

this question has answer here: why -diddeselectrowatindexpath not being called? 8 answers i have uitableview, uitableviewdelegate set this: tableview = uitableview() tableview.delegate = self tableview.datasource = self in delegate implement (among others) functions func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) func tableview(_ tableview: uitableview, diddeselectrowat indexpath: indexpath) my custom cell inherits uitableviewcell overrides setselected way: override func setselected(_ selected: bool, animated: bool) { super.setselected(selected, animated: animated) if selected { // visual updates (with small animation) } else { // visual updates } } the problem that, when tapping on cell, didselectrowat called , never diddeselectrowat , hence, cell shown selected. doing wro...

.net - Compiled content file (.JS) are not including in MSI packages -

i have added setup project(windows installer) web application generate msi packages. after building solution using devenv generating msi file. have typescript files in our web application project compiled during build process , generate corresponding .js (javascript) files. mentioned javascript(.js) files result of compiling .ts files not including in msi packages. 1 on issues. have added content files output of setup project.

xamarin.ios - How to add copy paste functionality in xamarin (for both android and ios) -

in project, have 1 entry containing link , 1 "copy" button. on "copy" button want copy link can paste anywhere in browser or in message. use clipboard manager class. https://developer.xamarin.com/api/type/android.content.clipboardmanager/ add text clipboard user can paste anywhere. code : clipboardmanager clipboard= (clipboardmanager)getsystemservice(context.clipboardservice); clipboard.text = "your text";

version control - PhpStorm & Git on remote server -

i new git , phpstorm. maybe on wrong track here, use remote webserver, web application hosted, development server. ( sure have exact same webserver config , version ) is there way deploy different git branches different folders, in order make them accessible via webserver. let's have branch 'newfeatures' , branch 'bugfixes', able access both branches 2 different urls, ' http://foo.bar/versions/newfeatures ' , ' http://foo.bar/versions/bugfixes '. what best way ( phpstorm ) ? or put cart before horse here ?

Validation for adding atleat three skills in input box using jquery or javascript -

need add validation adding atleast 3 skills in textbox. having form applying job in there option entering primary skills user knows , separated comma.so need add validation if user enters 1 skill while submiting form should show message atleaset 3 skills required. using codeigniter php <div class="primaryskillss"> <input type="text" class="form-control primaryskills" name="primary_skills" value="<?php echo set_value('primary_skills');?>" placeholder="primary skills(enter 3 skills separated comma)" required> <?php echo form_error('primary_skills', '<div class="error">', '</div>'); ?> </div> <button type="submit" class="btn btn-success successss" id="submits">submit</button> if(substr_count($_post[...

javascript - Accessing the Node ReadStream -

i have piece of code wrapped in promise. piece of code reads image form http, various things, , @ end sends aws.s3.putobject. looks (simplified): please note form multiparty object. form.on('part', (part) => {//form multiparty filecount++; let tmpfile = path.join(os.tmpdir(), `${userid}_${timeprefix}_${path.basename(part.filename)}`); part.pipe(fs.createwritestream(tmpfile)); part.on('end', () => { resolve(fs.createreadstream(tmpfile)); }); part.once('error', (error) => { handleerror(error); }); }); form.once('error', (error) => { handleerror(error); }); form.parse(request); }).then((imagestream) => { //here call aws s3.putobject. return promise }).then(() => { return new ok(); }); in essence stream made on created image , sent aws. wanted manipulation on binary level (read file signature, check if image). got work this: form.on('part', (part) => { fileco...

android - FIxing google contacts display fields -

i use gsuite , android. ever since using international lg phone, have save names bit weird. if make contact called f:mat l:johnson then looks fine on android. when open https://www.google.com/contacts/ user displayed johnsonmat. if click ... still have f:mat l:johnson it's somehow display name backwards , no space. now have 500 contacts saved phone on time , can't use gmail because can't find users f:mat. way name pop start type johnsonm. firstly can't remember last names, secondly if have 20 johnsons can't skip them. is there way fix these via script?

Spark streaming job exited abruptly - RECEIVED SIGNAL TERM -

the running spark streaming job, supposed run continuously, exited abruptly following error (found in executor logs): 2017-07-28 00:19:38,807 [sigterm handler] error org.apache.spark.util.signalutils$$anonfun$registerlogger$1$$anonfun$apply$1 (signalutils.scala:43) - received signal term the spark streaming job ran ~62 hours before receiving signal. i couldn't find other error/ warn in executor logs. unfortunately haven't set driver logs yet, not able check on specific issue deeper. i using spark cluster in standalone mode. any reason why driver might send signal? (after spark streaming ran , more 60 hours)

c# - .Net 2.0 - System.DateTimeOffset Best practice -

we have old database stores date , time smalldatetime. date , times generated different applications code: syste.datetime appointmentdate = system.datetime.now; we want migrate database make timezone independed. decided use sql datetimeoffset data type because comes need. stores utc date , offset... perfect. unfortunately have extremely old applications based on .net 2.0. there no system.datetimeoffset. what best way develop timezone awareness application in .net 2.0? store milliseconds since 1970-01-01 long data type in database , convert system.datetime in our application? lose timezone store date , time smalldatetime in our database use system.datetime.utcnow generate date , time on client side? lose timezone too. background our migration question: azure app service - datetime changes during sync any ideas?