Posts

Showing posts from January, 2014

javascript - nodejs bootstrap project works local only -

ive been trying out different things, , looking various ways solve it, i'm in need of hints make work. i have working nodejs bootstrap project gulp. website functions locally. so in project have fiollowing files (among other folders) : gulpfile.js index.html package.json when locally run project via 'gulp dev' seems perfect. on heroku after deploying gives me error: npm err! missing script: start this makes sense, because indeed package.json doesn't have start script. how can work on local? any leads? thanks node.js file name index.js first before start move current files new folder called public in parent folder above public create file index.js once in parent folder above public run in command line directory created index.js file npm express --save this install mini framework node.js , save project.json config for index.js file content /// start var express = require('express'); var path = require('path') v

javascript - facebook social plug-in not showing up when added dynamically -

i adding facebook social plug in webpage when manually add : <div class="fb-comments" data-href="http://website.com/z" data-width="700" data-numposts="7" data-colorscheme="light"></div> it works , , when javascript code add , doesn't any ideas ? the js sdk goes through document once when initialized, such elements parse social plugins. if want parse content add document later, need call fb.xfbml.parse() . https://developers.facebook.com/docs/reference/javascript/fb.xfbml.parse/

PostgreSQL replication locale issues (Ubuntu master, Windows slave) -

master ubuntu 14.04, slave windows 2008 r2 server, both running postgresql 9.6.5 (64-bits). able setup , start replication per this guide . psql can confirm changes being replicated, pgadmin4 not let me connect due following error message: fatal: database locale incompatible operating system detail: database initialized lc_collate "en_ca.utf-8", not recognized setlocale(). hint: recreate database locale or install missing locale. it understanding locale "en_ca.utf-8" on linux , "english_canada.1252" on windows , not equivalent. pgadmin defect or did forget something? try on windows 2012 now.

Shutting down namenode hadoop cluster -

i'm trying setup hadoop cluster , following error:- $hadoop_prefix/bin/hdfs namenode -format re-format filesystem in storage directory /var/hadoop/hadoop-namenode ? (y or n) y 17/09/11 19:41:55 info namenode.fsimage: allocated new blockpoolid: bp-448039548-10.211.55.101-1505158915421 17/09/11 19:41:55 info common.storage: storage directory /var/hadoop/hadoop-namenode has been formatted. 17/09/11 19:41:55 info namenode.nnstorageretentionmanager: going retain 1 images txid >= 0 17/09/11 19:41:55 info util.exitutil: exiting status 0 17/09/11 19:41:55 info namenode.namenode: shutdown_msg: /************************************************************ shutdown_msg: shutting down namenode @ node1/10.211.55.101 im trying follow tutorial setup cluster. https://github.com/vangj/vagrant-hadoop-2.4.1-spark-1.0.1 this not error. before can start hdfs, need format namenode. similar before can run linux/windows need format disk.

Migrating from Solace 8.4 to 8.5 - error at Docker startup -

just installed , tried start solace 8.5 community edition in docker. had been running 8.4 weeks. 8.5 attempts start , dies following error: 2017-09-11t18:55:36+0000 ip-10-97-56-158 root[178]: /usr/sw adcmndisktrans.cpp:150 (admanager - 0x00000001) main(0)@dataplane(11) fatal file /usr/sw/internalspool/softadb/backingstore actual size(536870912) != expected size(805306368) rolling 8.4 runs fine. docker command is: docker run -v /data/vmr/adb:/usr/sw/adb -v /data/vmr/internalspool/softadb:/usr/sw/internalspool/softadb -v /data/vmr/jail:/usr/sw/jail -v /data/vmr/var:/usr/sw/var -v /data/vmr/internalspool:/usr/sw/internalspool -v /data/vmr/diags:/var/lib/solace/diags -d --network=host --uts=host --shm-size=4g --ulimit core=-1 --ulimit memlock=-1 --ulimit nofile=2448:38048 --cap-add=ipc_lock --cap-add=sys_nice --env 'username_admin_globalaccesslevel=admin' --env 'username_admin_password=admin' --name=solace8

c++ - Avoid memory allocation with std::function and member function -

this code illustrating question. #include <functional> struct mycallback { void fire() { } }; int main() { mycallback cb; std::function<void(void)> func = std::bind(&mycallback::fire, &cb); } experiments valgrind shows line assigning func dynamically allocates 24 bytes gcc 7.1.1 on linux. in real code, have few handfuls of different structs void(void) member function gets stored in ~10 million std::function<void(void)> . is there way can avoid memory being dynamically allocated when doing std::function<void(void)> func = std::bind(&mycallback::fire, &cb); ? (or otherwise assigning these member function std::function ) unfortunately, allocators std::function has been dropped in c++17. now accepted solution avoid dynamic allocations inside std::function use lambdas instead of std::bind . work, @ least in gcc - has enough static space store lambda in case, not enough space store binder object. std::fun

c# - Close button relaycommand binding -

