Posts

Showing posts from July, 2015

java - OpenCV: calcHist puts all results in the first bin -

i working on opencv 3.0 project in java, want detect percentage of yellow found in image. however, when calculate histogram of hue values, end histogram bins contain value 0.0 besides first bin. seems if contains observations. here extract image - since work opencv, hue value should in following range 0-179: //establish number of bins matofint histsize = new matofint(10); // set range value, upper bound exclusive // hue varies 0 179 matoffloat histrange = new matoffloat(0f, 180f); // histogram of hue value computed --> channel 0 == hue matofint channel = new matofint(0); mat histref= new mat(); arraylist<mat> histimages = new arraylist<mat>(); histimages.add(hsvroi); //definition: calchist(images, channels, mask, hist, histsize, ranges, accumulate) imgproc.calchist(histimages, channel, new mat(), histref, histsize, histrange); core.normalize(histref, h

QuickBook Desktop Integration with PHP -

my requirement connect quickbook desktop php app. go through http://wiki.consolibyte.com/wiki/doku.php/quickbooks_web_connector create qwc file, found parameters fileid, ownerid . how can quickbook desktop..? thanks in advance responses... copy-pasted right link posted: http://wiki.consolibyte.com/wiki/doku.php/quickbooks_web_connector#example_qwc_file copy/paste: <fileid>…</fileid> can make long follows guid format (uppercase hex chars only!): {6904a826-7368-11dc-8317-f7ad55d89593}. has dataext elements; simple integrations can make up. <ownerid>…</ownerid> same above

asp.net - Convert c# list of objects to JSON -

how parse c# object json? this code got: model: namespace mvcapplication1.models { public class holidaymodel { public int holidayid { get; set; } public string holidaydescription { get; set; } public string holidaystartdate { get; set; } public string holidayenddate { get; set; } public int count { get; set; } public string holidayold { get; set; } public string holidaynew { get; set; } public int employeeid { get; set; } public int holidayselectedyear { get; set; } public int startday { get; set; } public int startmonth { get; set; } public int startyear { get; set; } public int endday { get; set; } public int endmonth { get; set; } public int endyear { get; set; } } } controller: public actionresult getevents() { list<holiday> holidays = conn.holidays.tolist(); viewbag.holidaysjson = json(holidays, jsonrequestbehavior.allow

javascript - HTML DOM how to optimize this code? -

i got code: allnodes = document.getelementsbytagname("*"); (node in allnodes) { if (allnodes[node].innerhtml != undefined) { allnodes[node].innerhtml = allnodes[node].innerhtml.replace('adshss sd', '1fsss'); allnodes[node].innerhtml = allnodes[node].innerhtml.replace('adsss sd', '1fsss'); allnodes[node].innerhtml = allnodes[node].innerhtml.replace('addsss sd', '1fsss'); allnodes[node].innerhtml = allnodes[node].innerhtml.replace('adfsss sd', '1fsss'); } } i have 10 different lines replace text in loop , have noticed takes whole lot of time complete, question is: how can optimize this? goal find text on website (the elements not named of , <td> ) , replace it. i know experiece way quicker if know index number element holding specific text want replace hard find here when there more 200 elements. thanks! assuming markup doesn't have input value (

swing - Doesn't show scroll in JScrollPane with JTable after Upgrade Java 7 to Java 8 -

