Posts

c# - HttpClientt.SendAsync doesnt wait/lock execution -

var httpresponsemessage = await httpclient.sendasync(message).configureawait(false); var datastream = await httpresponsemessage.content.readasstreamasync(); this idea should awaited, no matter executions exists method , returns ui. execution resumes when responses arrives, time ui has updated execution finished, when in fact hasn't. calling methods awaited. initial method not awaited design (task.run(() => startdownload(selectedschedules)); starts ui method executing services triggers httpclient, when call finished ui should update progress, second httpclient.sendasync is executed, execution returns ui task.run(() => startdownload(selectedschedules)); //first call, initiated button public async task startdownload(scheduleslist list) { //var t = new task(() => _scheduleservices.download(list)); //t.start(); //await t; await _scheduleservices.downloadiwcfdb(list, usbinfomodels); } public async task download(scheduleslist scheduleslist) { ...

hadoop - Determining the current Kerberos user in an Apache Spark job -

i'm running spark jobs on kerberos-enabled cluster (cloudera), , able log kerberos identity of user, given run of job. (note not identity of local linux user launches job, because use keytab files, jaas.conf files, , call kinit in launch script. can log identity in launch script, since know principal passed kinit along keytab, nice able log within actual spark job itself, if job launched manually, reliably know identity ran under). some answers suggest following: import java.security.{accesscontroller,principal} import javax.security.auth.subject val acc = accesscontroller.getcontext val sub = subject.getsubject(acc) val principals = sub.getprincipals but returned sub null , not work. you need @ usergroupinformation class. to logged-in user, can use: import org.apache.hadoop.security.usergroupinformation val user = usergroupinformation.getloginuser res6: org.apache.hadoop.security.usergroupinformation = user@realm (auth:kerberos) wiki

json - Auto-indent rules for file extension in Visual Studio Code (vscode)? -

is there way tell visual studio code apply specific auto-indent rules given file extension? our current settings.json file is: { "editor.tabsize": 4, "editor.insertspaces": true, "files.associations": { "**/src/**/*.js": "javascriptreact" } } i did try following, did not work me: { "files.associations": { "**/src/**/*.js": "javascriptreact", "package.json": "json" }, "[javascriptreact]": { "editor.insertspaces": true, "editor.tabsize": 4 }, "[json]": { "editor.insertspaces": true, "editor.tabsize": 2 } } i did experiment [*.json] , did not work either. i using visual studio code 1.15.0. [for simplicity, i'll put various solutions answer.] vscode has handy way edit language-specific editor settings . ...

post - Postgresql Parallel Processing/Batch Processing -

i need call function, test_function(clientcode) every clientcode, c1, c2, etc. test_function(c1), test_function(c2) @ same time. inside test_function(clientcode): read records clientcode sampletable, insert values temporarytable, processing , put values finaltable. how make sure test_function(c1), test_function(c2), test_function(c3) called @ same time. how avoid locking? how batch processing achieved? can parallel processing done above scenario? appreciated. wiki

gridview - React Native listview with different type of components -

i developing react native application. on homepage need show posts video, audio, images, blogs, articles etc. confused how achieve . how can make list or grid view different type of components, mix of audio , video, images. backend add image or video or audio or blog , new post created in list.also want add new post beginning , not @ end. appreciated. you can use flatlist this. it's easy use , performance , recommended react-native (look @ this ). simple example of using flatlist can handle list items in separated component or function , pass in renderitem prop of flatlist . can see full document of flatlist in here : _keyextractor = (item, index) => item.id; _renderitem = ({item}) => ( if (item.type === 'video') { <myvideo item={item}/> } else if (item.type === 'image') { <myimage item={item}/> } else if ... ... ); render() { return ( <flatlist data={datalist} ...

javascript - Triggering an alert if the element that is clicked matches the array item in my random function -

i making flexbox grid game. each square has own id. point of game computer think of random square(this randomized array function each square id array element), , if clicked same 1 computer thought of, alert message pops telling you picked right one. otherwise tells wrong. i cant figure out how link clicked item if else statement can check see if matches random number. have far. <body onload ="picknumber()"> <div class="container""> <button id="flex1" onclick="showanswer()"></button> <button id="flex2" onclick="showanswer()"></button> ...and on , forth </div> </body> function picknumber() { var grid = ["flex1", "flex2", "flex3", "flex4", "flex5", "flex6", "flex7", "flex8", "flex9"]; var randomnumber = grid[math.floor(math.random() * value...

node.js - MongoDB: How to get data by join -

i having following 2 schemas in mongodb var userschema = new schema({ first_name: string, last_name: string, email: string }); var messageschema = new schema({ sender: {type: schema.types.objectid, ref: 'users' }, receiver: {type: schema.types.objectid, ref: 'users' }, message: string, senton: date, }); var users = mongoose.model('users', userschema); var messages = mongoose.model('messages', messageschema); how can query users 'users' collection , last message (single) 'messages' collection? wiki