Posts

Showing posts from April, 2010

spring - Not able to connect to ActiveMq installed in remote machine -

i trying connect activemq installed in remote machine.but not connect queue 1 system in same network.can me solving   [t#0.container-1] o.s.j.l.defaultmessagelistenercontainer : not refresh jms connection destination 'requestsqueue'  

node.js - How can I find a tag inside a document in Javascript -

i want find out if document -which html file- has "some" tags. if so, want attributes. i tried var data = require('test.html'); if(data.tolowercase().indexof('<iframe') > -1|| data.tolowercase().indexof('<iframe>') > -1){ console.log('yeaaah exist'); // iframe attributes } i able find if tag exist, how can attributes? on server side. okay, got done using cheerio var cheerio = require("cheerio"); var url = "./test.html"; // if not work try absolute url download(url, function(data) { if (data) { // console.log(data); var testdata = cheerio.load(data); // tag use testdata("sometag") console.log(testdata("sometag").length); } });

bash - Why is 'if' statement not working? -

i don't seem understand why if statement isn't working. reason doesn't work , hope can give me advice! function startup { #budate bevat het jaartal,maand en dag van nu. budate=`date +%y%m%d` #maakt directory aan in backup map met datum als naam mkdir backupmap/$budate } function getday { dow=$(date +%u) backuptype="" case $dow in '1' ) #maandag backuptype="inc" ;; '2' ) #dinsdag backuptype="inc" ;; '3' ) #woensdag backuptype="inc" ;; '4' ) #donderdag backuptype="inc" ;; '5' ) #vrijdag backuptype="full" echo "got date" ;; '6' ) #zaterdag backuptype="inc...

python - type error when using class inheritence -

i have following code: class sphericalrefraction(opticalelement): def __init__(self, r0, normal, curvature, n, h): self._r0 = r0 self._normal = normal/npl.norm(normal) self._curvature = curvature self._n = n self._aperture = h def outputplane(sphericalrefraction): def __init__(self, r0, normal, h=15): sphericalrefraction.__init__(self, r0=r0, normal=normal, curvature=0, n=1, h=h) but when construct class outputplane in main : screen = r.outputplane(np.array([0,0,f]),np.array([0,0,1]), 5) i have following error: typeerror: outputplane() takes 1 argument (3 given) what have done wrong? should can inherit outputplane sphericalrefraction? you not inheriting sphericalrefraction because have defined outputplane function , not class. so def outputplane(sphericalrefraction): should class outputplane(sphericalrefraction):

Detect number of bytes required for an arbitrary number in Scala -

i'm trying figure out simplest way write function detect amount of bytes required number in scala. for instance number 0 should 0 bytes 1 should 1 byte 127 should 1 byte 128 should 2 bytes 32767 should 2 bytes 32768 should 3 bytes 8388607 should 3 bytes 8388608 should 4 bytes 2147483647 should 4 bytes 2147483648 should 5 bytes 549755813887 should 5 bytes 549755813888 should 6 bytes 9223372036854775807 should 8 bytes. -1 should 1 byte -127 should 1 bytes -128 should 2 bytes -32767 should 2 bytes -32768 should 3 bytes -8388607 should 3 bytes -8388608 should 4 bytes -2147483647 should 4 bytes -2147483648 should 5 bytes -549755813887 should 5 bytes -549755813888 should 6 bytes -9223372036854775807 should 8 bytes is there way besides doing math figuring out number wrt 2^n? after precisions in comments, guess algorithm negative numbers be: whatever answer opposite be; , long.minvalue not acceptable input value. therefore, suggest: def bytes(x: long): int = {...

javascript - How to connect Mailchimp subscribers with Firebase using AngularJS -

i have database firebase , i'm trying newsletter subscription, want save subscribers in mailchimp , firebase. mailchimp connection works perfectly, don't know how integrate firebase connection in same js. this have in <head> tag <script type="text/javascript"> angular.module("productlaunch", ["mailchimp"]) </script> this in <body> tag <body ng-app="productlaunch"><section class="container-fluid subscribe" ng-controller="mailchimpsubscriptionctrl"> <div class="wrapper"> <!-- let email --> <div class=""> <h2 class="text-center">subscribe our news</h2> <div class="col-lg-4 col-lg-offset-4 mt centered"> <h4 ng-hide="mailchimp.result ==='success'">let me know when launch</h4> <h4 ng-show="mailchimp.result ==...

javascript - Trying to do a:active to stay on untill other link is clicked -

what i'm trying this: have 2 links hot/update. when hot clicked should turn red , update black. when update clicked should turn red , hot black. this works on fiddle, not on website. i able find various answers on so, seems common thing ask. implementing 1 one, none of them works. seem work fine in fiddle not on web. html: <div id="space" > <ul> <li role="presentation" class="sort"> <a class="link" href="/?sort=score&page=1" style="text-decoration:none;">hot</a> </li> <li role="presentation" class="date"> <a class="link" href="/?sort=date&page=1" style="text-decoration:none;">update</a> </li> </ul> </div> javascript: $(function() { var links = $('a.link').click(function() { links.removeclass('active'); $(this).addclass...

javascript - add and remove css class on hover -

so have code , works: $('.col-main').on('mouseenter', '.product-wrapper', function () { $( ).addclass( "js-hover" ); }); $('.col-main').on('mouseleave', '.product-wrapper', function () { $( ).removeclass( "js-hover" ); }); but want bit more elegant. this: listcontainer.on( { mouseenter: function() { $( ).addclass( "js-hover" ); console.log( "hoooover" ); }, mouseleave: function() { $( ).removeclass( "js-hover" ); } }, productwrapper ); but can´t work :) appreciated i think problem productwrapper variable. try followoing. var listcontainer=$('.col-main') var productwrapper='.product-wrapper'; listcontainer.on( { mouseenter: function() { $( ).addclass( "js-hover" ); console.log( "hoooover" ); }, mouseleave: function() { $( ).removeclass( "js-hover" ); } }, pro...

Jquery datatable bind from parameterized webservice -

everything fine json result not biding result datatable please help json rsult:[{"ourbranchid":"8001","accountid":"90186772","productid":"ca-pkr"}]{"d":null} <script type="text/javascript"> $(document).ready(function () { $.ajax({ type: 'post', url: 'accountservice.asmx/getaccountparam', data: "{ 'account': '90186772'}", contenttype: 'application/json; charset=utf-8', datatype: 'json', success: function (data) { var datatableinstance = $('#datatb').datatable({ data: data, // data: data.d, columns: [ { 'data': 'ourbranchid' }, { 'data': 'accountid' }, { 'data': ...

itext pdfstamper makes the document read only -

i'm reading in pdf document fillable fields, , using pdfstamper fill in form, output of stamper read pdf, how can make output pdf document fields filled still fillable? are using setformflattening(true) ? if so, behavior normal. change true false , form remain "fillable". learn difference reading answer question: itext how create multi-page document fillable template this reason why form no longer interactive: removing interactivity flattening form. (if that's not case, please share code can see going on.) or... pdf reader-enabled? if so, use pdfstamper in append mode. maybe you're experiencing problem explained in question why error saying "use of extended features no longer available"?

sql server - "The column is too long in the data file" while doing bulk insert from native data file -

i'm trying copy data in table sql server's identical empty table. i'm using transfer file cause direct sql-connection not possible. reason insert fails single table. i've used many other tables. ideas causes issue or how overcome it? source: microsoft sql server 2008 r2 (sp2) - 10.50.4321.0 (x64) jul 9 2014 15:59:57 copyright (c) microsoft corporation standard edition (64-bit) on windows nt 6.1 (build 7601: service pack 1) (hypervisor) target: microsoft sql server 2014 - 12.0.4100.1 (x64) apr 20 2015 17:29:27 copyright (c) microsoft corporation standard edition (64-bit) on windows nt 6.1 (build 7601: service pack 1) (hypervisor) exported using command-line: bcp mydb.dbo.f_mytable out f_mytable -n -s 123.123.123.123 -u myusername -p %passwd% tried importing using t-sql: bulk insert dbo.f_mytable 'c:\f_mytable' (datafiletype='native',keepidentity); resulted in error: msg 4866, level 16, state 4, line ...

AngularJS orderBy filter not working as expected -

Image
i'm trying show array ( $scope.stored_questions_clusters ) sorted in descending order position of each element, problem don't desired result. in example ng-repeat = "question cluster stored in clusters questions | orderby '- question_cluster.position'" , @ each iteration create panel bootstrap print position, expect list sorted position, don't this... here code use: <div style="margin-top:30px;" ng-show="mostrarpreguntas==true"> <div ng-repeat="question_cluster in stored_questions_clusters | orderby:'-question_cluster.position'" class="col-xs-8 col-xs-offset-2"> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-xs-11"> <h3>{{question_cluster.position}}.- {{question_cluster.title}}</h3> </div> ...

sql server - Counting Columns with conditions, assigning values based on count -

i have table call logs. need assign time slots next call based on time slot phone number reachable in. the relevant columns of table are: phone number | calltimestamp calltimestamp datetime object. i need calculate following: time slot : timestamp, need calculate count each time slot (eg. 0800-1000, 1001-1200, etc.) each phone number. now, if count greater 'n' particular time slot, need assign time slot number. otherwise, select default time slot. weekday slot : same above, weekdays. priority : count of how many times number reached here's have gone solving these issues: priority to calculate number of times phone number called straight forward. if number exists in call log, know called. in case, following query give me call count each number. select distinct(phonenumber), count(phonenumber) tblcalllog group phonenumber however, problem need change values in field count(phonenumber) based on value in column itself. how go achieving this? (eg. if ...

c++ - symbol endl and cout could not be resolved -

i have written code book reading complier warns symbol cout , endl not resolved. why that. #include <iostream> #include <float.h> int main() { cout << "float: " << endl << "stevilo decimalnih mest: " << flt_dig << endl << "natancnost stevila....: " << flt_epsilon << endl << "najmanjse stevilo.....: " << flt_min << endl << "najvecje stevilo......: " << flt_max << endl << "bitov v mantisi.......: " << flt_mant_dig << endl << "najvecji eksponent....: " << flt_max_10_exp << endl << "najmlajsi eksponent...: " << flt_min_10_exp << endl; return 0; } you have use namespace: #include <iostream> #include <float.h> using namespace ...

Jenkins workflow (pipeline) - build job only when there are SCM changes -

i'm creating quite complicated workflow using workflow-plugin (renamed pipeline plugin). simplicity let's assume need build job, job quite expensive , doesn't need build every time. when there scm changes. so let's call job expensivejob , it's source code management there scmrepositorya . so want build job: 'expensivejob' and want poll scm changes , build job based on information. is there way how this? my current solution have checkout in pipeline script scmrepositorya , check currentbuild.rawbuild.changesets seems me quite lot of unnecessary work , possibly have align whatever source code management changes in jobs.. there not equivalent of build step merely initiate polling, opposed unconditionally scheduling build. writing such step, or making option of build step, not particularly difficult think. in meantime, non-sandboxed script, same direct jenkins api calls: if downstream project had configured scm trigger (need poll ...

python one more stupid debug -

sorry, bit of pain damaged code, cannot understand wrong. removed if statement appears timedelta not recognized anymore , breaks code. pretty sure havent removed of reference though. scratching head cannot find problem.. would know went wrong? import random import datetime import csv itertools import groupby def generator(): i=0 while 1: yield random.randint(-1, 1), datetime.datetime.now() i=i+1 def keyfunc(timestamp,interval): xt = datetime.datetime(2013, 4,4) dt=timestamp delta_second =(dt - xt).seconds normalize_second = (delta_second / (interval*60)) * (interval*60) newtime = xt + timedelta(seconds=normalize_second) return newtime mynumber = 100 random_number, current_time in generator(): mynumber += random_number reftime5min = keyfunc(current_time,5) print mynumber,",", current_time, reftime5min the error is: traceback (most recent call last): file "", line 35, in file "...

poedit - gulp watch TypeError: glob pattern string required -

i've .po files in application. i've created watch see when translations file have been changed , compile them gulp.task('translations', () => gulp .src('po/.*po',) .pipe(gettext.compile({format: 'json'})) .pipe(gulp.dest('dist/translations/'))); ) gulp.task('watch', () => { gulp.watch('po/**/*.po', ['translations']); }); i use poedit if change works, if click save button without new change gulp process die throwing error typeerror: glob pattern string required update i've changed gulp.watch gulp-watch package , throws me better info enoent: no such file or directory, stat '/home/rkmax/development/myproject/po/es_es.temp.po'

assembly - PIC16F84_A Interrupt not working -

Image
just started learning pic microcontrollers. reason, portb remains 0x00 , interrupt never occurs. ;*** counter interrupt *** ;***** pic16fa4_a ************* org 0h status equ 03h porta equ 05h portb equ 06h trisa equ 85h trisb equ 86h intcon equ 0bh count equ 0ch count1 equ 08h count2 equ 09h goto main ;** interrup routine ** org 04h incf count,1 clrf portb ; clear rbo movlw 0ah subwf count btfss status,0 ;test carry flag goto go_on goto clear go_on bcf intcon,1 retfie clear clrf count bcf intcon,1 retfie ;** end of inerrupt routine ** main bsf intcon,7; global interrupt enable bsf intcon,4; rb0 interrupt enable bcf intcon,1; clear interrupt flag in case on bsf status,5 movlw 00h ;all ra pins output pins movwf trisa movlw 01h ;rb0 pin input pin movwf trisb bcf status,5 loop movfw count movwf porta ;put count in porta call delay ;delay movlw 01h movwf portb...

regex replace spaces between dollar signs -

how can replace spaces between 2 dollar sign? with regex work fine, can remove spaces between r , r. \s(?![^\r]*(\r|$)) the result but when use dollar sign instead r, doesn't work. maybe there special way dollar sign. \s(?![^\$]*(\$|$)) result dollar sign edit: programming language: php the \s+(?!(?:(?:[^$]*\$){2})*[^$]*$) pattern suggested in 1 of comments involves lot of backtracking, highly inefficient , can cause program freeze. here how in php (replacing space in between $ symbols hyphen): $re = '~\$[^$]+\$~'; $str = "\$ words words \$ \$ words words \$ \$ words words \$ \$ words words \$"; $result = preg_replace_callback($re, function($m) { return str_replace(" ", "-", $m[0]); }, $str); echo $result; see ideone demo with \$[^$]+\$ pattern, match whole substrings between 2 dollar symbols, , inside preg_replace_callback , can further manipulate replacement applying str_replace matches. ...

winforms - When adding a child Node to a TreeView in c# it visually looks wrong -

Image
i'm trying add child node treeview in winforms app (using c#). problem when use following code winform looks wrong visually. here's example: if (treeview1.nodes.count == 0) { treenode newguy = new treenode("new_subitem"); treeview1.nodes[0].nodes.add(newguy); newguy.beginedit(); return; } treenode n = treeview1.selectednode; treenode n3 = new treenode("new_subitem"); n.nodes.add(n3); n3.beginedit(); return; here happens: doing wrong? if (treeview1.nodes.count == 0) { treenode newguy = new treenode("new_subitem"); treeview1.nodes[0].nodes.add(newguy); newguy.beginedit(); return; } that code senseless: first check treeview1 has no nodes(treeview1.nodes.count == 0), try access first node it's correct(treeview1.nodes[0])

javascript - JS Function calling displaying odd text & not working more than once -

i have problem, when run function "addmoney(amount)" (shown below) works , shows following: 100[object htmlbuttonelement] my question this, there way rid of [object htmlbuttonelement] while keeping number moneyamount when function called? , additionally, there way call function multiple times , add money accordingly? works first time call it, calling more once same or different amounts of moneyamount displays no more or no less displays first time. my html: <li class="item_shown" id="money">shrill: <button class="moneybutton" id="moneyamount">0</button></li> calling function in html: <a class="button" onclick="javascript:addmoney('100');">add 100 money</a> my js function: function addmoney(amount) { document.getelementbyid('moneyamount') var newbalance = amount + moneyamount; document.getelementbyid('moneyamount').innerhtml = newbalance; }...

ios - AppStore: can I make an off-line alternative of in-app purchase? -

i'm not sure if ask in proper place, please - direct me proper place if needed, , don't blame :) i'm creating app guide on over museum in st. petersburg , clients want cost money, , want sell brochures code activate in app, people receive app if not registered bank card in itunes. i know how make programmatically, i'm not sure if allowed apple. it? pass review such feature?

python - TKinter tkFileDialog.askopenfilename Always behind other windows -

i want create simple tkinter file selection dialog function use other scripts , not wider gui. my current code is: # select single file , return full path string def select_file(data_dir): chdir(data_dir) root = tkinter.tk() root.withdraw() file_path = tkfiledialog.askopenfilename() return file_path when run file dialog behind other windows. if have spyder maximised, opens behind have minimise. there few questions related this, i've been unable of suggested code work, apologies if viewed duplicate question. ben just have use root.deiconify() after file_path = tkfiledialog.askopenfilename() but it's bad idea create new tk here.

Polymer 1.0 : Bind to global element -

sometimes want "share" global element between other elements @ application level. example, data store or other api endpoint. possible , not anti-pattern bind polymer element polymer element? bind properties of elements each other, binding property element seems useful invoking api of element etc.? for example: <my-datastore id="my-ds"></my-datastore> <my-element datastore="{{my-ds}}"></my-datastore> it's possible retrieve datastore element polymer dom api id, direct binding possible? (i've seen example of usage of $.my-ds somewhere in polymer 0.5, doesn't seem work anymore in 1.0)?

android - How could Intent be null in onHandleIntent()? -

my android app crashes , logcat :- java.lang.nullpointerexception @ com.google.android.gcm.gcmbaseintentservice.onhandleintent(gcmbaseintentservice.java:194) @ android.app.intentservice$servicehandler.handlemessage(intentservice.java:65) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:137) @ android.os.handlerthread.run(handlerthread.java:60) i looked android gcm r3 source , found argument intent null in onhandleintent(). is possible? how fix it? (i know null intent seen service.onstartcopmmand returning start_sticky intentservice.onstartcommand doesn't use start_sticky .) i think application crashes in devices during installation time. it's because during installation gcm service receives intent other google source , broadcast receiver not prepared handle type of intent . if want receive gcm intent want pull server through push notification, use in handle intent call. protected void o...

How to echo every values in multi dimensional array using php? -

how can done? i want echo each values in multidimensional array. here print_r of array. array ( [7] => array ( [sale] => 08 [not_sale] => 00 [inventory] => -- [not_inventory] => -- ) [1] => array ( [inventory] => 17 [not_inventory] => 00 [sale] => 08 [not_sale] => 00 ) [2] => array ( [inventory] => 17 [not_inventory] => 00 [sale] => 08 [not_sale] => 00 ) [3] => array ( [inventory] => 17 [not_inventory] => 00 [sale] => 08 [not_sale] => 00 ) [4] => array ( [inventory] => 17 [not_inventory] => 00 [sale] => 08 [not_sale] => 00 ) [5] => array ( [inventory] => 17 [not_inventory] => 00 [sale] => -- [not_sale] => -- ) [6] => array ( [inventory] => -- [not_inventory] => -- [sale] => -- [not_sale] => -- ) ) i want echo each item in each array... here code. no luck! please respect for($row=0; $row<7; $row++) { for($col=0; $col<7; $col++) { echo $myarray[$row]...

code analysis - Are there different sets of PhpStorm inspection rules, for example for different versions of PHP? -

i totally new phpstorm. imported existing code via "new project existing files", , set scope ignore third party libraries, *.bak files, , such. went file / settings / languages & frameworks / php, , set "php language level" current project 5.3 (which unfortunately appropriate level server production code running). then did "inspect code". bunch of warnings came up. expected, had never used phpstorm before. clicked on of them more or less randomly, , caught eye: function mysql_error deprecated. function mysql_error not deprecated. well, mean, is, of course, deprecated as of version 5.5 of php . using earlier version of php, , thought had explained fact phpstorm (via "php language level" setting). maybe can rid of mysql_error in php 5.3, don't know yet, example. main concern seems there billion inspection warnings due issues - i.e. due fact inspection engine seems think have access higher version of php do. there w...

excel - Use Application.Wait immediately after a workbook opens -

i need workbook display color after open it. after 5 seconds color change. implemented following code: private sub workbook_open() application.activesheet.cells.interior.colorindex = 4 application.wait (now + timevalue("0:00:05")) application.activesheet.cells.interior.colorindex = 5 end sub however when click on file, loads 5 seconds , opens , displays second color. how fix while still using application.wait. i tested , worked. use in workbook_open private sub workbook_open() 'schedules procedure run @ specified time in future '(either @ specific time of day or after specific amount of time has passed). application.ontime + timevalue("00:00:01"), "dothis" end sub put in module. not thiswork or won't work private sub dothis() application.activesheet.cells.interior.colorindex = 4 application.wait (now + timevalue("0:00:05")) application.activesheet.cells.interior.colorin...

html - Center button tag on top of bootstrap carousel -

pretty cut , dry question... not big on html trying button, in example below, center on top of bootstrap carousel. sadly got use button tag. http://www.codeply.com/go/ry7ybxnnnj .centerbutton { margin: 0 auto; background-color: transparent; text-align: center; position:absolute; z-index:50; top:50%; left:50%; margin-top:-23px; margin-left:-50px; } please note: adjust margin-top half button's height adjust margin-left half button's width it position first relative parent

r - RWeka installation on mac -

i trying install rweka package on mac. os version: 10.9.5 java version installed: java version "1.7.0_75" java(tm) se runtime environment (build 1.7.0_75-b13) java hotspot(tm) 64-bit server vm (build 24.75-b04, mixed mode) after executing install.packages("rweka") when try execute library(rweka) the following error displayed error : .onload failed in loadnamespace() 'rwekajars', details: call: .jinit() error: jni_getcreatedjavavms returned -1 error: package or namespace load failed ‘rweka’ javavm: requested java version ((null)) not available. using java @ "" instead. javavm: failed load jvm: /bundle/libraries/libserver.dylib javavm fatal: failed load jvm library. the output of command r cmd javareconf is xcode-select: note: no developer tools found @ '/applications/xcode.app', requesting install. choose option in dialog download command line...

github - Git pull enforce authentication -

i trying learn basics of github. want enforce authentication whenever git pull request made. possible in public repository? this public test repository https://github.com/santhanarajagopalan/jenkintest when try clone in machine using url https://github.com/santhanarajagopalan/jenkintest.git it doesn't ask credentials when pull. am missing configuration or git doesn't prompt password when public repository? when execute git pull locally, you're affecting copy of repository on machine, not copy on github's servers. github require authentication write copy of repository (either using git push locally or merging pull request in web interface).

Can I avoid Maven deployed war version with timestamp in Archiva? -

in out project using using deployed war file in /archiva-2.2.0/repositories/internal/com/xyz/1-snapshot/proj-1-20160204.122021-15.war path using shell script copy jboss. finding latest build timestamp , build number difficult. there way avoid using timestamp while storing in archiva proj-1-snapshot.war ? have read <uniqueversion>false</uniqueversion> whcih not supported in maven 3. i using archiva-2.2.0, maven-3.3.9. maven repositories wasn't designed distribute deployable components, continuous integration environment should take care of this. jenkins has eg archive artifacts (native) , copy artifact plugin can use store , recover binaries in pipelines. but can workaround behavior changing version of war stable 1 - removing -snapshot suffix. lead predictable url.

.htaccess - Limited users and passwords in . htpasswd and hide form in the php website -

i have secret login page (useradmin.php) users can add , delete users have access secret website (listmembers.php). want limit users adding more users 8 in useradmin site. if there 8 users want hide add form on page , show users message in order add user need first delete current users. can in php file not connected database or have in .htaccess or .htpasswd file? here php useradmin.php <?php // list users $filename = ".htpasswd"; if (!empty($_get["usr"])) { $usr = $_get["usr"]; } else { $usr = ""; } if (!empty($_get["pw"])) $pw = $_get["pw"]; if (!empty($_get["radera"])) { $radera = $_get["radera"]; } else { $radera = 0; } echo "<h2>administration av användare och lösenord</h2>"; if (strlen($usr)>2) { //append new user end of file $handle = fopen($filename, "a"); $userdata = $usr.":"; $userdata = $userdata.crypt($pw)."\n...

speech recognition - Pocketsphinx recognizes random phrases in a silence -

i have pocketsphinx installed on raspberry pi , microphone connected it. when run pocketsphinx_continuous using command pocketsphinx_continuous -inmic yes -dict dict.dict -hmm /home/pi/zero_ru.cd_cont_4000 -jsgf mygrammar.gram it starts recognize random phrases (but in cases same phrase) when not speaking. , when do, result same. use acoustic model russian language. please, need help. you need use keyword spotting mode. pocketsphinx supports keyword spotting mode can specify keyword list for. advantage of mode can specify threshold each keyword keyword can detected in continuous speech. other modes try detect words grammar if used words not in grammar. keyword list looks this: oh mighty computer /1e-40/ hello world /1e-30/ other phrase /1e-20/ to run pocketsphinx keyword list use: pocketsphinx_continuous -inmic yes -dict dict.dict -hmm /home/pi/zero_ru.cd_cont_4000 -kws keyword.list threshold must specified every keyphrase. shorter keyphrase can use smaller t...

mysql query to get not repeated data and multiple where statements -

i have trouble creating query should have 2 , statements in where. example table: type_id type 00034 1 00035 2 00035 3 00036 2 00037 3 i'm looking type_id doesn't have repeated id , type not 1 or 3. expected result 00036. not working: select type_id test type_title !=1 group type_id having count(type_id) = 1 result is: 00036 00037 how make 00036? best regards & nice weekend! let's assume table name "test_table", following query return need: select t1.type_id test_table t1 join test_table t2 on t1.type_id = t2.type_id t2.type not in(1,3) group t1.type_id having count(t1.type_id) = 1;

javascript - How to reuse mongodb connection through Promise -

i want reuse mongodb connection. 'am aware of how reuse mongodb connection in node.js want acheive same using promises , mongo driver v2 currently have connect db every request makes slow. code "use strict" var app = require('./utils/express')(); var mongodb = require('mongodb'); var mongoclient = mongodb.mongoclient; //actually 'am connecting mongolab var url = 'mongodb://localhost/my-mongo'; app.set('port', (process.env.port || 5000)); app.listen(app.get('port'), function () { console.log('parkme app running on port', app.get('port')); }); app.get('/location/create', function(req,res,next){ mongoclient.connect(url).then(function(db) { return db.collection('parkme_parkinglots').find({}).toarray().then(function (docs) { return docs; }); }); }); i want like: "use strict" var app = require('./utils/express')(); var mongodb = require('mongo...

java - Generating a random number from the array -

suppose there array : int arr[] = {0,1,2} is there way can generate random number out of 0,1,2 (i.e array) ? try this import java.util.random; random random = new random(); system.out.println(arr[random.nextint(arr.length)]);

Are C++ constructors called pre-initialization? -

suppose declare a of type type : type a; question: type constructor a called @ point? or after initialize a constructor called? is type constructor called @ point? or after initialize constructor called? you are initializing a here, whether explicitly provided value process or not. there no opportunity initialise a "later"; can assign later. (early c texts talk "initialising" numeric values long after declaration, that's different language, different century, , different set of descriptive idioms.) so, yes, constructor called object's lifetime begins. that's either right there , then, on line, or if class member of course it's when encapsulating class being initialised , it's member's turn. of course have proven simple std::cout pair.

c - How to pass an array of integers to a function as an argument and modify the content? -

i trying modify array of integers through function, array maintains original values. tried accesses values modify it: this produces error: *array[i] = *array[i] * *array[i]; this example runs program array modified: int main() { int array[] = {1, 2, 3, 4, 4, 5, 6}; int size = sizeof(array)/sizeof(int); square_array_values(&array, size); } void square_array_values(int *array, int size) { int i; (i = 0; < size; i++) { printf("array[%d]: %d.\n", i, array[i]); array[i] = array[i] * array[i]; } } this late answer party - hope gives ideas how add prints code show going on. consider output following program. there several ways approach this, 1 possibility. of earlier answers solid , should give ideas. you're going need build mental model of how memory allocation works in c can predict compiler do. find printing out values of variables , addresses helpful. benefit sketching "memory map" paper ...

javascript - What is the purpose of skin-deep? -

let me start saying new react , newer tdd coding in javascript. working on react / redux application testing of our components. our current test suite consists of jasmine, mocha, chai, karma, , skin-deep. of our components using skin-deep (see below -- skin deep ) import sd 'skin-deep'; describe('testing-text-editor', () => { let tree; let instance; let vdom; let field; let fieldinput; let callbackfunction; beforeeach(() => { field = 'description'; fieldinput = '<div>i description</div>'; callbackfunction = () => console.log('foo'); tree = sd.shallowrender(react.createelement(texteditor, { id: field, initialvalue: fieldinput, onsubmit: callbackfunction })); instance = tree.getmountedinstance(); vdom = tree.getrenderoutput(); }); it('testing-render-description', function() { // tests }); }) whenever use skin-deep using on components use shallowrender. ...

html - uncaught reference error Function not defined Javascript -

simple program calculate periodic interest rate, function defined , called in button still error uncaught reference still shows. appreciated function calculatepayment(){ var loanamount = document.getelementbyid("txtloanamount").value; var interestrate = document.getelementbyid("txtinterestrate").value; var amortiperiod = document.getelementbyid("txtyearlyperiod").value; var totalpayment; var numofmonths; //convert strings text box integers loanamount = parseint(loanamount); interestrate = parseint(interestrate); amortiperiod = parseint(amortiperiod); //validate input boxes ensure values added , follow application rules if (loanamount == null || loanamount == ""){ //alert("you must enter loan amount"); message = "you must enter loan amount"; document.getelementbyid("errormessage").innerhtm...

How to quote lines from source in github markup -

i have seen post on how link specific line number on github tells how create permalink lines of source code on github. that's great! my question is, how can quote lines of code in post such see code & line numbers - if view source code directly? the way know quote code literally copying & pasting post; need include permalink or quote line numbers people reading post know in source file look. easier if see code & link number in post. i think have add in line number github flavor markdown blockquotes , code documented here .

Add a date column to csv using python -

i have following code writes data output csv file. want add date variable @ end of each row using yesterday.strftime variable using in creating filename. example: thanks! my current output like: columna 1 2 and want add following column: date 2/5/2016 2/5/2016 . . . code:: filepath = 'c:\\test\\' filename = yesterday.strftime('%y-%m-%d') + '_' + 'test.csv' f = open( filename, 'wt') writer = csv.writer(f, lineterminator='\n') header = [h['name'][3:] h in results.get('columnheaders')] writer.writerow(header) print(''.join('%30s' % h h in header)) # write data table. if results.get('rows', []): row in results.get('rows'): writer.writerow(row) print(''.join('%30s' % r r in row)) else: print ('no rows found') f.close() in [26]: import pandas pd in [27]: import datetime in [28]: = pd.read_csv('a.csv') in [2...

bash - Capture output of last executed command into a variable without affecting Vim and line returns -

from question: bash - automatically capture output of last executed command variable used command: prompt_command='last="`cat /tmp/x`"; exec >/dev/tty; exec > >(tee /tmp/x)' it works, when use vim this: # vim vim: warning: output not terminal then vim opens. takes while. there way rid of message , slowdown? also when list dir , echo $last removes return lines (\n). there way keep return lines (\n)? i think ask hard achieve. vim tests if output terminal. command you've provided redirects output tee command. tee saves input (which menans: command's output) file and outputs terminal. vim knows nothing it. knows output not terminal. outputs warning. , vim 's source code: [...] if (scriptin[0] == null) ui_delay(2000l, true); time_msg("warning delay"); which means redirection 2 seconds delay. also, example, man vim command not work such redirections, because terminal output has attributest (e.g. width , h...

ssl - iOS Universal Links NSURLAuthenticationMethodServerTrust kAuthenticationErr -

i've set universal links in our app, , i'm unable retrieve apple-app-site-association file server on app install. device console giving following error attempts retrieve file during install: rejecting url 'https://example.com/apple-app-site-association' auth method 'nsurlauthenticationmethodservertrust': -6754/0xffffe59e kauthenticationerr i'm able retrieve file in safari using same device. it's hosted via https standard verisign issued ev cert. don't ssl errors when retrieving file outside of app install, i'm confident cert configured correctly on server side. what causing error? as turns out issue caused having worx citrix installed on phone. app installed profile xenmobile on phone interfering ssl handshake between our server , apple. case when installing test apps on phone. our production app downloaded app store works fine. also, if remove citrix apps , associated xenmobile profile, works. annoying.

java - JFreeChart: how to set the duration/period of a candle? -

Image
is possible set duration/period of single ohlcitem on candlestickchart? what i'm trying achieve possibility of merging 2 candles 1 ohlcitem. problem can set point in time on x axis candle should drawn, while merged candle should take space of 2 merged candles. is there way achieve this? screenshot better explains i'm aiming at: currently i'm merging candles following code, replaces 1 of items @ item's millisecond: private static ohlcitem getmergeditem(int i, ohlcitem clickeditem, ohlcitem neighbouritem) { double high; double low; if(clickeditem.getlowvalue() >= neighbouritem.getlowvalue()) { low = neighbouritem.getlowvalue(); } else { low = clickeditem.getlowvalue(); } if(clickeditem.gethighvalue() >= neighbouritem.gethighvalue()) { high = clickeditem.gethighvalue(); } else { high = neighbouritem.gethighvalue(); } if(i == 1) { return new ohlcitem(clickeditem.getper...

mysql - Accessing arrays created by explode function in php -

i'm beginner in php , mysql. pass string php ajax , split string after new lines. later assign each element in array variable. want pass variables mysql database. please assume: $q = "john \n doe \n 07589334009 \n john.doe@john.com"; here attempt: $date = date('y/m/d h:i:s'); $q = $_request["q"]; $arr = explode(php_eol, $q); $name = $arr[0]; $surname = $arr[1]; $phone = $arr[2]; $email = $arr[3]; $sql = "insert `database`.`mytable` (`name`, `surname`, `phone`, `email`, `reg_date`, `valid`) values ('$name' , '$surname', '$phone', '$email', '$date', '1');"; $result = $conn->query($sql); when check database see "johndoe07589334009john.doe@john.com" in name column. apart name , valid columns okay. just try like $arr = explode("\n", $q); $name = $arr[0]; $surname = $arr[1]; $phone = $arr[2]; $email = $arr[3]; explode using \n ,...

scala - Type Constraints with 2 Parameters -

given: scala> sealed trait parent defined trait parent scala> case object k extends parent defined object k scala> case object j extends parent defined object j scala> sealed trait result defined trait result scala> case object kresult extends result defined object kresult scala> case object jresult extends result defined object jresult how can implement following f ? scala> def f[a <: parent, b <: result](x: a): b = ??? f: [a <: parent, b <: result](x: a)b let's k must have kresult , , j has jresult . but, concern there's no enforced constraint on passing f[k, jresult] @ compile-time. or, perhaps resort to: def f(x: parent): result = x match { case k => kresult case j => jresult but, weakness of approach make mistake: def badf(x: parent): result = x match { case k => jresult case j => kresult ? you need way link kresult k in type system. can achieve adding type parameter a result ...

javascript - Prevent users from seeing Meteor client script by role -

in meteor put sensitive code in /server , browser code in /client . meteor automatically compiles , minifies /client side code us. meteor. however, i'm using https://github.com/alanning/meteor-roles manage content user roles. 1 of roles administrator , have client side scripts use user eg: /client/admin-only/**.js . code in scripts checks user administrator , calls server sensitive tasks, don't want adminstrator able see code. what want ensure these client admin js files downloaded users actual administrators , not included in auto-compiled/minified js created meteor. is there way setup meteor generate 2 versions of it's client js - 1 normal users , 1 administrators - , download files based on user role? the meteor guide addresses issue: while client-side code of application accessible browser, every application have secret code on server don’t want share world. secret business logic in app should located in code loaded on server. means in serve...

jquery - Can't Open A Div On Click — Trying to Change it's height from 0 to it's actual size -

i’m trying open div css transition hidden it’s actual size, using height. on click, it's supposed open it’s full height. initially set element's height 0 — in order hide it. .full-bio { width: 100%; transition: 0.4s ease; color: white; overflow: hidden; height: 0; } then in jquery copy element, find size, copy size, delete copied element , if height equals 0, change height height saved. var $textblock = this.$fullbio; var $measuringcopy = $textblock.clone(); console.log($textblock); console.log($measuringcopy); $measuringcopy.css({ 'opacity': 0.5, 'backgroundcolor' : 'yellow', 'height': 'auto', 'position': 'absolute', 'width': '100%', 'top' : -1000, 'left' : -1000 }); $textblock.append($measuringcopy); var finalheight = $mea...

javascript - ReactJS when using HTML attribute checked, reactjs is not allowing to select the checkbox -

as in question title, not able mark checkbox selected, on onchange event of selectbox this, <select id='featurestype' onchange={this.handlechange.bind(this, 'type')} > {this.getoptions(featurestype)} </select> were handlechange : handlechange: function (field, e) { if (field == 'type') { let selected = e.target.value; this.setstate({typeselected: selected}) } /*why console taking previous selecte option, ex: if locker selectec below lone prints 'dc' */ console.log(field ,',', this.state.typeselected) }, when bind defaultvalue, defaultchecked={(this.state.typeselected =='locker')} the select box not able mark wrt condition given, manually able mark checked/notchecked. checked={(this.state.typeselected =='locker')} on checked attribute, checkbox able mark checked, based on select box option value. in cas...

java - Need to make my texfield output bold, italic and both when the JCheckButtons are selected -

i have created basic gui has 2 jcheckbuttons (bold, italic) , 3jradiobuttons in button group of font styles (times, helvetica, courier). there textfield display string of font style, such times, in style, , if bold or italic buttons pressed text bold or italic (or both). far have managed add action listeners copy font name radio buttons textfield having trouble making text in associated font style. having trouble functions of bold , italic buttons. here code gui layout (the layout how want be, problem functionality of buttons: package weektwo; import javax.swing.*; import java.awt.*; import java.awt.gridbagconstraints; import java.awt.event.actionevent; import java.awt.event.actionlistener; public class tasktwo { public static void main(string[] args) { jframe window = new jframe("font chooser"); window.setdefaultcloseoperation(jframe.exit_on_close); window.setsize(500, 100); fontsetter fontsetter = new fontsetter(); container pane = window.get...