Image
i've upgrade project java 8. after running application, scroll jscrollpane doesn't show. same piece of code works in java 7 , ok. public static void main(string[] a){ jpanel contentpane = new jpanel(); contentpane.setbackground(color.white); contentpane.setborder(new emptyborder(0, 0, 0, 0)); contentpane.setlayout(new javax.swing.boxlayout(contentpane, javax.swing.boxlayout.y_axis)); jpanel aggregates = new jpanel("aggregates", new insets(40, 0, 0, 0)); gridbagconstraints gbc_aggregates = new gridbagconstraints(0, 2, 1, 1, 0.0, 0.0, gridbagconstraints.west, 1, new insets(10, 10, 10, 10), 0, 0); gbl_panel.setconstraints(aggregates, gbc_aggregates); gridbaglayout gbl_agregats = new gridbaglayout(); addparameterslayout(gbl_agregats, new int[]{0,0,0}, new int[]{0, 0},new double[]{ 0.0, 0.0, double.min_value}, new double[]{0.0, double.min_value} ); aggregates.setlayout(gbl_agregats); jtable table = new jtable(new myta

linux - C segmentation fault using shared library -

have write program displaying list of logged users (their id , groups if -i or -g used) using shared library. functions in shared library working correctly, seems function pointer causes segmentation fault. since it's school assigment have use c , functions have return nothing, , take user name. i'm quite new programming in linux (obviously). main code: #include <unistd.h> #include <stdlib.h> #include <utmp.h> #include <dlfcn.h> struct utmp *p; int main(int argc, char* argv[]){ int opt, iflag = 0; int gflag = 0; void *handle; while((opt = getopt(argc, argv, "ig")) != -1) { switch(opt) { case 'i': iflag = 1; break; case 'g': gflag = 1; break; default: fprintf(stderr, "błąd \n"); exit(exit_failure); } } handle = dlopen("./zad2lib.so", rtld_lazy); if (handle == null) { fprintf(stderr, &qu

node.js - socket.io private chat with nodejs -

how can manage chat user user user ,b , user c login user send message user c user c see message when send message receiver side socket not receive message use multiple method msg not receive how manage socket.io node js how manage system please me io.sockets.on('connection', function (socket) { socket.on('connection', function (data, callback) { if (data in users) { callback(false); } else { callback(true); socket.nickname = data; users[socket.nickname] = socket; updatanicknames(); var list= object.keys(users); io.sockets.on('connection', function (socket) { socket.on('send-message', function (messages) { var msg_number = fs.readfilesync('creditional/database.txt', 'utf8'); var msg_id = msg_number.tostring(); var next_msg_id = (msg_id - 0) + (1 - 0); fs.writefile('creditional/database.

java - Testing a buffered reader reading from input stream -

i have problems when testing code. think problem has using bufferedreader reading inputstreamreader. used intellij , give following input: hello world! why program not printing anything? here code: public static void main(string[] args) throws ioexception { bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); deque<string> lines = new arraydeque<>(); string line = br.readline(); while (line != null) { lines.push(line); line = br.readline(); } while (!lines.isempty()) { system.out.println(lines.pop()); } } your code stunk in first loop. to fix this, modify loop condition next: while (line != null && !line.isempty()) { lines.push(line); line = br.readline(); } then loop exit when hit enter . or can add other exit code . such while (line != null && !line.equals("exit")) . when enter in console exit code ( exit in example above) loop stop , de

Testing Two Label Values In XML -

i trying change else's document perform additional tasks, haven't dipped in xml in years , years , have forgotten if it's possible this. i'm trying test 2 values coming in system i'm working on , write value if both values meet criteria. here's i'm working with: <message key="label.support.spn6309" > <label lang="en" value="aftertreatment #1 diesel exhaust fluid dosing control unit" /> </message> <message key="label.support.fmi0" > <label lang="en" value="high - severe" /> </message> i'd combine above this: <message key="label.support.spn6309" , message key="label.support.fmi0" > <label lang="en" value="aftertreatment #1 diesel exhaust fluid dosing control unit --- high - severe" /> </message> so instead of 2 values writte

c# - IronPython: Unexpected token 'from' -

i running python script .net using ironpython, below python script import tensorflow tf print('tensorflow imported') below c# code using system; using system.text; using system.io; using ironpython.hosting; using system.collections.generic; using microsoft.scripting.hosting; namespace consoleapplication1 { class program { private static void main() { var py = python.createengine(); list<string> searchpaths = new list<string>(); searchpaths.add(@"c:\users\admin\appdata\local\programs\python\python35\lib)"); searchpaths.add(@"c:\users\admin\appdata\local\programs\python\python35\lib\site-packages)"); py.setsearchpaths(searchpaths); try { py.executefile("script.py"); } catch (exception ex) { console.writeline(ex.message); }

Angular 2 RxJS groupBy flatMap empty -

i'm pretty new rxxjs, might looking @ wrong way, have service returns array of 'verpleegperiodes': export class verpleegperiode{ verpleegperiodeid?: number; begindatumuur?: moment.moment; einddatumuur?: moment.moment; bed: string; kamer: string; dienst: dienst; dossier: dossier; } and in component, i'm trying array of 'verpleegperiodes' grouped 'kamer' property, ex. '101', '102', '103', ... i'd observable stream of ex.: [{verpleegperiodeid: 1, kamer: '101'},{verpleegperiodeid: 3, kamer: '101'}] [{verpleegperiodeid: 6, kamer: '102'}] or better, if possible rxjs : { kamer: '101', verpleegperiodes: [{verpleegperiodeid: 1, kamer: '101'},{verpleegperiodeid: 3, kamer: '101'}] } { kamer: '102', verpleegperiodes: [{verpleegperiodeid: 6, kamer: '102'}] } for this, i've found documentation group by: https://www.learnrxjs.io/operators/transf

How to get static library in sdk? -

everyone searched how include static library in sdk, surely read this thread 2014 . tried suggested, didn't work. reading yocto mega manual version 2.1 (yocto morty), found in chapter 5.9.12. (poky reference distribution changes), added disable_static variable, disable generation of static libraries. tried adding recipe, , didn't enable adding static library sdk: disable_static = "" i can see library in sysroot when building image. not getting in sdk. so, need static library , headers in sdk? what worked adding staticdev package ´image_install´ in local.conf , don't want have that. i created example recipe, demonstrates problem. directory structure this: example-staticlib/ example-staticlib/example-staticlib_0.1.bb example-staticlib/files/ example-staticlib/files/lib.c example-staticlib/files/lib.h example-staticlib/files/makefile example-staticlib_0.1.bb : description = "example stared library" license = "lgplv2" lic_

typescript optional parameter type check -

i've got function (func) on class (myclass) optional parameter. type of optional parameter (myinterface) has optional properties. i expected compiler error when call foo primitive number. thats not case. why that? , there way tell type system mark error? interface myinterface { foo?: string } class myclass { func(b?: myinterface) : void {} } let c = new myclass(); c.func(); c.func({ foo: 'bar' }); c.func({ foo: 30 }); // compiler error: ok c.func({}); c.func(60); // no compiler error: not expect the reason happens number compatible {} . (for example, imagine argument of type {tofixed: (n: number) => string} , too, compatible number ). you can think way: you can number, {foo?: string} .

javascript - Jquery: wait till open in new tab is selected and then redirect -

i have html element looks this. <a href="#" id ="bs">buildsummary</a> i need to display pop window on clicking link. if right click , click on 'open in new tab' should open new tab , new tab opened should have same data pop window contains. in event handler, have used 1 if block handle right click shown below. $(document).on("click contextmenu",'#bs',tabeventhandler) function tabeventhandler(event){ event.preventdefault(); if( event.which == 3 ){ var wnd = window.open("about:blank","_blank"); wnd.document.write(ajaxresult); } } but opens new tab son right click on link. want browser display menu , after user selects 'open in new tab' should open new tab. how can achieve this?

enterprise architect - How to give “Hidden Sub Menu” inside a “Hidden Sub Menu” -

Image
how can put “hidden sub menu” inside “hidden sub menu”. for example: - have 4 toolboxes naming a, b, c , d , b , c hidden. hidden , added b, b hidden , added c, c hidden , added d. toolbox-d, when drag , drop “c” should b in list , when select b, should in list , then, when select a, whatever elements containing should list out options in diagram workspace. how can achieve behavior. you can have maximum of 2 sub-menus( item in toolbox->menu a->menu b) example can give events in bpmn(2.0) item in toolbox menu a menu b the first sub-menu done via hidden-menu functionality of toolbox profiles. second sub-menu done via _subtypeproperty metaclass attribute the first sub-menu useful differentiate stereotypes similarities of same metaclass. the second sub-menu useful assigning different shape (from conditional branching in shapescript of stereotype) element on creation. can used assign value of tagged value on creation

javascript - Show modal to user when updated -

i have made modal , shows on first visit website $(document).ready(function(){ settimeout(function(){ if(!cookies.get('modalshown')) { $("#mymodal").modal('show'); cookies.set('modalshown', true); } else { alert('you saw modal') } },1000); }); in modal shows content of new functionality application added. target to show modal user every time update modal content . how can this? you use versionning in cookies values : var currentrelease = "1.0.1", currcookie = cookies.get('modalshown') settimeout(function(){ if(!currcookie || currcookie != currentrelease) { $("#mymodal").modal('show'); cookies.set('modalshown', currentrelease); } else { alert('you saw modal') } },1000); note method forces update value of "currentrelease" crypt text content of modal md5 , use va

angular - Angular2 Modal updated, but view is not updating -

created component named notification.component.ts import { component, oninit } '@angular/core'; @component({ selector: 'notification', templateurl: './notification.component.html', styleurls: ['./notification.component.css'] }) export class notificationcomponent implements oninit { constructor() { } private type:string = ""; private message:string = ""; private showmessage:boolean = false; ngoninit() { //this.showmessagebox('info', 'hi da'); } showmessagebox = (type:string, message:string): void => { this.type = type; this.message = message; this.showmessage = true; } } and template below <div id="notification" class="boxshadow" *ngif="showmessage" > <b>{{type}}! </b>{{message}} </div> i have called showmessagebox() function other component. model updated, view not updating. pfb component below

c# - ASP.net: Concurrent file upload Fails after N number of large uploads -

i working on asp.net (webforms, asp.net 2.0, framework 3.5) application. 32 bit application running on iis 7.0, os windows 2008 r2 sp1 i facing issue large file uploads. files more 20 mb or so. application able upload large files however, noticed after n number of uploads, next set of uploads keep on failing until iis restarted. the application supports concurrent file uploads. noticed that, single large file upload works. when start upload more 1 file, 1 of uploads stuck. i tried looking @ temp folders in posted file data gets uploaded , noticed when issue happens, upload failing file never starts server's view point never generates temp file , after few sec, request fails. when things fail, cpu ok w3wp stands @ 2 gb memory usage (against total 4 gb ram) w3wp not show crash other pages of application still works fine i tried using wireshark see network traffic, err_connection_reset. apart that, not getting clue. i suspecting below things not sure how conclude or fi

c# - Properly scaling the UI canvas for android phone's -

so have been trying while now, , have had every topic available. cant seem work. so issue following: i'm developping galaxy s7 resolution of 1440 x 2560 pixels. use in game view allign buttons etc. cant seem scale other android phones. i used canvas scaler alot no luck far, might doing wrong? any idea's highly, highly appreciated!

mysql - One-to-many connection, several tables sql -

i've got tables tech_map (17 rows): id,name,status, id_user_add, datetime_add, commentary tech_map_expenses (7 rows): id,name,cost, tech_map.id tech_map_products (8 rows): id,category_id,catalog_id, total, tech_map_id tech_map_stock (8 rows): id,category_id,catalog_id, total, tech_map_id and want select tech_map exits connection other tables example: select tech_map.* `tech_map` inner join tech_map_expenses on tech_map_expenses.tech_map_id = tech_map.id inner join tech_map_products on tech_map_products.tech_map_id = tech_map.id inner join tech_map_stock on tech_map_stock.tech_map_id = tech_map.id order tech_map.id desc but it's return many rows (33) duplicate records. you should change left join inner join. why? left join contain tech_map doesnt have connection other tables. inner join contain tech_map have connection other tables. take @ picture , me. , also, documentation .

string - Change double quotes to single in java but with some restrictions -

i need change double quotes single quotes in java having restrictions. e.g.: consider ' love "apple" , "banana" much'. i don't want change "apple" , "banana" double quotes single quotes. another one: "hi! what's up?" output: 'hi! what's up?' can me on this? if strings processed line line wont problem. can make sure first , last characters ' . may check string documentation, has lot of methods this. but if dealing paragraph or sentences can tricky. can use natural language processing (nlp) there many java implementations of google , can find one.

How can I access tomcat log files from Java web application deployed on it? -

how can access tomcat log files java web application deployed on it? possible? okay, possible. used like: public static string readlogfile () { stringbuilder sb = new stringbuilder(); try(bufferedreader br = new bufferedreader(new filereader("/var/log/tomcat8/catalina.out"))) { string line = br.readline(); while (line != null) { sb.append(line); sb.append(system.lineseparator()); line = br.readline(); } } catch (ioexception e) { // exception handling } return sb.tostring(); }

javascript - Accessing the query variable from within callback -

take following example: getoptions() { let options = {}; if (this.props.location.hasownproperty('query')) { const query = this.props.location.query; const queriesmap = { 'createdby': 'createdby', 'state': 'state', 'created_from': 'created_at[from]', 'created_to': 'created_at[to]' }; object.keys(query).map(function(key) { if(queriesmap.hasownproperty(key)) { options = object.assign(options, { queriesmap[key]: query[key] }); } }); } return options; } i'm using queriesmap object map url parameters build new url call api. problem query undefined when i'm trying access within .map callback. how access query variable? looks missing [] around queriesmap[key] . should options = object.assign(options, { [queriesmap[key]]: query[key] }); . also, options[queriesmap[key]] = query[key] rather object.assign

elixir - a 3 level deep relationship in Ecto -- how to preload -

i have quite several level relationship of models in project. in controller have this: var1 = repo.get!(model1, 123) |> repo.preload([child_items1: :child_items2]) this works fine have go 1 level deeper. namely each child_items2 many child_items3 . now, how can preload child_items3 each child_items2 ? i use scopes. example in model(1) have with_model2 function preloads model2. load 3 associations in row, i'd have like: def with_model2(query \\ __module__) query, preload: [model2: ^model2.with_model3] end for model(1). , idea, model2 have def with_model3(query \\ __module__) query, preload: :model3 end i never went 3 level deep, assume work.

php - Most Efficient way of scrapping web pages -

i using curl contents page scrap using simple html dom. have scrap thousands of pages code takes lot of time executing. looking methods can speed code. have option of using alternative of curl more efficient , less time consuming. know can using file_get_contents gives me error after few calls. so question is. how can scrap webpages in bulk , best efficiency ? i sharing code. great if can point out how speed up. appreciated. <?php include_once ('simple_html_dom.php'); function do_it_with_curl($url) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_returntransfer, true); $server_output = curl_exec ($ch); $error = curl_error($ch); $errno = curl_errno($ch); curl_close ($ch); return str_get_html($server_output); } function check_response_object( $str_obj, $type ) { if(is_object( $str_obj )) { if( $type == 'url' )

matlab - Math behind some quaternion code and gimbal lock -

Image
i have following matlab code gives rotation matrix quaternion. person did said used library , rotation matrix the rotation matrix according code looks like the diagonal elements , signs changed. can someonw explain me math or conditions disparity between two. q0 = quat(1); q1 = quat(2); q2 = quat(3); q3 = quat(4); %% set f2q 2*q0 , calculate products f2q = 2 * q0; f2q0q0 = f2q * q0; f2q0q1 = f2q * q1; f2q0q2 = f2q * q2; f2q0q3 = f2q * q3; %% set f2q 2*q1 , calculate products f2q = 2 * q1; f2q1q1 = f2q * q1; f2q1q2 = f2q * q2; f2q1q3 = f2q * q3; %% set f2q 2*q2 , calculate products f2q = 2 * q2; f2q2q2 = f2q * q2; f2q2q3 = f2q * q3; f2q3q3 = 2 * q3 * q3; %% calculate rotation matrix assuming quaternion normalized r(1, 1) = f2q0q0 + f2q1q1 - 1; r(1, 2) = f2q1q2 + f2q0q3; r(1, 3) = f2q1q3 - f2q0q2; r(2, 1) = f2q1q2 - f2q0q3; r(2, 2) = f2q0q0 + f2q2q2 - 1; r(2, 3) = f2q2q3 + f2q0q1; r(3, 1) = f2q1q3 + f2q0q2; r(3, 2) = f2q2q3 - f2q0q1; r(3, 3) = f2q0q0

javascript - Angular 2 mode = "Observable" what does it do? -

i working on angular 2 project , came across tutorial used format. using observable interact database , retrieve data , component subscribing service happening. tutorial had mode = 'observable'; what do? can't seem find online. can assume does, necessary? export class taxratelookupcomponent { errormessage: string; mode = 'observable'; taxrate: taxrate[]; constructor( private taxratelookupservice: taxratelookupservice, public route: activatedroute, ) {} gettaxrate(search) { this.taxratelookupservice.gettaxrate(search) .subscribe( taxrate => this.taxrate = taxrate, error => this.errormessage = <any>error); } }

logging - Grok filter for my log pattern -

i experimenting elk. try input log following pattern logstash 14:25:43.324 [http-nio-9090-exec-116] info com.app.mainapp - request has been detected i have tried following grok patterns filter in logstash.conf match => { “message” => [ “ (?<timestamp>%{hour}:%{minute}:%{second}) \[%{notspace:thread}\] %{loglevel:loglevel} %{data:class}\- %{greedydata:message}“ ]} match => { “message” => [ “ %{time:timestamp} \[%{notspace:thread}\] %{loglevel:loglevel} %{data:class}\- %{greedydata:message}“ ]} but when input log logstash , following error [0] "_grokparsefailure" can suggest correct grok filter above log pattern ? this parse failure got fixed after removing starting space. working logstash.conf after removing space below input { file { path => ["./debug.log"] codec => multiline { # grok pattern names valid! :) pattern => "^%{timestamp_iso8601} " negate => true =&g

jsf 2 - JSF Custom font with CSS -

i trying add custom font _template.html, not rendering font, plain text. tried solution found here , did not solve problem. my custom font file in webcontent/resources/fonts/helveticaneueltstd-ltex.otf my css file in webcontent/resources/css/font.css font.css: @font-face { font-family: "martinelli logo"; src: url("#{resource['fonts/helveticaneueltstd-ltex.otf']}"); font-weight: normal; font-style: normal; body{ font-family: "martinelli logo"; } } obs.: tried src: url('fonts/helveticaneueltstd-ltex.otf'); , no luck. _template.xtml: <h:body> <h:outputstylesheet library="css" name="css/font.css" /> hello world in custom font! <h:body /> the final solution: apparently browser (chrome) loading old cached css, wasn't being able see updates developing on styles. cleaned chrome's cache , working perfectly. need figure how change behavior on browser, since don't want clea

android - Is customizing style of WheelView possible? -

i'm using this: https://code.google.com/archive/p/android-wheel/ library wheels. can't find ways apply app's theme them - still stay default. there way customize them, actually?

javascript - How to use Google Custom Search Element with existing form element? -

i'm trying use current search form google's custom search element , far unable work. current search form. <form class="search-form" action="/search/"> <p class="inputs"> <label for="search-q">search</label> <input type="search" id="search-q" name="search" data-gname="search"placeholder="find you're looking for..." value="#formatted_query#"> <input type="submit" value="go" class="button postfix brand-orange-bk"> </p> </form> the google cse code snippet use shown below: (function() { var cx = '004626212387516433456:aex2tyveipy'; var gcse = document.createelement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:')

ios - Auto-renewal Subscripton receipt validation -

i'm implementing auto-renewal trial period,now i'm testing sandbox account.i have couple of questions,please me. 1.after purchasing i'm validating receipt whether free trail or not, receipt "is_trial_period" false, need know whether user in free trail or not? 2.if user deletes app , re-install again in same device or in device can receipt again? 3.if wont receipt after re-install how can unlock feature subscription subscribed? 4.if user cancels subscription in trail period, how know cancelled? 5.if user cancels subscription, if restore purchases, shall purchases in restore transaction? i may answer of questions: if receipt sandbox account, receipt active 5 minutes. is_trial_period true on real users. if user deletes app device , re-install same devices can retrieve receipt if user install in different device he/she must restore purchase apple id bought subscription. check answer 2. receipt has expires_date , can check if user cancelled

ansible - How do I do SSH agent forwarding in AWS Lambda? -

i doing following tasks in aws lambda: create instance x. git pull ansible playbook instance x via exec_command of paramiko run ansible playbook spawn multiple instances (y) , specific tasks. however, have agent-forwarding here executing tasks on remote instances (y). so, 1 solution scp pem file x via exec_command . is there better/elegant solution problem statement?

jquery - Javascript gallery, adding images with "for" loop -

i'm creating gallery in project, don't want spam clear html , repeat 20 times in code. want create loop in javascript numbers of images folder , later add 1 div. i've created code don't know how step it. code: function addingimages() { (var = 0; <= ***; i++) { var image = document.createelement("img"); image.setattribute("src", "images/1.jpg"); document.queryselector(".gallery").appendchild(image); } } *** - don't know should there. , know need variable increment later numbers of images 1.jpg , 2.jpg, 3.jpg etc. you need loop 1 20, set loop count 20. use index loop in setattribute function this: function addingimages() { (var = 1; <= 20; i++) { var image = document.createelement("img"); image.setattribute("src", "images/" + + ".jpg"); document.queryselector(".gallery").appendchild(image);

c# - Xamarin Image Grid from Folder -

i trying display image grid text. using images folder. have tries various approaches , tutorials no success. have both read , write permissions internal , external storage. whenever debug application blank screen. have tried setting breakpoint on adapters getview() method never gets hit. here mainactivity oncreate() method: protected override void oncreate(bundle bundle) { if (!_dir.exists()) { _dir.mkdir(); } base.oncreate(bundle); setcontentview(r.layout.main); string[] filepath = null; string[] filename = null; if (_dir.isdirectory) { droidio.file[] imagelist = _dir.listfiles(); filepath = new string[imagelist.length]; filename = new string[imagelist.length]; (int = 0; < imagelist.length; i++) { filepath[i] = imagelist[i].absolutepath; filename[i] = imagelist[i].name; } } var gvimagelist = findviewbyid<gridview>(r.id.gvimagelist); gvimagelist.setadapt

Sails.js + PM2 - process.send is undefined -

i have sails.js app. using pm2 in production environment. according this issue , need send request sails pm2 indicating app online. module.exports.bootstrap = function(cb) { sails.on('lifted', function() { process.send('ready') // process.send undefined }); }; how trigger ready event here? please try: var cp = require('child_process'); var p = cp.fork(__dirname + '/app'); sails.on('lifted', function() { p.send('ready'); }); however, use pm2 well, , launch production without code in bootstrap.js file , keymetrics works fine: pm2 start app.js -x -- --prod i hope helpful. cheers

java - Tomcat standalone servlet doPost not receiving any incoming requests -

first off, i'm not java developer. use open source ebxml product (hermes v1.0) have been tasked getting accept/produce tlsv1.1 or tlsv1.2 requests. product has been working fine using tomcat 4 , java 5. have upgraded tomcat 6 , java 8 tls protocols work. i believe have tls aspect working. log generated -djavax.net.debug=all shows decrypted https post request. servlet's dopost never hit. can doget via browser no issues. below have attached portion of application's web.xml <servlet> <servlet-name>msh</servlet-name> <servlet-class>hk.hku.cecid.phoenix.message.handler.messageservicehandler</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>msh</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> any tips on how can debug going on?

javascript - Jquery input text allow decimal and value between 0.00 and 100 -

jquery input text allow decimal , value between 0.00 , 100 html : <input name="score type="number" min="0.01" max="100" step="0.01"> is showing invalid when enter "1111" want validation after click submit button <input type="text" name="score"> <input type="submit"> script: if($(this).val()<= 0.01 && ($(this).val() <=100)){ // allow 0.01 100 100 return true; } i want allow decimal in field you can use html this: <input type="number" min="0" max="100" step="0.01"> if don't want use html: $(document).on("ready", function() { $("#form").submit(function(e) { var scoreval = $("#score").val(); if(parseint(scoreval) <= 0 || parseint(scoreval) > 100) { e.preventdefault(); console.log(&quo

php - Wordpress Paginate with additional Parameters -

the code below works great paginating custom post search results: if( isset($_get['pagination']) && $_get['pagination'] != 'false'){ $arguments['posts_per_page'] = -1; $pagination = 'true'; } else { $arguments['posts_per_page'] = 9; $pagination = 'false'; $arguments['order'] = 'asc'; $arguments['meta_key'] = 'code_auto'; $arguments['orderby'] = 'meta_value'; } however, if has filtered results using this: if( isset($_get['sort_price'])){ $sort_price = $_get['sort_price']; if($sort_price == 'asc'){ $arguments['order'] = 'asc'; $arguments['meta_key'] = 'price-6'; $arguments['orderby'] = 'meta_value'; } else { $sort_price = ''; $arguments['order'] = 'desc'; $arguments['orderby&#

reactjs - Enzyme: Method “text” is only meant to be run on a single node. 0 found instead -

i'm using react v15.4, babel-jest v18 , enzyme v2.5.1 i have simple react component: import react, {component} 'react' import {formattedrelative} 'react-intl' import pagewithintl '../components/pagewithintl' import layout '../components/layout' class extends component { static async getinitialprops ({req}) { return {somedate: date.now()} } render () { return ( <layout> <h1>about</h1> <p> <formattedrelative value={this.props.somedate} updateinterval={1000} /> </p> </layout> ) } } export default pagewithintl(about) and simple jest/enzyme test: /* global it, expect, describe */ import react 'react' import { shallow } 'enzyme' import renderer 'react-test-renderer' import '../pages/about.js' describe('with enzyme', () => { it('app shows "about&qu

arrays - PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" -

i running php script, , keep getting errors like: notice: undefined variable: my_variable_name in c:\wamp\www\mypath\index.php on line 10 notice: undefined index: my_index c:\wamp\www\mypath\index.php on line 11 line 10 , 11 looks this: echo "my variable value is: " . $my_variable_name; echo "my index value is: " . $my_array["my_index"]; what these errors mean? why appear of sudden? used use script years , i've never had problem. what need fix them? this general reference question people link duplicate, instead of having explain issue on , on again. feel necessary because real-world answers on issue specific. related meta discussion: what can done repetitive questions? do “reference questions” make sense? notice: undefined variable from vast wisdom of php manual : relying on default value of uninitialized variable problematic in case of including 1 file uses same variable name. majo

python - Sending large amount of data from one system to another -

actually trying send trained data system 1 system 2, can knn classification in system 2. find difficult sent trained data large. there way send bulky data 1 system through socket. system 1 import sys import time import pickle sklearn.datasets import load_files sklearn.neighbors import kneighborsclassifier sklearn.feature_extraction.text import countvectorizer sklearn.feature_extraction.text import tfidftransformer socket import socket, gethostbyname, af_inet, sock_dgram port_number = 5000 hostname = gethostbyname('0.0.0.0') mysocket = socket( af_inet, sock_dgram ) mysocket.bind( (hostname, port_number) ) print ("test server listening on port {0}".format(port_number)) (data,addr) = mysocket.recvfrom(15) print data mysocket.sendto("connected...", addr) (data,addr) = mysocket.recvfrom(20000000) msg=pickle.loads(data) twenty_train=msg mysocket.sendto("one", addr) (data,addr) = mysocket.recvfrom(300000000) ms=pickle.loads(data) x_train_tfid

mysql - I have a php error. But I don't understand why -

i have problem in code. i'm trying make private chat. using php , mysql. have error: "fatal error: uncaught exception 'mysqli_sql_exception' message 'table 'b7_19757973_4hfbroup.asdfannedegraaff' doesn't exist" , know means table not exist. use code if table exist: $query = mysqli_query($con, "select * `".$_session['senderreceiver']."`"); if(!$query) echo "the s not exists"; $query2 = mysqli_query($con, "select * `".$_session['receiversender']."`"); if(!$query2) echo "the f not exists"; but still error, how can fix this? btw session made this: $sender = $_session['username']; $receiver = $_post["name"]; $senderreceiver = $sender . $receiver; $receiversender = $receiver . $sender; $_session['senderreceiver'] = $senderreceiver; $_session['receiversender'] = $receiversender; i'm sorry bad english , bad explanation. ho

python - how to efficiently link lines of numpy array to sets of tags? -

i trying convert list of data structure, of same type, numpy arrays. works number attributes there 1 attribute value set of tags (strings). , don't see how model numpy . so far, use 2d array. each row contains attributes of 1 data structure, 1 per columns. set of strings, don't know how use in numpy array. it seems can put set value cell in array seems break point of numpy : fixed size arrays efficient functions apply on them. any idea ? i think best alternative use list of tuples supposing l list: in [1]: l = [[4,5,6,'a','b'],['x','y',2,3]] in [2]: _l = [tuple(elem) elem in l] in [3]: _l out[1]: [(4, 5, 6, 'a', 'b'), ('x', 'y', 2, 3)] alternatively create list of tuple first element of tuple numpy array, , second element tag.

image processing - Training a Siamese Network with Caffe -

i training simple siamese network compares pair of images. followed example given caffe(siamese) , made own model. my issue constrastive loss function. detail of function implementation caffe defined here . in implementation used margin = 1, defined follows layer { name: "loss" type: "contrastiveloss" bottom: "data" bottom: "data_p" bottom: "label" top: "loss" contrastive_loss_param { margin: 1 } } my data labeled 0 if dissimliar , 1 if similar. confused margin of contrastive loss function. how margin parameter selected? page 3 of initial paper hadsell et.al states margin > 0 there upper bound?

mysql - Error Code: 1264. Out of range value for column -

i'm trying code work , first line i'm inserting error. i've changed value of phone number's varchar, error still remains. this code: create schema if not exists `mydb` default character set utf8 ; use `mydb` ; create table if not exists `mydb`.`customer` ( `customer_id` int not null, `customer_f_name` varchar(45) not null, `customer_l_name` varchar(45) not null, `customer_address` varchar(45) not null, `customer_dob` date not null, `customer_h_phone` varchar(20) not null, `customer_w_phone` varchar(20) not null, `customer_type` varchar(45) not null, `customer_sponsor_id` int null, primary key (`customer_id`), index `fk_customer_customer1_idx` (`customer_sponsor_id` asc), constraint `fk_customer_customer1` foreign key (`customer_sponsor_id`) references `mydb`.`customer` (`customer_id`) on delete no action on update no action) engine = innodb; insert `customer` (`customer_id`, `customer_f_name`, `customer_l_name`, `customer_address`, `customer_dob`, `customer

regression - Rescale data to be sinuosoidal -

i have time series data i'm looking @ in python know should follow sine 2 function, various reasons doesn't quite fit it. i'm taking fft of , has broad frequency spread, when should narrow single frequency. however, errors causing quite consistent--if take data again matches closely previous data set , gives similar fft. so i've been trying come way can rescale time axis of data @ single frequency, , apply same rescaling future data collect. i've tried various filtering techniques smooth data or cut frequencies fft without luck. i've tried fitting frequency varying sine 2 data, haven't been able fit (if able to, use frequency vs time function rescale time axis of original data has constant frequency , apply same rescaling new data collect). here's small sample of data i'm looking at (the full data goes few hundred cycles). , resulting fft of full data any suggestions appreciated. thanks!

Clojure Ring wrap-reload is not working -

this core.clj file (ns lein-app.core (:require [compojure.core :refer :all] [compojure.route :as route] [ring.middleware.reload :refer [wrap-reload]])) (use 'ring.adapter.jetty) (defroutes app (get "/" [] "<h1>hello world</h1>") (route/not-found "<h1>not found</h1>")) (def reloadable-app (wrap-reload app)) (defn -main [] (run-jetty reloadable-app {:port 3000})) and project.clj (defproject lein-app "0.1.0-snapshot" :description "fixme: write description" :url "http://example.com/fixme" :license {:name "eclipse public license" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [ [org.clojure/clojure "1.8.0"] [compojure "1.5.2"] [ring "1.5.0"]] :main lein-app.core) when run lein run starts server correctly if change response else example need kill server

Running a macro crashes excel -

i have excel spreadsheet containing around 15 excel dct. on sheet, there drop down menu allowing selecting username, , when changing value, macro updates dtc present on spreadsheet username , refreshes data. problem reason, crashes excel except on high perf computer. don't know do here macro : dim pt pivottable dim pi pivotitem dim strfield string strfield = "cslts" on error resume next 'application.enableevents = false 'application.screenupdating = false if target.address = range("h1").address each pt in activesheet.pivottables pt.pagefields(strfield) each pi in .pivotitems if pi.value = target.value .currentpage = target.value exit else .currentpage = "(blank)" end if next pi end nex

entity framework - return custom object from stored procedure executed in EntityFramework, can't see object results -

Image
i trying execute stored procedure using entity framework. i've tried below , returns correct amount of rows, when @ data in debug window, shows type, won't let me drill see actual values are. sqlparameter param1 = new sqlparameter("@targetdate", filedate); var result = db.database.sqlquery<positionsheetcompresults>("dbo.comparepositionsheet @targetdate", param1); can tell me how this? here results should return here class public class positionsheetcompresults { public string acctnum { get; set; } you should write tolist<positionsheetcompresults>(); var result = db.database.sqlquery<positionsheetcompresults>("dbo.comparepositionsheet @targetdate", param1).tolist<positionsheetcompresults>();

r - Using nested time series columns as input into function, return value to nested df -

i use ts.union() create column in nested data frame, inputs ts.union() being 2 nested time series in nested data frame. see set below. library(tidyverse) library(forecast) ts_special <- function(df){ts(df,start = c(2010,01), frequency = 4)} ets_spec <- function(df){ets(df, mod="mmm", opt.crit="lik", damped=null)} x <- cumsum(rnorm(48)) grp <- rep(c("a","b"), 24) dtf <- cbind(x, grp) %>% data.frame dtf <- dtf %>% group_by(grp) %>% nest dtf <- dtf %>% mutate(ts = map(data, ts_special)) dtf <- dtf %>% mutate(ets = map(ts, ets_spec)) dtf <- dtf %>% mutate(ets_fcast = map(ets, forecast)) dtf <- dtf %>% mutate(pred= map(dtf$ets_fcast, ~ .x[["mean"]])) # below works want dplyr way , nest result in column in dtf ts.union(dtf$ts[[1]], dtf$pred[[1]]) i'd have result of ts.union each group's time series , prediction combination stored in nested column in data frame, dtf .