Posts

Showing posts from February, 2014

angular - Angular4: HttpClient - many requests in succession -

i have http request list of items feed. feed api requires page param, limited 20. first 60 instead, need make 3 requests requestoptions.params.set('page', 1); this.http.get(environment.api+ '.feed.json', requestoptions) requestoptions.params.set('page', 2); this.http.get(environment.api+ '.feed.json', requestoptions) requestoptions.params.set('page', 3); this.http.get(environment.api+ '.feed.json', requestoptions) what best way deal ordered list? not fond of nesting your service: getpage(page) { /*init requestoptions*/ requestoptions.params.set('page', page); return this.http .get(environment.api+ '.feed.json', requestoptions) .map(/*map object expected one*/) .catch(/*catch http exception*/); } somewhere call service let allpages = []; observable.forkjoin( this.service.getpage(1); this.service.getpage(2); this.service.getpage(3); ).subscribe((resparray) =>{ allpages

ios - Swift doesn't convert Objective-C NSError** to throws -

i have objective-c legacy code, declares method like - (void)dosomethingwithargument:(argtype)argument error:(nserror **)error as written here https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/adoptingcocoadesignpatterns.html swift automatically translates objective-c methods produce errors methods throw error according swift’s native error handling functionality. but in project described methods called this: object.dosomething(argument: argtype, error: nserrorpointer) moreover, throws runtime exception when try use them like: let errorptr = nserrorpointer() object.dosomething(argumentvalue, error: errorptr) do need more convert objective-c "nserror **" methods swift "trows" methods? only objective-c methods return bool or (nullable) object translated throwing methods in swift. the reason cocoa methods use return value no or nil indicate failure of method, , not set error object. docu

g++ - TextView Gtkmm - Changing Size -

i trying build window in gtkmm. of widgets appearing, cannot adjust height of textviews. have tried set_border_window_size() , set_size_request(), neither working. is, not changing aspect of textview size. here window constructor: udpwindow::udpwindow() : gtk::applicationwindow(), box_hbox(gtk::orientation_horizontal, 7), box_vbox1(gtk::orientation_vertical, 7), box_vbox2(gtk::orientation_vertical, 7), box_sentdata(gtk::orientation_vertical, 7), box_receiveddata(gtk::orientation_vertical, 7), frm_sentdata("sent data"), frm_receiveddata("received data"), lbl_sendmessage("message send"), lbl_senddevice("select device"), btn_send("send message"), btn_quit("quit"), comms(null) { // set udp communications //comms = new udp_communicator(); uchar device[3] = {1, 2, 3}; /*device[0] = comms->createnewsocket(52088, "192.168.1.2", 2); device[1] = comms->createnewsocket(8090, "192.168.1.3", 2); device[2

amazon web services - Copy encrypted EBS snapshot to another account -

i'm trying copy encrypted ebs instance 1 aws account part of disaster recovery process. i'm hoping has done before, i'm looking clever way approach it. big problem seems encryption keys. i've been able create k8s pod "backup" automatically when introducing encryption seems break because can't find key. one more note, i've familiarized myself sharing process, ebs shared different account form account copy , forth - found few posts here nothing similar i'm looking for. advanced thanks. when create encrypted ebs volume, want specify custom encryption key. key can shared across regions/accounts. you must use custom key if want copy snapshot account when start copy operation can specify new key. according aws: using new key copy provides additional level of isolation between 2 accounts. part of copy operation, data re-encrypted using new key. please review https://aws.amazon.com/blogs/aws/new-cross-account-copying-of-en

python - Using Raspberry Pi to Receive Float from Arduino using NRF24L01 -

i've been learning on how transfer data arduino raspberry pi wirelessly using nrf24l01 based on following reference: raspberry pi 3 tutorial 14 – wireless pi arduino communication nrf24l01+ . the reason why want log temperature , humidity data wirelessly using dht22 sensors. the arduino code shown below: //sendreceive.ino #include<spi.h> #include<rf24.h> // ce, csn pins rf24 radio(9, 10); void setup(void){ while(!serial); serial.begin(9600); radio.begin(); radio.setpalevel(rf24_pa_max); radio.setchannel(0x76); radio.openwritingpipe(0xf0f0f0f0e1ll); const uint64_t pipe = (0xe8e8f0f0e1ll); radio.openreadingpipe(1, pipe); radio.enabledynamicpayloads(); radio.powerup(); } void loop(void){ radio.startlistening(); serial.println("starting loop. radio on."); char receivedmessage[32] = {0}; if(radio.available()){ radio.read(receivedmessage, sizeof(receivedmessage)); serial.println

generics - Java Compile time parameter interdependency -

i'm designing event driven system sends events data queue. listener on queue dispatches messages via javax.enterprise.event, have methods listening these events via observerving qualifiers. system behaves i'd expect i'm missing compile-time type validation. basic code can found below: public interface ieventsender { void send(final servereventtypeenum servereventtypeenum, final ieventdata eventdata); } public class observingclientclass{ public void eventaprocessservice(@observes @ieventtypequalifier(event_1) servereventmessage servereventmessage) { //handle event, cast data concrete implementation x (x) servereventmessage.geteventdata() } } public enum servereventtypeenum implements ieventtypeenum { event_1, event_2 } public interface ieventdata extends serializable{ } public class x implements ieventdata { } public class y implements ieventdata { } the servereventtypeenum enum types of events support. the eventdata generi

c# - How to use c#7 with Visual Studio 2015? -

Image
i´ve heard lastest preview of visual studio 15 can configured play features of c#7 , visual studio 2015 ? how can use c#7 it? you can replace compiler shipped visual studio c# 7-enabled version installing nuget package microsoft.net.compilers : referencing package cause project built using specific version of c# , visual basic compilers contained in package, opposed system installed version. there no indication can see on package page whether officially supported in visual studio 2015. not-thorough tests far indicate works not painlessly - c# 7 code compiles, underlined red squiggly line indicates syntax error: note need install nuget package system.valuetuple use new c# 7 value tuples features. wiki

javascript - How to update the existing nodes attributes of a d3js tree, based on an input value from a search box? -

i working d3js example: https://bl.ocks.org/mbostock/4339083 in case, difference whole code wrapped within function being called externally. consider variables defined within such function. then, still externally, want update nodes attributes based on search box created following: <div id="footer"> <label for="search">search: </label> <input type="text" id="search" onkeyup="update(this.value)"> </div> the box seems operational. can type within , each time press key calls following function created texts/labels existing nodes. function update(query) { var text = d3.select("svg") .selectall('text') .style("font-weight", function (d) { console.log(d.name) if (d.name.tolowercase().indexof(query.tolowercase()) != -1) { return "bold" } else { return "normal" } });

amazon ec2 - DC/OS stateful app with persistent external storage -

i'm trying setup stateful app in dc/os assigning external (ebs) volume docker container. i've ran demo app provided in docs , created 100gb ebs volume in aws. there way specify size of volume in marathon.json file? can use same ebs volume multiple apps? here's demo app i've tested. { "id": "/test-docker", "instances": 1, "cpus": 0.1, "mem": 32, "cmd": "date >> /data/test-rexray-volume/test.txt; cat /data/test-rexray-volume/test.txt", "container": { "type": "docker", "docker": { "image": "alpine:3.1", "network": "host", "forcepullimage": true }, "volumes": [ { "containerpath": "/data/test-rexray-volume", "external": { "name": "my-test-vol", "provider&

soapui - Handle DST in UTC time using Groovy -

i trying convert milliseconds time date-time (yyyy-mm-dd't'hh:mm:ss'z') format in utc. def startdatetimenew = testcase.testsuite.project.getpropertyvalue("startdatetime").tolong() def startdate = new date(startdatetimenew).format("yyyy-mm-dd't'hh:mm:ss'z'", timezone.gettimezone('utc')); log.info startdate 'startdatetime' value '1503478800000' the output getting :- tue aug 22 18:13:59 ist 2017:info:2017-08-23t09:00:00z but want handle dst in output :- tue aug 22 18:13:59 ist 2017:info:2017-08-23t10:00:00z if you're on java 8, i'd highly recommend using new java.time api instead of java.util.date import java.time.* import java.time.format.datetimeformatter // converts millis zoneddatetime representation def currentzone = zoneid.systemdefault() // or whatever appropriate zone def startdate = zoneddatetime.ofinstant(instant.ofepochmilli(startdatetimelong), currentzone) // format

ms access - VBA Recordset Update Hanging On Specfic Record -

so have below... sub test4() dim db dao.database dim source_rst dao.recordset dim dest_rst dao.recordset set db = currentdb set source_rst = db.openrecordset("select distinctrow [scorecard last ran].[scorecard id], round(([dqs - scorecard history].[no passed]/([dqs - scorecard history].[no passed]+[dqs - scorecard history].[no failed]))*100,1) & '%' score [dqs - scorecards] inner join ((select [dqs - scorecard history].[scorecard id], max([dqs - scorecard history].[date/time scorecard ran]) [maxofdate/time scorecard ran] [dqs - scorecard history] group [dqs - scorecard history].[scorecard id]) [scorecard last ran] inner join [dqs - scorecard history] on ([scorecard last ran].[maxofdate/time scorecard ran] = [dqs - scorecard history].[date/time scorecard ran]) , ([scorecard last ran].[scorecard id] = [dqs - scorecard history].[scorecard id])) on [dqs - scorecards].id = [dqs - scorecard history].[scorecard id];") set dest_rst = db.openrecordset("dqs -

bass - MIDI tick to millisecond? -

i realize there many questions here concerning converting midi ticks milliseconds (ex: how convert midi timeline actual timeline should played , midi ticks actual playback seconds !!! ( midi music) , midi timestamp in seconds ) , have looked @ them all, tried implement suggestions, still not getting it. (did mention little "math phobic") can me work practical example? using bass lib un4seen . have data need - don't trust calculations. bass methods tick // position of midi stream uint64_t tick = bass_channelgetposition(midifilestream, bass_pos_midi_tick) ppqn //the pulses per quarter note (or ticks per beat) value of midi stream. float ppqn; bass_channelgetattribute(handle, bass_attrib_midi_ppqn, &ppqn); tempo //tempo in microseconds per quarter note. uint32_t tempo = bass_midi_streamgetevent( midifilestream, -1, midi_event_tempo); my attempt @ calculating ms value tick: float currentmilliseconds = tick * tempo / (ppqn * 1000); the value a

php - how can i make wordpress display posts from the second top 10 posts? -

i using code display in main page posts number of views function wh_post_display_order_view($query) { if ($query->is_home() && $query->is_main_query()) { $query->set('meta_key', 'whpp_track_post_views'); $query->set('orderby', 'meta_value_num'); $query->set('order', 'desc'); } } add_action('pre_get_posts','wh_post_display_order_view'); how can make display posts second top 10 posts? ex : want 1st post appears number 11 in viewed posts you can use offset parameter so: $query->set('offset', 10); more pagination , wp query class here wiki

Project Euler Palindrome #4 with C -

i found few posts regarding problem using c. of elements in code work on own iteration @ beginning causing problems reason. first, i'm getting "exited non-zero status" error message. when run program smaller range , b, don't message. i'm guessing there's problem rev_array , for_array variables created. i'm sure i'm doing dumb right here apologize in advance that. but when use smaller range , b (like 10 25), program still showing two-digit numbers (even 11, 22, 33, 44) not same forward , backward. used printf check this. i made similar program used fixed values , b instead of iterating on range of values , worked fine. couldn't figure out why 1 isn't working. #include <stdio.h> #include <stdlib.h> #include <math.h> int max; int a; int b; int prod; int m = 0; int rev_array[10000]; int for_array[10000]; int c; int d; int same = 0; int main(void) { // iterate on 3 digit numbers in lines 19-21 for(a = 10; <= 25;

entity framework 6 - EF6 upgrade issues -

we have upgraded our application ef6. facing below error when click on 1 of button present in aspx page. page using context object. {system.invalidoperationexception: executereader requires command have transaction when connection assigned command in pending local transaction. transaction property of command has not been initialized. @ system.data.sqlclient.sqlcommand.validatecommand(string method, boolean async) @ system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method, taskcompletionsource`1 completion, int32 timeout, task& task, boolean asyncwrite) @ system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method) @ system.data.sqlclient.sqlcommand.executereader(commandbehavior behavior, string method) @ system.data.sqlclient.sqlcommand.executedbdatareader(commandbehavior behavior)

c# - dynamically generate a windows 10ish tile-menue in Windows Forms -

Image
does know way generate tiles, sorted groups dynamically? something tile view in windows 10(or in case devexpress example) the goal programmatically add groups or tiles this: list.add("groupname","tilename"). groupname primary key of group , foreignkey of tile. here's simple example created started model part. let's have tile class represents tile. in case, put directly group name part of tile, have group class , store groupid in tile. public class tile { public string title { get; set; } public string group { get; set; } } now, let's have created few tiles : var tiles = new tile[] { new tile { title = "tile 1", group = "group 1" }, new tile { title = "tile 2", group = "group 1" }, new tile { title = "tile 3", group = "group 1" }, new tile { title = "tile 4", group = "group 2" }, new tile { title = "tile 5"

math - PHP perfect round off -

i'm trying round off following figures: case 1: round( ((4/6) * 100), 2 ) . '%'; = 66.67% round( ((1/6) * 100), 2 ) . '%'; = 16.67% round( ((1/6) * 100), 2 ) . '%'; = 16.67% total % = 66.67 + 16.67 + 16.67 = 100.01% case 2: round( ((5/11) * 100), 2 ) . '%'; = 45.45% round( ((3/11) * 100), 2 ) . '%'; = 27.27% round( ((3/11) * 100), 2 ) . '%'; = 27.27% total % = 45.45 + 27.27 + 27.27 = 99.99% can tell me how make perfect 100% thanks if prefect 100 100.00 , use case: round( ((4/6) * 100), 3 ); = 66.667 round( ((1/6) * 100), 3 ); = 16.667 round( ((1/6) * 100), 3 ); = 16.667 round(66.667+16.667+16.667, 2); = 100 echo round( ((5/11) * 100), 3 ); = 45.455 echo round( ((3/11) * 100), 3 ); = 27.273 echo round( ((3/11) * 100), 3 ); = 27.273 echo round(45.455+27.273+27.273, 2); = 100 you can make more prefect increasing rounded precision, e.g. use 15 instead of 3 double values ;). or $a1 = (4/6)*100; $b1 = (1/6)*1

node.js - How to remove chai http queries from mocha test report? -

Image
http chai queries break test report. there way remove it? on image attached dot reporter used , line of dots expected in report. instead of see each dot on single line , after each there http query report. wiki

java - IntelliJ IDEA using JavaScript "version" of dependency specified in Gradle build file? -

Image
this issue (past couple days) started occurring on 1 of development machines. i'm using eclipse's vert.x dependency web project: build.gradle dependencies { ... // kotlin compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" // vert.x web framework compile group: 'io.vertx', name: 'vertx-core', version: '3.4.2' compile group: 'io.vertx', name: 'vertx-web', version: '3.4.2' ... } this has worked fine in past - think triggering action upgrading intellij 2017.2.2, now: intellij cannot resolve of -web imports: if examine dependencies list module, javascript version of dependency shown? how did happen , , how can make sure it's recognized java dependency? edit: sample project available here: https://youtrack.jetbrains.com/issue/idea-177950 this bug in kotlin plugin fixed in version 1.1.4-2. after update plugin, need delete incorrect libraries

c# - "Current user *** have no permission.",it showed this while using SqlCacheDependency and HttpRuntime.Cache.How to solve it? -

sqlcachedependencyadmin.enablenotifications(connstring); sqlcachedependencyadmin.enabletablefornotifications(connstring, tablename); sqlcachedependency sqldenpendency = new sqlcachedependency(entryname, tablename); httpruntime.cache.insert(key,lstdata,sqldenpendency,datetime.now.addminutes(timeout), cache.noslidingexpiration); when used sqlcachedependency save data httpruntime.cache this,there runtime error following: current user uu163 have no permission . transaction ended in trigger. batch has been aborted. [sqlexception (0x80131904): current user uu163 have no permission . transaction ended in trigger. batch has been aborted.] system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection, action 1 wrapcloseinaction) +2442126 system.data.sqlclient.sqlinternalconnection.onerror(sqlexception exception, boolean breakconnection, action 1 wrapcloseinaction) +5736904 system.data.sqlclient.tdsparser.throwexceptionandwarning

node.js - What is the recommended way to build the authentication for NodeJS Postgresql backend server? -

as tittle says, i've been looking @ how people use passport sessions, passport-jwt jsonwebtoken, passport jsonwebtoken, express-jwt and half way through got lost in "best practice" combine ? could advice me on ? wiki

java - Flashlight blink on button click in android -

i developing flashlight application in trying add blink functionality on button click. code found is: string mystring = "0101010101"; long blinkdelay 50; //delay in ms (int = 0; < mystring.length(); i++) { if (mystring.charat(i) == '0') { params.setflashmode(parameters.flash_mode_on); } else { params.setflashmode(parameters.flash_mode_off); } try { thread.sleep(blinkdelay); } catch (interruptedexception e) { e.printstacktrace(); } } but code turns off flashlight after few blinks. how can start flashlight blink on button click , stop unless click again? help? it's controlled string length loop break after count of becomes greater last index. use while loop if want blink flash continuously. can use 1 boolean variable switch between on off. , boolean in while condition break loop when button clicked wiki

Difference between Xamrin android, Xamrin iOS and Xamrine crossplatform project -

Image
what difference between xamarin android, xamarin ios , xamrin crossplatform project? xamarin android , xamrin ios native? thought make 1 single app on xamarin works on both ios , android. p.s: started work xamarin. i copy info here xamarin android makes possible create native android applications using same ui controls in java, flexibility , elegance of modern language (c#). xamarin.ios allows developers create native ios applications using same ui controls available in objective-c , xcode, except flexibility , elegance of modern language (c#). and xamarin cross platform, it's little more complex explain. as can see in image, xamarin cross platform, can share tremendous amount of code between apps(ios, android, uwp, etc) , if use xamarin forms can share ui (which based in xaml , of course can implement native things custom renders). you can view more xamarin in developer web page: https://developer.xamarin.com/guides/ wiki

git - Cleaning up a remote tree after a rebase -

after pushing rebase bare remote , running git gc --aggressive --prune=now on remote, else needed force commit history of remote indicate same history new checkout remote would, no indication of rebase? example, needs done on remote remove history , show single squashed commit: $ mkdir test $ cd test $ git init $ touch foo $ git add foo $ git commit -m 'initial commit.' $ git remote add origin ssh://user@git.domain.com:29418/~user/test.git $ git push -u origin master $ in {1..10} > > echo $i >>foo > git add -u > git commit -m "adding $i foo." > git push origin master > done $ git reset --soft 99a31c5906f82b333ca5c6204a3f83e3f100d4e7 $ cat foo 1 2 3 4 5 6 7 8 9 10 $ git commit --amend --no-edit $ git push origin master --force # on git server inside bare repo: [root@server test.git]# git log --graph --all --oneline * 8068d90 push * 203f010 push * 58b851d push * 5e385c9 push * 3c3a5b2 push * 5b40efd push * 558d8e1 pus

php - Planning for a large Yii2 application -

i thinking how build large application client in yii2. experience comes several smaller yii2 projects. what major decisions have made during first steps cannot changed later on , typical yii2 solution patterns that? here features i'm thinking of: user administration a jump start extension yii2-user or yii2-usario. gives user management, user login, password reset features , like. multi-tenancy to manage multiple clients in 1 database, recommended add client id every table , use yii2 behaviors add table field every database query. optional / complex features yii2 provides "modules" code separation. yii2 modules can have components, models, views, controllers,... , perfect delivering independent features @ later stage. or separate features core application. are there similar yii2 patterns know start of project in order avoid major refactoring during project? an important patter available in yii2 me rbac (authorization acces roles) .. if a

android - Getting Cursor IndexOutOfBound Exception when passing contact-id to fetch details from Contacts -

i getting contact details of person according account name working fine exception contacts have name not numbers. getting contact ids when fetch details using contact_id phone cursor causes exception private void displayallcontactsbytype(string accountname) //account-name: mobikwik { cursor rawcursor = null; rawcursor = cresolver.query( contactscontract.rawcontacts.content_uri, new string[]{contactscontract.rawcontacts.contact_id}, contactscontract.rawcontacts.account_name + "= ? , "+contactscontract.rawcontacts.contact_id + " != 0", new string[]{accountname}, contactscontract.contacts.display_name_primary + " collate localized asc"); int contactidcolumn = rawcursor.getcolumnindex(contactscontract.rawcontacts.contact_id); int rawcursorcount = rawcursor.getcount(); int total = 1; utils.log("raw size", " " + rawcursorcount); while (rawcu

why is (WebView) in brackets in android -

my background web design using js html , css writing simple apps - nothing professional. have recent had urge learn bit android development. came across below line. understand defining variable webview etc, don't understand why '(webview)', in brackets, used in statement. webview browser; browser=(webview)findviewbyid(r.id.webkit); i can imagine android haven't come across in js before. or info on can read on appreciated! it type casting. webview browser; in above line, declaring browser object of webview . so can hold webview so, in below line, setting type webview in order prevent error if findviewbyid(r.id.webkit); return otherwise browser=(webview)findviewbyid(r.id.webkit); this java feature. you can read more in oracle java documentation wiki

vba - Count tags in web page HTML code -

how can count number of tags in html web site code? try use code: f=ie.document.getelementsbytagname("p") msgbox f.count but not work $("p").length if want count tags in html page use jquery ".length" gives length of tags in html page. wiki

java - How to run a shell command in a different working directory -

my program runs in directory in c: drive, need run shell commands in directory in drive d, example. how can this: processbuilder builder = new processbuilder( "cmd.exe", "/c", "cd \"d:\\\" && dir"); to change working directory of process, call directory() on builder before starting it. wiki

osx - Why won't my mac discover devices in this Core Bluetooth App? -

i've been working on core bluetooth mac app , i've run issues discovery part on mac. code has failed to discovery devices despite fact same devices appear in bluetooth setting of mac. it's code issue can't seem figure out. code: import cocoa import corebluetooth class viewcontroller: nsviewcontroller, cbcentralmanagerdelegate { var centralmanager: cbcentralmanager! override func viewdidload() { super.viewdidload() centralmanager = cbcentralmanager(delegate: self, queue: dispatchqueue.main) // additional setup after loading view. } override var representedobject: any? { didset { // update view, if loaded. } } func setupbt() { } func centralmanagerdidupdatestate(_ central: cbcentralmanager) { var statusmessage = "" switch central.state { case .poweredon: statusmessage = "bluetooth status: turned on" case .poweredoff: statusmessage = "bluetooth status: turned off" case .

angular - Detect keyboard with HostListener -

i create few components in angular (4.0.0) detect keyboard language (rus-eng) decorator hostlistener: // detect keyboard lan @hostlistener("window:keypress", ["$event"]) public detectkeyboard(keycode: number, mode: string): void { // if current lan rus if (mode === "rus") { if (keycode >= 128 && keycode <= 255) { this.currentkeyboard = "rus on"; } else { this.currentkeyboard = "eng on"; } } } and method interfacing keyboard message // interfacing keyboard message public getkeyboard(): string { return this.currentkeyboard; } this template: <div *ngif="getkeyboard()" class="alert alert-danger"> {{currentkeyboard}} </div> and add output share in component: @output("keyboard") public keyboard: eventemitter<object>; in template of component call this: <div (keypress.keyboard)="detectk

sql - How to calculate the median of a row in Mysql? -

i new sql , have been struggling nan-median, example, have table 3 (million) rows, each ten numbers (or null): row1: 1,2,3,null,4,5,6,7,8,9 ---------- row2: 2,4,null,6,8,2,1,0,9,10 ---------- row3: 1,1,1,1,null,7,2,9,9,9 ---------- how nan-median of each row ? according question, if have 10 columns want calculate. trick avoid null values coalesce function. use logic: select (coalesce(col1, 0) + coalesce(col2, 0) + coalesce(col3, 0)+ coalesce(col4, 0)+coalesce(col5, 0)+coalesce(col6, 0)+coalesce(col7, 0)+coalesce(col8, 0)+coalesce(col9, 0)+.coalesce(col10, 0))/10 yourtable wiki

Order of an initialization in inline initialization. C/C++ -

this question has answer here: c++: variable declaration initialization order 1 answer order of initialization multiple declarators in single declaration 3 answers here code concerned with: double first(2), second(first); will first variable initialized before second one? wiki

javascript - How to get exclusive read lock in mongodb? -

node file accessing running balance based on last record of user's account sorted timestamp multiple threads in mongodb accessing same record @ same time every mongo thread getting inconsistent running balance. is there way execute read operations sequentially ? wiki

javascript - React, setState warning for mounted/unmounted component -

i have react component using load images progressively app has been working great me. when use on page load images, though, seeing error: warning.js:35 warning: setstate(...): can update mounted or mounting component. means called setstate() on unmounted component. no-op. multiple times - looks once each image called. not seem effecting image components still work. wondering how rid of error though, cannot figure out how. so here component: import react, { proptypes } 'react'; require('./progressive-image.scss'); export default class progressiveimage extends react.component { constructor(props) { super(props); this.state = { loaded: false, image: props.smallimg }; this.loadimage = this.loadimage.bind(this); this.onload = this.onload.bind(this); this.onerror = this.onerror.bind(this); this.image = undefined; } componentdidmount() { const { largeimg } = this.props; this.loadimage(largeimg); }

(Closed) Javascript: outputting a .txt file as a string -

so have function takes contents of .txt file , returns string... or @ least should. instead, returns "undefined". however, "console.log(text);" outputs proper text, makes me believe can't convert contents string since has line breaks in it, different text on each line of .txt file. how can convert output string can use .split , convert array (having each line of text in notecard translate separate item in array)? please help! <script>//_____read_text_file_____ function done() { var filecontents = this.response; var text = filecontents; console.log(text); return text; } function readtxt(filename) { var xmlhttp; xmlhttp=new xmlhttprequest(); xmlhttp.addeventlistener("load", done, false); xmlhttp.open("get",filename,true); xmlhttp.send(); } </script> wiki

node.js - Dockerfile for an npm project -

i'm trying add docker-compose setup crates.io project. current file npm piece follows: from node:8.4 env npm_config_global true copy package.json package-lock.json ./ run npm install and it's fine , when try build it, is: building frontend step 1/4 : node:8.4 ---> 6f6ffe2a1302 step 2/4 : env npm_config_global true ---> using cache ---> 868e1aec7aac step 3/4 : copy package.json ./ ---> 3846f64854e0 removing intermediate container a1dea9f3f3a2 step 4/4 : run npm install ---> running in 18b3f1003133 npm info worked if ends ok npm info using npm@5.3.0 npm info using node@v8.4.0 npm info lifecycle cargo@0.0.0~preinstall: cargo@0.0.0 npm info linkstuff cargo@0.0.0 npm info lifecycle cargo@0.0.0~install: cargo@0.0.0 npm info lifecycle cargo@0.0.0~postinstall: cargo@0.0.0 + cargo@0.0.0 added 1 package in 0.23s npm info ok ---> 6785fa0a2b21 removing intermediate container 18b3f1003133 built 6785fa0a2b21 tagged cratesio_frontend:latest so none of dev

Connect Java to a MySQL database -

how connect mysql database in java? drivermanager old way of doing things. better way datasource , either looking 1 app server container configured you: context context = new initialcontext(); datasource datasource = (datasource) context.lookup("java:comp/env/jdbc/mydb"); or instantiating , configuring 1 database driver directly: mysqldatasource datasource = new mysqldatasource(); datasource.setuser("scott"); datasource.setpassword("tiger"); datasource.setservername("mydbhost.example.org"); and obtain connections it, same above: connection conn = datasource.getconnection(); statement stmt = conn.createstatement(); resultset rs = stmt.executequery("select id users"); ... rs.close(); stmt.close(); conn.close(); wiki

java - Kafka consumer.poll call not returning kafka ConsumerRecords -

i'm new kafka technology..i'm working on poc need send producerrecord<string, paymnt> kafka topic paymnt pojo..i able publish record & see messages being delivered kafka topic.. d:\kafka\kafka_2.11-0.11.0.0\bin\windows>kafka-run-class.bat kafka.tools.getoffsetshell --broker-list localhost:9092 --topic test --time -1 test:2:0 test:1:0 test:0:4 however on consumer side i'm not able retrieve same record..when debug consumer code,i see thread call blocking on consumer.poll() consumer class public class consumer { public static void main(string args[]) throws ioexception { properties props = new properties(); kafkaconsumer<string, paymnt> consumer = null; props.put("bootstrap.servers", "localhost:9092"); props.put("batch.size", 16384); props.put("buffer.memory", 33554432); props.put("key.deserializer", "org.apache.kafka.common.serialization.stringdeserializer");

c# - Add Section in PowerPoint using OpenXML -

Image
i trying insert section in powerpoint presentation, not able find relevant code. using pmldocument insert/merge slides. pmldocument proposaldocument = presentationbuilder.buildpresentation(sources); i glad if share link or reference. thank you. wiki

php - how to allow all wildcard string to the routing url in laravel -

i'm developing laravel api.so when during implementation face problem in passing parameters routing url. have pass parameters ,one sessionid , other 1 userid. session id this, eyjpdii6uiikf6teltnvp1yw5bajltytytyydmvgc9psisinzhbhvlijoiyuiuiuiu081ntdyttfvemnwswfnae1nsmv2stazixtuiuiuiuizfiuunue9psisim1hyiuiuiuiyi6ijjknjjjngnlnwu5otuxzwuwmdrlmzi2ytvimgy0mdfiuiuiumnmi5zmu2nwu2zuiuiuiuim3mwjizdu2zwvkyzfimwi4ogjjnwmifq%3d%3d so session id contains a-z,a-z,.,etc , wildcard strings (%3d%3d) congaing string i've try lots of ways pass sessionid string function.but still no proper solution me. this code segment , routes.php $api->version('v1',function ($api){ $api->get('oneu/{id?}/{userid}',[ 'as'=>'user', 'uses'=> 'app\http\controllers\usercontroller@show']) ->where(['id' => '.[a-za-z1-9\-_\/?;!"`\'()`\|{}]+']); }); this controller class code segment public fu

javascript - Pass value of multiple input fields in jQuery ajax? -

i have multiple input fields, like <p>filter gender</p> <select class="filter-users"> <option value="female">female</option> <option value="male">male</option> </select> <p>filter city</p> <input class="filter-users" type="text" name="city"> how create request url these 1 or of these inputs $.ajax({ url: "/users/filter", type: "get", data: { city: city, gender: gender }, success: function(response) { } }); how make ajax request every time on of filter inputs changed? example send new request when on option change, or text input entered? trying explain is, there no submit button. requests needs made everytime 1 of these fields changes you can use serializearray , this: $.ajax({ url: "/users/filter", type: "get", data: $("form").serial

log4j2 - FlumeException: No active client -

how fix it? 2017-08-23 10:37:33,729 main warn unable write flumeavro[192.168.26.132:4141] @ 192.168.26.132:4141 org.apache.flume.eventdeliveryexception: failed send event. exception follows: @ org.apache.flume.api.failoverrpcclient.append(failoverrpcclient.java:169) @ org.apache.logging.log4j.flume.appender.flumeavromanager.send(flumeavromanager.java:186) @ org.apache.logging.log4j.flume.appender.flumeappender.append(flumeappender.java:105) @ org.apache.logging.log4j.core.config.appendercontrol.trycallappender(appendercontrol.java:155) @ org.apache.logging.log4j.core.config.appendercontrol.callappender0(appendercontrol.java:128) @ org.apache.logging.log4j.core.config.appendercontrol.callappenderpreventrecursion(appendercontrol.java:119) @ org.apache.logging.log4j.core.config.appendercontrol.callappender(appendercontrol.java:84) @ org.apache.logging.log4j.core.config.loggerconfig.callappenders(loggerconfig.java:390) @ org.apache.logging.log

reduction parallel loop in julia -

we can use c = @parallel (vcat) i=1:10 (i,i+1) end but when i'm trying use push!() instead of vcat() i'm getting error. how can use push!() in parallel loop? c = @parallel (push!) i=1:10 (c, (i,i+1)) end elaborating bit on dan's point; see how parallel macro works, see difference between following 2 invocations: julia> @parallel print in 1:10 (i,i+1) end (1, 2)(2, 3)nothing(3, 4)nothing(4, 5)nothing(5, 6)nothing(6, 7)nothing(7, 8)nothing(8, 9)nothing(9, 10)nothing(10, 11) julia> @parallel string in 1:10 (i,i+1) end "(1, 2)(2, 3)(3, 4)(4, 5)(5, 6)(6, 7)(7, 8)(8, 9)(9, 10)(10, 11)" from top 1 should clear what's going on. each iteration produces output. when comes using specified function on outputs, done in output pairs. 2 first pair of outputs fed print, , the result of print operation becomes first item in next pair processed. since output nothing , print prints nothing

c# - How to validate a column in an editable datatable? -

Image
am using editable html datatable on asp.net web page .which this, how add validation on column target, receive float values.? function (for enable edit): function editrow(otable, nrow) { var adata = otable.fngetdata(nrow); var jqtds = $('>td', nrow); jqtds[0].innerhtml = adata[0]; jqtds[1].innerhtml = adata[1]; jqtds[2].innerhtml = '<input type="text" id="float" class="form-control" value="' + adata[2] + '">'; jqtds[3].innerhtml = '<a class="save-row" href="">save</a>'; jqtds[4].innerhtml = '<a class="cancel-row" href="">cancel</a>'; } i tried add keypress event on textbox , not working.! $('#float').keypress(function (event) { if ((event.which != 46 || $(this).val().indexof('.') != -1) && (event.which < 48 || event.which > 57) && (event.which != 8)) {

api design - REST Partial update on multiple resources -

i have 2 sorts of resources, stores , items, store can uniquely identified by it's id, store contains number of different types of items.items have codes identify type , instance conductor cable of modela has code of 265, item of code 265 can exist in more 1 store. sample http requests , responses. get /stores/1/items [{ "itemcode": 265, "itemdescription": "conductor cable", "itemmodel": "model1", "uom":"meter", "quantity": 30 }, { "itemcode": 122, "itemdescription": "low-fat milk", "itemmodel": "model2", "uom":"liter", "quantity": 15 }] /stores/2/items [{ "itemcode": 265, "itemdescription": "conductor cable", "itemmodel": "model1", "uom":"meter", "quantity": 2

javascript - node Cron with callback getting Cannot enqueue Handshake after invoking quit error -

i trying query db in particular interval. using node corn. creating connection every minute , close once query completed. works first minute, next minute throws error of cannot enqueue handshake after invoking quit, using callback. 1 correct doing wrong app.js var scontroller = require('./scontroller'); cron.schedule('* * * * *',function(){ console.log("i running every minute"); var params ="dddd"; scontroller.updatedb(params,function(err,res){ console.log("xxxx"); }); }); scontroller.js var smodel = require('./smodel'); var scontroller = function(){} scontroller.prototype.updatedb = function(params,callback){ smodel.updatedb(params,function(res,err){ if(res){ console.log("kkk"); } callback(err,res); }); } module.exports = new scontroller(); smodel.js var connection = mysql.createconnection(mysqlconfig); function mysqlconnect() { connection.connect

excel - Close userform using myForm.Hide or Unload Me -

before start let me give background. working on vba project excel , computer using has limited resources (and have been asked light possible fast execution time). in project open multiple userform @ different times, apply filters on sheet example. as said resources limited , want know if frmfilters.hide enough close userform or if there better way ? i've read about unload me i'm not sure how it's working because i'll apply filters form , need keep them once form closed until user totally close excel file. is there situation unload me better frmfilters.hide ? regards, teasel i found interesting answer question thought useful post here. unload me unload me removes form memory , stop application if on main form of project. every modification did in form lost. hide myform.hide only hide form. if on main form of application, not end program (the debug mode still running example). every modification in form kept next time show form. wh

php - Xampp apache service freezes(not a port proplem) -

i can't run apache service in xampp ...when try run first time says shutdown unexpectedly (i've tried change port , close apps use port 80 , changed port , makes no sense) when try run second time says attempting start apache service... , don't says else wiki

Powershell turn strings into array with headings -

Image
i'd create table headings series of strings, have been pulled output. i've used this... $scopearray = @("$server","$ip","$scopename","$comment") to turn this... $ip = $trimmed[0] $server = $trimmed[1] $scopename = $trimmed[2] $comment = $trimmed[3] into this: ps c:\windows\system32> $scopearray myserver.domain 10.1.1.1 nameofscope scopedetails but need turn table, this: i've tried below, , copule of other multidimentional examples, i'm missing fundamental. $table = @() foreach ($instance in $scopearray) { $row = "" | select servername,ip,scopename,comment $row.heading1 = "server name" $row.heading2 = "ip address" $row.heading3 = "scope name" $row.heading4 = "comment" $table += $row } create objects input data: ... | foreach-object { new-object -type psobject -property @{ 'server name' = $trimmed[1] 'ip address&#

c# - Calling (ID_number) primary key to textbox using Combobox(Category Description) -

dealing foreign key using ms access in c#. each time select category description(catdesc) using combobox category table, wanted get/call automatically category id(catid) in textbox1. my code doesn't worked, , no errors given. this sample_code: private void cmdcategoryy_textchanged(object sender, eventargs e) { categorydesc(); } void categorydesc() { oledbconnection mycon = new oledbconnection(@"provider = microsoft.ace.oledb.12.0; data source = c:\users\blabla\desktop\docsmonitorg\try 081517\windowsformsapp6\windowsformsapp6\database.accdb"); string con; try { con = "select catid, catdesc category catdesc = '" + cmdcategoryy.text + "' "; mycon.open(); oledbcommand cm = new oledbcommand(); oledbdataadapter da = new oledbdataadapter(); datatable mydata1 = new datatable(); cm.commandtext = con; cm.connection = mycon; int i; da.sele

python - Is it possible to have two mailboxes(folders) with same name? -

i working on product have interact email servers (like zimbra, dovecot etc) through imap fetch emails etc. i using python's imaplib library. connect email server account credentials , select mailbox (folder) through name. now wondering whether possible have 2 mailboxes same name in account? if yes how go ? question : unclear on this. using select(mailbox=... dealing real folders . therefore no duplicate possible. imap4.select(mailbox=’inbox’, readonly=false) select mailbox. returned data count of messages in mailbox (exists response). default mailbox 'inbox'. if readonly flag set, modifications mailbox not allowed. wiki