i trying make command binding close menu item. found called relaycommand. understand reusable. i have following done: the contructor of main window: public mainwindow() { initializecomponent(); datacontext = new classmainformbtnviewmodel(); } the viewmodelclass: namespace qbox_0000.viewmodel { public class classmainformbtnviewmodel { public relaycommand closeapplicatiecommand { get; private set; } public classmainformbtnviewmodel() { closeapplicatiecommand = new relaycommand(closeapplicatie, canuse); } private void closeapplicatie(object parameter) { //application.current.shutdown(); messagebox.show("test"); } public bool canuse(object parameter) { return true; } } } the relaycommandclass: namespace qbox_0000 { public class relaycommand { readonly action<object> _execute; readon

python - Upload image received via Flask to Firebase Storage -

i trying upload image firebase storage. image passed via http post. request processed using flask. can't seem image upload correctly. when specify image's location can upload image, ruling out issue firebase or code. have tried file location, unfortunately flask has prevented safety(probably thing). there need process image before storing it?. i using postman send post request. @message_api.route('/messenger/message/send/picture/individual', methods=['post']) def send_individual_picture(): picture = request.files['picture'] firebase.storage().put(picture) since firebase.storage().put() expects file path, you'll need save upload file first before can store it. right have this: @message_api.route('/messenger/message/send/picture/individual', methods=['post']) def send_individual_picture(): picture = request.files['picture'] firebase.storage().put(picture) after this, picture insta

Modifying the code in R to make a loop function for plots in R -

i wondering how can make loop function have scatter plot of each variable vs gear , carb in 1 page. mean scatter plot of mpg va gear , scatter plot of mpg va carb in 1 page. again scatter plot of cyl vs gear , cyl vs carb in 1 page. since have many variables in real sets not want use code; attached (mtcars) b1<-mtcars[,c(1,10,11)] plot1 <- b1 %>% gather(-mpg, key = "var", value = "value") %>% ggplot(aes(x = mpg, y = value))+ facet_wrap(~ var, scales = "free") + geom_point() + stat_smooth() b2<-mtcars[,c(2,10,11)] plot2 <- b2 %>% gather(-cyl, key = "var", value = "value") %>% ggplot(aes(x = cyl, y = value))+ facet_wrap(~ var, scales = "free") + geom_point() + stat_smooth() and on.                    

python - how to use numpy polyfit to force scatter points linear fit pass through zero? -

x=np.asarray([1,2,4,5,7,8,9]) y=np.asarray([2,1,3,6,4,7,9]) m,b=np.polyfit(x,y,1) i have scatter points , try linear fit (y = m*x + b, b = 0) numpy polyfit . there way force interception b 0? can have variance? i googled , said np.linalg.lstsq may work don't know how manipulate it. , prefer np.polyfit . can work? no. np.polyfit doesn't have method removing lower order terms. here's how np.linlg.lstsq : m = np.linalg.lstsq(x.reshape(-1,1), y)[0][0] m 0.87916666666666654 this not same as: np.mean(y/x) 0.98520408163265305

linux - How to use init-functions? -

every operating system has librarys. of them gives opportunity more ore write less code. inti-functions 1 of these librarys but... what init-functions , how use it? in linux able use init-functions manage deamons , protocol in colored & uniform way. way easier handle recolor every answer. it stored in /lib/lsb/ under name init-functions . here have example: #!/bin/bash # script amir boudani ©amir boudani source /lib/lsb/init-functions # importing init-functions - log messages # use importing other scripts ore else: "source" / "." # use @ beginning of path "/" path has start root directory log_success_msg "starting test.sh" || true echo log_action_msg "info message" || true # info message log_success_msg "checking files" || true # success message log_warning_msg "free sto

r - Group columns based on information in an annotation matrix -

i seeking advice on how following task: i analyzing single-cell rnaseq dataset. have normalized expression data in table ( each column has unique cell id, each row gene). i have annotation matrix have information of each cell (each row cell id, each column piece of info (such patient id, site,etc.) for downstream analyses, have different grouping based on info available in annotation matrix. guys have suggestion how might able that???? for example, have expression_matrix<-matrix(c(1:4), nrow = 4,ncol =4, dimnames = list(c("gene1", "gene2", "gene3", "gene4"),c("cell1","cell2","cell3","cell4"))) annotation_matrix<-matrix(c("1526","1788", "1526","1788","controller","noncontroller","controller","noncontroller","ln","pb","ln","pb"), nrow = 4,ncol =3, dimnames = list(c("

angular - Is a "src" dir required under the top-level ng2 app dir for aot? -

i'm trying app running aot per documentation: https://angular.io/guide/aot-compiler i execute following aot compile command 'myapp' dir: "node_modules/.bin/ngc" -p ./ng2/tsconfig-aot.json and returned following error: error file 'c:/code/myapp/ng2/src/app/app.module.ts' not found. it looks command expecting 'src' dir first subdir under main ng2 app dir. ng2 app exists within context of parent .net mvc app, has lot of own special dirs. suspect default ng2 parent app dir named 'src' , causing confusion in up. do know if there's command option can pass exclude 'src' dir path compiler attempting execute against? or if there's aot workaround or if i'm doing incorrectly here? check files property in tsconfig-aot.json . in guide, looks this: "files": [ "src/app/app.module.ts", "src/main.ts" ] assuming haven't changed these, explain path requiring src

python - Scrapy Linkextractor -

i'm new programming. have tried everything. i have manage scrape in 1 page when try entire site get: [scrapy.extensions.logstats] info: crawled 0 pages (at 0 pates/min) here spider: import urlparse scrapy.http import request scrapy.contrib.spiders import crawlspider, rule scrapy.contrib.linkextractors import linkextractor class myspider(crawlspider): name = "municipio" allowed_domains = ["cm-leiria.pt"] start_urls = ["http://www.cm-leiria.pt/pages/"] rules = (rule (linkextractor(allow=("/pages/\d",),restrict_xpaths= ('//ul//li//a[@class="deph\d"]',)), callback="parse_items", follow=true), ) def parse_items(self, response): base_url = 'http://www.cm-leiria.pt/pages/215' in response.xpath('//a[starts-with(@href, "/uploads/") , not(contains(@href,":"))]/@href'): link = a.extract() i

ruby - Chef Template Does Not Evaluate chef_environment and name Correctly -

knife node show -l my-node -f json returns: { "name": "my-node", "chef_environment": "test" .. } we have created template, info.txt.erb: node = <%= node %> name = <%= node['name'] %> chef_environment = <%= node['chef_environment'] %> our recipe: template "#{app_dir}/info.txt" source 'info.txt.erb' ... end after chef run, node has info.txt file: node = my-node name = chef_environment = why knife show <node> command return different evaluated template file? how can change template file correct information? that should node.name , node.chef_environment . aren't attributes, can't use attribute access syntax them.

jQuery .is('input:hidden') function returns true if any input type element is not visible -

you can use jquery .is() function determine if html element of specific type. example, $(x).is('input:text') will return true if x references a <input type="text'> element. i noticed if make text (or other) input element invisible, use $(x).is('input:hidden') , returns true . to match <input type="hidden"> elements, must do $(x).is('input[type=hidden]') am missing here, or bug? thought :hidden referred element type , not visibility of element. here's requisite codepen: https://codepen.io/anon/pen/lzpdaj first of all, jquery method is , not checking element type, checking against jquery selector - https://api.jquery.com/is/ as selector, in css :hidden match type hidden, same selector has broader meaning in jquery. from docs - https://api.jquery.com/hidden-selector/ elements can considered hidden several reasons: they have css display value of none. they form elements

php - replace string in get_permalink() function? -

i'm struggling rewrite urls. bc facebook doesn't follow 301 redirects likes (ugh) i'm needing find way rewrite og:url parameter wordpress spits out http in there instead of https. i'm trying following no avail: <?php $oldlink = get_permalink(get_the_id()); $newlink = str_replace('https', 'http', $oldlink); ?> <meta property="og:url" content="<?php echo $newlink ?>"/> any ideas why method might not work? if you're using in header.php , page you're loading single post/page/custom post can use the_post(); before statement in order initiate loop. <?php the_post(); ?> <meta property="og:url" content="<?php $oldlink = get_permalink(get_the_id()); $newlink=str_replace('https','http',$oldlink); echo $newlink; ?>" /> the thing get_the_id() function works within loop, out initiating it returns fault results causing get_permalink function ret

java - How to call a class already implemented class in a different JFrame? -

i cant figure out how call class implemented in login.java(is jframe) in welcome.java(also jframe) this class have called upon in login.java. public class session { public session(string susername, string spassword, string sname, string sage, string ssex) { string username = suser; string password = spassword; string name = sname; string age = sage; string sex = ssex; } } this login.java code implementing class. if(rs.next()) { username=rs.getstring("usernames"); password=rs.getstring("passwords"); name=rs.getstring("names"); age=rs.getstring("ages"); sex=rs.getstring("sexes"); session s1 = new session(username, password, name, age, sex); } in welcome.java want call upon s1 so. s1.name or s1.username if s1 session class instance private member of login (extends jframe) class, there no regular way access s1 member outside login class. need use public accessor methods

filesystems - Interaction between git client and local file system -

i'm running git bash client on windows machine , use clone branches of remote repo directory named "localrepo" on windows machine. repo has 2 branches ("master" , "develop") , start out on branch "master". when open "localrepo" in windows file explorer, see .git sub-directory , various files , sub-directories of branch. when go git client command line , checkout branch "develop", git client manipulate windows file system see files on branch "develop" when go "localrepo" in windows file explorer? i assume git keeping state of branches in .git directory. is git creating symbolic links switches when branches changed? yes, after git checkout develop , git physically update localrepo windows folder files develop branch. try , see.

PHP store some data in mySQL for x hours (limited time) -

how possible store data in database limited time (like example 1 hour)? a user searches thing, logic executed server-side , search result loaded. result loaded, want store in mysql , keep x hours. after x hours data should deleted database. how possible in laravel or in php (it not matter me. mentioned laravel may have libraries this)? writing logic in sql or it's php task? how this? suggestions/links/solutions? thank much! is writing logic in sql or it's php task? doing php hassle because need send requests check if record expired , send delete. can achieved using events in mysql . i came across blog post might helpful . also dont forget check mysql documentation page

php - Error 1045 while installing phpmyadmin in linux(kali 2017) -

Image
i followed following steps while installing phpmyadmin , apache server , mariadb sudo apt install openssh-server sudo apt install apache2 sudo apt search php7.0 sudo apt install php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-curl php7.0-gd php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-zip sudo apt install php7.0-mysql mariadb-server mariadb-client sudo systemctl restart apache2.service chmod +x /var/www/html/ chmod +x /var/www/ chmod +x /var/ sudo apt install php7.0-mysql mariadb-server mariadb-client sudo mysql_secure_installation mysql -u root -p sudo mysql update user set plugin="" user='root'; flush privileges; exit sudo systemctl restart mysql.service mysql -u root -p sudo apt install php-gettext phpmyadmin here after gets error if try apt-get remove phpmyadmin again getting error 1045 can't remove also

swift - watchOS minimum padding too much -

Image
i trying recreate messages view on apple watch. how looks like. however, whatever try, can't seem rid of pre-set padding wkinterfacelabels come with. padding in "real" app me, i'd love negative padding. i tried containing group's spacing argument, tried putting labels groups , tried going setting fixed-height manually, helped little bit starts cutting off letters 'g' @ bottom leaves lots of space @ top. there way change that?

xampp - Page not found on localhost wordpress site -

help working on wordpress website on localhost using xampp. today changed site url , home url in phpmyadmin host plan on transferring site to, ran issues had revert localhost. but doesn't work! have tried 'localhost' , 'localhost/wordpress'. latter, can see site's header , footer , theme colors etc., main frontpage says "not found" , other menu pages not found. when try access wp-admin, can't find either! can't log admin panel. folders structure: c:/xampp/htdocs/wordpress inside wordpress folder, there's .htaccess, index.php, etc. , 3 folders: wp-admin, wp-content , wp-includes. i don't know why isn't working anymore, literally changed database's site url temporarily! nothing works , can't access admin panel. please help. in advance! make sure changed siteurl , home values in wp_options table localhost http://localhost/site delete htaccess file , try open site , see if have security plugin changes l

c# - kestrel use folder path in all urls -

how set setup url subfolder localhost:5000/rootfolder/controller i.e. localhost:5000/mysite/home var host = new webhostbuilder() .usekestrel() .usecontentroot(directory.getcurrentdirectory()) .useiisintegration() .usestartup<startup>() .build(); if want make application available @ /site , can use application path base teach application can run path base prefix well. just call usepathbase @ beginning of startup’s configure method: public void configure(iapplicationbuilder app) { app.usepathbase("/site"); // … app.usemvc(); } by doing that, if open site @ /site , work if opened without it, , generated links include path.

sql - Oracle Database Documentation Lock Modes Example -

Image
. oracle database documentation provides example of 2 transactions concurently obtaining explicit locking. believe there mistake, bottom(right) transaction should able obtain srx lock if 1st (left) transaction got rs lock. what opinion? want make sure indeed error. documentation link just done test, opinion right. result below: session 1: sql> lock table cenzhgl.lock_test in row share mode; table(s) locked session 2: sql> lock table cenzhgl.lock_test in exclusive mode nowait; ora-00054 sql> lock table cenzhgl.lock_test in share row exclusive mode nowait; table(s) locked oracle lock model mutex relationship below: lock mode | lock name | permit | exclusion --------------|-------------------------------|----------|-------------- 2 | row share | 2,3,4,5 | 6 3 |row exclusive table lock | 2,3 | 4,5,6 4 | share table lock | 2,4 | 2,

php - Retry Ajax Request 5 Times with 1 Second Interval -

i have verify.php file check database entry , return 1 if exists or 0 if doesn't. database updated between 0 5 seconds. @ least first 5 seconds return might 0. in page, want check verify.php's return ajax , retry 5 times 1 second interval between each checks. if @ time in 5 second check, received 1, exit checking loop , display success message. i have written checks once , don't know how make check x amount of times: <p id="status"></p> <script type="text/javascript"> var url = 'verify.php'; $('#status').text('please wait...'); $(document).ready(function(){ $.ajax({ type: 'post', url:url, success: function(msg){ if (msg == 1){ $('#status').text('success'); }else{ $('#status').text('failed'); } } }); }); </script> any appreciated. thanks. turn ajax call function have variable tracks

C: Getting Segmentation Error -

i have written code input user , save text file. int main(){ file *fp; fp = fopen("rahiv.txt", "w"); char s[80]; char a; gets(s); = s ; fputs(s, fp); } but if want write fputs part below, it's giving me segmentation error, how can typecast gets() function's return value , fix this! int main(){ file *fp; fp = fopen("rahiv.txt", "w"); char s[80]; fputs(gets(s), fp); } this unsafe code. i'll try address things in order, , answer question somewhere in process. 1) need make sure file opened successfully. isn't nice java/c#/python/other high level languages it'll throw exception. must check if(fp == null) { /*handle error*/ } 2) trying equate variables a , s , different types , not equivalent. char s[80] allocates array of chars 80 bytes long on stack. looks s of type char , of type char* , line a = s ... well, i'm not sure does. 3) gets can return more s

How can I echo each item in my PHP array rather than just the last? -

i have array in php (it has php complicated reasons go beyond scope of post): <?php $arr = array(div1, div2); foreach ($arr $value) { print_r($value); } ?> i have jquery i'm attempting use hide every element has class in array. <script> $(document).ready(function(){ $("."+"<?php echo $value; ?>").hide(); }); </script> however, hides elements class equivalent last item in array. in other words, items class div2 hide. how can make apply each item in array? you can take php array , use in javascript. easiest way use json: <?php $arr = array('div1', 'div2'); ?> <script> $(document).ready(function(){ var arr = <?=json_encode($arr);?>; arr.foreach((classname)=>$("."+classname).hide()); }); </script> or can join array , let jquery iterate on it: <script> $(document).ready(function(){ var arr = <?=json_encode($arr);?>; $('.

php - How to create a form to save into sql, sort, retrieve and export to excel -

i getting started php, mysql , phpmyadmin. the reason want learn have books database of own. i want create html / php form can enter books entry (stock received). want them store in mysql. once have enough books want export them excel using php or html sorting / filtering required data database , export them excel. they key thing before have save books titles in database. later using form want save stock received respective titles ability view , delete stock whenever required specific title (add stock / delete stock). any guidence highly appreciated. regards narendra s this question exceptionally broad. have decent idea there php/mysql , on, but, you'll have sit down , learn languages , on in order make happen. here links started. read on those, server set test on, , go there. https://www.tutorialspoint.com/php/php_and_mysql.htm http://www.freewebmasterhelp.com/tutorials/phpmysql

javascript - Tracking time and display it at next game -

i have assignment , bit stuck. assignment states: modify game time tracked , best time (or time beat) stored , displayed @ end of game , @ beginning of next game played. functionality assumes browser not closed , each successive game begun through "play again?" link. display of time beat shown below. i have files necessary, stuck in part. here code: <!doctype html> <html> <head> <title>recipe: drawing square</title> <script src="easel.js"></script> <script type="text/javascript"> var canvas; var stage; var placementarray = []; var tileclicked; var timeallowable; var totalmatchespossible; var matchesfound; var txt; var matchesfoundtext; var tileheight = 30; var tilewidth = 45; var border = 1; var globalpadding = 10; var margin = 10; var padding = 5; var texttiles; var flashcards = [ ["

How to get variable from javascript to php? -

Image
i want variable code value: /* link skor */ memory.prototype.cekskor = function(){ window.location = "./skor/index.php?value=" + this.nummoves; } memory.prototype._wingame = function() { var self = this; if (this.options.ongameend() === false) { this._cleargame(); this.gamemessages.innerhtml = '<h2 class="mg__onend--heading">keren!</h2>\ <p class="mg__onend--message">kamu memenangkan game ini dalam ' + this.nummoves + ' gerakan.</p>\ <button id="mg__onend--restart" class="mg__button">ingin bermain lagi?</button>\ <button id="mg__onend--skor" class="mg__button">cek skor?</button>'; this.game.appendchild(this.gamemessages); document.getelementbyid("mg__onend--restart").addeventlistener( "click", function(e) { self.resetgame();

How to get image element on XML document with PHP? -

i'm trying thumbnail links like: https://i.pinimg.com/236x/38/8f/c9/388fc91621d9d12db3d1211b39ab0fc1--flying-dog-pure-joy.jpg but reason getelementsbytagname doesn't return wanted. $newdom=new domdocument(); $xml=simplexml_load_file("https://www.pinterest.co.uk/sucastro/animals.rss"); $newdom->loadxml($xml); $out=$newdom->getelementsbytagname('img'); print_r($out); i tried $out=$newdom->channel->item->description->getelementsbytagname('img'); which failed. simplexmlelement object ( [@attributes] => array ( [version] => 2.0 ) [channel] => simplexmlelement object ( [title] => animals [link] => https://www.pinterest.com/sucastro/animals/ [description] => simplexmlelement object ( ) [language] => en-us [lastbuilddate] => fri, 48 jan 2017 33:33:33 +0000

swift - AppRTC mach-or errors -

i'm getting mach-o errors on clean install of apprtc in swift. i create new project in xcode 8.3.3 , run. i add: pod ‘apprtc‘ to podfile, , use pod install. when complete, disable bitcode. running on device, cleaned code , i'm stumped! seems apprtc not work pods swift. objective-c, no problem. not real solution, used static library this. also, downvoter have feedback why question not suitable?

Javascript function call from file -

so...my homework says... create function named calcbmi() performs calculation using values in weight , height text boxes , assign result bmi text box. convert value integer number using parseint() function. reference text boxes within function using documentobject.getelementbyid(name), , value attribute of each text box (in other words, don’t use function arguments aka pass values function). add event listener to call calcbmi() function i have done here. keep in mind javascript file being reference in html. whenever press calculate button nothing happens. function calcbmi() { var weight = parseint(documentobject.getelementbyid("weight")); var height = parseint(documentobject.getelementbyid("height")); var result = (weight * 703) / (height * height); var textbox = documentobject.getelementbyid('result'); textbox.value = result; } document.getelementbyid("submit"). addeventlistener("click", ca

machine learning - Voice assistant - intent classification with parameters -

classification of intent (ok, google find restaurant -> google find restaurant). can done in combination bag of words , neural net. there quite lot examples how achieve this. the question design of model can evaluate parameters given query? e.g. open web page "www.example.com". have encountered research paper or open source system covers functionality? spent 3 hours of research. found any. thank , points.

How to use CPUID instruction to get x86 CPU features correctly? -

i want write small program features of x86 cpus. after referring cpuid document, find there 2 sections: (1) eax=1 : ...... of january 2011, standard intel feature flags follows: ...... (2) eax=80000001h : ...... amd feature flags follows: ...... so means if cpu vendor genuineintel , should use eax=1 while if authenticamd , should use eax=80000001h execute cpuid instruction. understanding correct? after referring amd cpuid , intel cpuid documents, can learn flags different eax 1 cpuid instruction, need differentiate them.

javascript - NodeJS - Handlebars - Data not Parsed / Contains Nothing in Handlebars -

i have problem node js express & handlebars. in routes, i've tried collect data mongoose query. after that.. i've tried print via console.log before render view , parse array variable. code : console.log(datamenusebulan); res.render('laporan/index', {layout:false, penjualanhariini:penjualanhariini, datamenusebulan:datamenusebulan, datasetahunmak:datasetahunmak, datasetahunmin:datasetahunmin, dataseminggumak:dataseminggumak,dataseminggumin:dataseminggumin, penjualankemarin:penjualankemarin, penjualanbulanini:penjualanbulanini, penjualanbulanlalu:penjualanbulanlalu, csrftoken:req.csrftoken()}); in console, variable succesfully printed, result : image result in view, i've tried echo variable inside javascript tag code : console.log({{datamenusebulan}}); it's work array variable, not variable. have idea guys?

javascript - Excel data extraction using SheetJS/js-xlsx and its usage in AngularJS -

i want extract xlsx data , display onto webpage. have used sheetjs/js-xlsx extraction of data xl sheet. data getting extraced not sure how data angularjs further usage. /* set xmlhttprequest */ var url = "test.xlsx"; var oreq = new xmlhttprequest(); oreq.open("get", url, true); oreq.responsetype = "arraybuffer"; oreq.onload = function(e) { var arraybuffer = oreq.response; /* convert data binary string */ var data = new uint8array(arraybuffer); var arr = new array(); (var = 0; != data.length; ++i) arr[i] = string.fromcharcode(data[i]); var bstr = arr.join(""); /* call xlsx */ var workbook = xlsx.read(bstr, { type: "binary" }); /* workbook here */ var first_sheet_name = workbook.sheetnames[0]; /* worksheet */ var worksheet = workbook.sheets[first_sheet_name]; var xldata = xlsx.utils.sheet_to_json(worksheet, { raw: true }) console.log(xldata); } oreq.send(

c# - Rows cannot be added programatically in Gridview. Index Error -

hi want retrieve data database gridview. using custom grid here c# code try { int i=0; mysqlcommand cmd = new mysqlcommand("select accounts,credit,debit,sum(credit) c,sum(debit) d tbl_open_balance", con); dr=cmd.executereader(); while(dr.read()) { datagridview1.rows[i].cells[0].value=dr["accounts"].tostring(); datagridview1.rows[i].cells[1].value = dr["credit"].tostring(); datagridview1.rows[i].cells[2].value = dr["debit"].tostring(); datagridview1.rows.add(); i++; } datagridview1.borderstyle = borderstyle.none; datagridview1.alternatingrowsdefaultcellstyle.backcolor = color.fromargb(238,239,249); datagridview1.cellborderstyle = datagridviewcellborderstyle.singlehorizontal; datagridview1.defaultcellstyle.selectionbackcolor = color.darkturquoise; datagridview1.defaultcellstyle.selectionforecolor = color.whitesmoke; datagridview1.backgroundcolor = color.wh

python 3.x - Requests.history Not printing python3 -

i'm noob python programming. have simple problem. im using python3, in pycharm 2017.2.1, want print out request redirects. have googled seem doing right. no errors , response 200. missing? import requests url='http://httpbin.org/html' payload= {'url':'http://bing.com'} req = requests.get(url, params=payload) #print(req.text) print("response code: " + str(req.status_code)) if req.history: print ("request redirected") resp in req.history: print (resp.status_code, resp.url) print ( "final destination:") print(resp.status_code, resp.url) else: print("request not redirected") x in req.history: print(str(x.status_code) + ' : ' + x.url) output: response code: 200 process finished exit code 0 i think should use url: http://httpbin.org/redirect-to , url you're using not redirect request. else block not executed because applies loop. import re

protobuff.net - How to use protobuff in the serviceStack framework -

do have corresponding example? want convert transport format protolbuff now. thank you. please read servicestack's protobuf format docs shows example of registering protobufformat plugin info on need decorate dtos can serialized protobuf.

Which Design Pattern needs to be used in the scenario? -

i have following simple scenario: let's user enters number , expected outputs are: 1.collection of numbers odd , less entered input 2.same above numbers. 3.same above magic numbers etc. , on.. basically, given number user expects series of collections based on different criteria. may know design pattern suitable here? in advance.

ssms - How do I connect to an existing Access .mdb from Server Management Studio 17.2? -

i have taken on access database , have limited access experience , more comfortable in server management studio envrionment. how connect access database ssms can't seem right (which may caused lack of ms access experience). access database on shared network drive, accessed myself.

java - Is it necessary to add a constructor all the time in child class -

this question has answer here: does subclass need have constructor? 4 answers i creating child class extending parent class. my parent class public class bike { public int gear, speed; public bike(int gear, int speed){ this.gear = gear; this.speed = speed; } public void applybreak(int decrement){ speed -= decrement; } public void speedup(int increment){ speed += increment; } } my child class public class mountainbike extends bike { public mountainbike(int gear, int speed) { super(gear, speed); // todo auto-generated constructor stub } public static void main(string[] args) { // todo auto-generated method stub } } but here in base class if not use constructor throwing error. questions is necessary add constructor time in child class. if yes , if no

How to create products list in SugarCRM -

i new sugarcrm, don't know how register partner profile product app listings . i have created , activated account in sugarcrm , after searching partner profile section add products, don't see option create product in profile anywhere., please tell me whether in right way or not.? or required isv partner profile grade create product please advice.

ReactJS - .JS vs .JSX -

it confusing me when matter of creating react application. there plenty of examples available on internet. out of them using .js file while using .jsx file. i read .jsx file , says lets write html tags. same thing can written in .js file also. then actual difference between these 2 extensions .js , .jsx ? there none when comes file extensions. bundler/transpiler/whatever takes care of resolving type of file contents there is. there other considerations when deciding put .js or .jsx file type. since jsx isn't standard javascript 1 argue not "plain" javascript should go own extensions ie., .jsx jsx , .ts typescript example. there's good discussion here available read

Using exception filtering in c# 6.0 (with typeof()) VS. catching custom exception -

i have method manage exception handling below. question that, in case typeof exception our point, approach recommended? using catch (system.exception ex) when(ex.gettype() ==typeof(exconeexception)){...} or catch (exconeexception ex) {...} public t mymethod<t>(func<t> codetoexecute) { try { return codetoexecute.invoke(); } catch (system.exception ex) when(ex.gettype() ==typeof(exconeexception) ) { throw new exconeexception(ex.message,ex); } catch (system.exception ex) { throw new exctwoexception(ex.message, ex); } } update: solution has 3 projects, ui, services , dataaccess. each part has own custom exception-handler class. imagine that, code in question in service project. codes should call method execution. if there run-time error type of exconeexception, means error in service section, else, there should error in data access part; so, exctwo

cuda - How to generate random number inside pyCUDA kernel? -

i using pycuda cuda programming. need use random number inside kernel function. curand library doesn't work inside (pycuda). since, there lot of work done in gpu, generating random number inside cpu , transferring them gpu won't work, rather dissolve motive of using gpu. supplementary questions: is there way allocate memory on gpu using 1 block , 1 thread. i using more 1 kernel. need use multiple sourcemodule blocks? despite assert in question, pycuda has pretty comprehensive support curand. gpuarray module has direct interface fill device memory using host side api (noting random generators run on gpu in case). it possible use device side api curand in pycuda kernel code. in use case trickiest part allocating memory thread generator states. there 3 choices -- statically in code, dynamically using host memory side allocation, , dynamically using device side memory allocation. following (very lightly tested) example illustrates latter, seeing asked in ques

claims based identity - .Net core Authorize attribute in inherited controller -

i having trouble authorization policies. have basewebapicontroller action [httpdelete("{id}"), authorize(policy = "administrator")] public virtual async task<iactionresult> delete(int id) {} but in controller inherits above want give access users also, policy like: [httpdelete("{id}"), authorize(policy = "all")] public override task<iactionresult> delete(int id){} it seems regular users cannot access action. have search further errors in policy configuration, or since controller inherited,m it's attributes neglected? thanks the authorizeattribute attribute inherited , allows applied multiple times. that means when inheriting method has authorizeattribute , carried over. final function definition in subclass this: [authorize(policy = "administrator")] [authorize(policy = "all")] public override task<iactionresult> delete(int id) so route has 2 policies in place. kind of proble

Unique random number generation in c# -

Image
i using listing #1 develop multiple-choice q&a application. i retrieve, say, 1000 entries database. i select 6 random questions them , display them in form. i select 1 random question out of 6 ask. as can see, listing #1 has 1 serious issue. may generate duplicate numbers in each step , thereby asks same question more once ( to wipe off repeated). to solve this, have written listing #2 . but, listing #2 has serious issues: the call new uniquerandomnumber().next(0, 5); never returns 5. if _list.count near 5-7, stuck in while loop ever. i observed that, randomquestion.next() returns 0 of times. listing #1 private void startlearning() { if (_list != null) { _list.clear(); _list = null; } _list = _worddatabase.getbycorrectnessbelow(correctness_repetition); if (_list != null) { if (_list.count >= multiple_choice_count) { if (

javascript - Extending sap.m.PlanningCalendar -

i wondering if me out extending planning calendar. want extend 1 of parameters called calendar appointment (sap.ui.unified). currently, has few properties title, text, icon etc. want extend has 'project' property. this have far xml: <mvc:view controllername="amista_planningboard.controller.calendar" xmlns:mvc="sap.ui.core.mvc" xmlns:unified="sap.ui.unified" xmlns="sap.m" xmlns:custom="amista_planningboard.controls"> <vbox class="sapuismallmargin"> <planningcalendar id="pc1" startdate="{path: '/startdate'}" rows="{path: '/people'}" appointmentsvisualization="filled" appointmentselect="handleappointmentselect" showemptyintervalheaders="false" intervalselect="handleappointmentaddwithcontext"> <toolbarcontent> <title text="amista - planning boa

how to not break line in html input tag? -

i have 2 radio-type <input> (for gender) , want show them inline, not in 2 lines. i've tried display: inline; doesn't work. the output goes this: "male" first radio button "female" second radio button i need output this: "male" first radio button "female" second radio button also there lot of space between word "male" , radio button itself. so there 2 question have: how not break line when use 2 or more input button? how manage space between radio button , word came after it? here sample code use: <div class="field-wrap"> <label> gender<span class="req">*</span> </label> <input type="radio" name="usex" value="male" checked>male <input type="radio" name="usex" value="female"> female</div> </div>

swift - How to pass the same parameter multiple times in CoreData iOS predicate builder? -

i have uitableview uisearchbar let me filter data based on search text uisearchbar . the coredata table contains 3 attributes name, notes, date i want search 3 columns occurrence based on user search text. so tried on: let searchtext = searchtext.lowercased() let query = "name contains[cd] %@ or notes contains[cd] %@ or date contains[cd] %@" let predicate = nspredicate(format: query, searchtext, searchtext, searchtext) is there way pass same parameter ( searchtext ) 1 time? something java string formatter: let query = "name contains[cd] %1$@ or notes contains[cd] %1$@ or date contains[cd] %1$@" let predicate = nspredicate(format: query, searchtext) you can use substitution variables : let searchtext = searchtext.lowercased() let template = nspredicate(format: "name contains[cd] $srch or notes contains[cd] $srch or date contains[cd] $srch") let subvars = ["srch": searchtext] let predicate = template.withsubsti

javascript - jQuery MultiSelect can not enable a disabled -

i have several dropdowns, 1 of them enabled beginning on, others disabled <select class="someclass" name="somename" multiple id="someid" disabled> the enabling of disabled drop-downs depends on selection of values in first (enabled) dropdown, use following code $('#enableddropdown').on('change',function() { } in there (in further if statement) tried every possible combinations of: $('#someid').multiselect('enable'); $('#someid').multiselect('refresh'); $('#someid option').attr('disabled',false); $('#someid').prop('disabled', false); $('#someid').material_select(); $('#someid').removeattr('disabled'); but not works. dropdown remains disabled! edit: have $(document).ready(function () { } following... $('#someid').multiselect({ name : 'somename', columns : somenumber, placeholder : 'somepla

sql server - Syntax error in SQL code when query by two schema -

select [shop.code], [ful.storename] **database** [shopping].[dbo].[stores] shop inner join database [fulfillment].[dbo].[orderingsagas] ful on shop.code=ful.storecode i going query 2 schema. sql code , got 'an error near database . please me

Angular 2 : Logout all open tabs automatically when user logs out in one of them -

i have created login page, based on sessionstorage. on loading page have checked value of sessionstorage. if opened web page in more 1 tab , logout 1 of tabs, remaining pages should logout automatically. please me run script, when user view page or other way solve problem. on click of logout button logout() { const userloggedout = this.loginservice.changestatuslogout(this.isauthenticated.getloginstatus(), this.isauthenticated.getloggedinuserid()); if (userloggedout) { const link = ['login']; this.router.navigate(link); } } changestatuslogout(status: boolean, userid){ if (userid && status) { sessionstorage.removeitem('userid'); sessionstorage.removeitem('usergroup'); sessionstorage.removeitem('userlogedin'); return true; } } getloginstatus() { const checkstaus = sessionstorage.getitem('userlogedin'); if (checkstaus === 'true') {

protractor: finding an url which is present for milliseconds only -

if click on signout-button there first pagea, second pageb , third page again. want eliminate first 2 steps , show pagea only. , test protractor. test negatively - first have test positively. have function test url, didn't react. put directly code: signoutbutton.click().then(function () { browser.wait(function () { browser.getcurrenturl().then((url) => { ... evaluating or console.log(url); }); }, 2000); if so, once page b found, in other runs not. although have tell protractor wait something, in case quick find pageb? how can detect short moment of pageb (which visually see on screen)?