Posts

elasticsearch - Is the order of operations guaranteed in a bulk update? -

i sending delete , index requests elasticsearch in bulk (the example adapted from docs ): { "delete" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } { "field1" : "value1" } the sequence above intended first delete possible document _id=1 , index new document same _id=1 . is order of actions guaranteed? in other words, example above, can sure delete not touch document index ed afterwards (because order not respected reason or another)? the delete operation useless in scenario, if index document same id, automatically , implicitly delete/replace previous document same id. so if document id=1 exists, sending below command replace (read delete , re-index it) { "index" : { "_index" : "test", ...

cron - how to properly run Python script with crontab on every system startup -

i have python script should open linux terminal, browser, file manager , text editor on system startup. decided crontab suitable way automatically run script. unfortunately, doesn't went well, nothing happened when reboot laptop. so, captured output of script file in order clues. seems script partially executed. use debian 8 (jessie), , here's python script: #!/usr/bin/env python3 import subprocess import webbrowser def action(): subprocess.call('gnome-terminal') subprocess.call('subl') subprocess.call(('xdg-open', '/home/fin/documents/learning')) webbrowser.open('https://reddit.com/r/python') if __name__ == '__main__': action() here's entry in crontab file: @reboot python3 /home/fin/labs/my-cheatcodes/src/dsktp_startup_script/dsktp_startup_script.py > capture_report.txt here's content of capture_report.txt file (i trim several lines, since long, prints folder structures. seems came ...

java - Mock creation of Object inside method -

problem description i'm trying mock object creation inside of method. have loginfragment creating loginpresenterimpl inside of oncreate method, shown below: public class loginfragment extends basefragment { private loginpresenter mpresenter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mpresenter = new loginpresenterimpl(this); <<-- should mocked } } i have problems combining robolectricgradletestrunner , powermockrunner in 1 test after reading this post, found way how that, test this: baserobolectrictest.java @runwith(powermockrunner.class) @powermockrunnerdelegate(robolectricgradletestrunner.class) @config(constants = buildconfig.class, sdk = 21) @powermockignore({"org.mockito.*", "org.robolectric.*", "android.*"}) public abstract class baserobolectrictest { } test.java @preparefortest({loginpresenterimpl.class}) public class test exte...

ios - label is not growing when the text is longer -

Image
i want view centered in superview grows due content in case label. don't want grow doesn't fit in screen anymore thats why pin left , right. i've put on test viewcontroller: import uikit import purelayout final class viewcontroller: uiviewcontroller { let container: uiview = { let container = uiview(forautolayout: ()) container.backgroundcolor = uicolor.blackcolor() container.clipstobounds = true return container }() let label: uilabel = { let label = uilabel(forautolayout: ()) label.textalignment = nstextalignment.center label.numberoflines = 1 label.textcolor = uicolor.redcolor() label.text = "this very long message" return label }() var rightview: uiview = { let view = uiview(forautolayout: ()) view.backgroundcolor = .redcolor() return view }() override func viewdidload() { super.viewdidload() self.co...

Slow performance first queries on SQL Azure -

i have small database (50mb) , i'm on basic plan. there single user, need create many databases (always 1 per user) since used training purposes. each database created doing following statement: create database training1 copy of modeldatabase1 we seem getting very slow performance when first query database, afterwards seems acceptable. to give idea: have sp: startupevents runs when application started. query takes 25 seconds run first time. seems incredible since database small, , tables query calls don't contain many records. if run procedure afterwards executes immediately... how can avoid this?

mapreduce - Resource manager does not transit to active state from standby -

one spark job running more 23 days , caused resource manager crash. after restarting resource manager istance (there 2 of them in our cluster) both of them stayed in standby state. and getting error: error org.apache.hadoop.yarn.server.resourcemanager.resourcemanager failed load/recover state org.apache.hadoop.yarn.exceptions.yarnexception: application id application_1470300000724_40101 present! cannot add duplicate! we not kill 'application_1470300000724_40101' yarn resource manager not working. killed instances unix level on nodes dint work. have tried rebooting nodes , still same. somewhere 1 entry of job still there , preventing resource manager elected active. using cloudera 5.3.0 , can see issue has been addressed , resolved in cloudera 5.3.3. @ moment need workaround past now. to resolve issue can format rmstatestore executing below command: yarn resourcemanager -format-state-store but careful clear application history executed befor...

serialization - Convert Any type in scala to Array[Byte] and back -

i have following question: i have variable value in program declared value. i want convert value byte array.. how can serialize byte array , back? found examples related other types such double or int, not any. this should need. it's pretty similar how 1 in java. import java.io.{bytearrayinputstream, bytearrayoutputstream, objectinputstream, objectoutputstream} object serialization extends app { def serialise(value: any): array[byte] = { val stream: bytearrayoutputstream = new bytearrayoutputstream() val oos = new objectoutputstream(stream) oos.writeobject(value) oos.close stream.tobytearray } def deserialise(bytes: array[byte]): = { val ois = new objectinputstream(new bytearrayinputstream(bytes)) val value = ois.readobject ois.close value } println(deserialise(serialise("my test"))) println(deserialise(serialise(list(1)))) println(deserialise(serialise(map(1 -> 2)))) println(deserialise(seri...

android - Do we need to use background thread for retrieving data using firebase? -

i've android app i'm retrieving data fragment. , believe firebase manages asynchronous calls. still i've doubt if need write firebase code in background thread or not?. if need write background thread can please tell operations takes more time. eg: mdatabase = firebasedatabase.getinstance().getreference().child("blog"); i think performing on main ui thread may become risk full because setting connection between database may sometime take large time. the firebase database client performs network , disk operations off main thread. the firebase database client invokes callbacks code on main thread. so network , disk access database no reason spin own threads or use background tasks. if disk, network i/o or cpu intensive operations in callback, might need perform off main thread yourself.

how to print a string to UITextField in xcode ios -

i m having mobile number, saved in nsstring variable in program, want display in uitextfield when user gets window of user details in ios app. want disable editing of phone number. how can that? m using xcode 7.4.2 initially check string contains value or not , like yourmobilenumbertextfield.userinteractionenabled = true; if (yourstring.length > 0) { yourmobilenumbertextfield.text = yourstring; yourmobilenumbertextfield.userinteractionenabled = false; } swift yourmobilenumbertextfield.userinteractionenabled = true if yourstring.length > 0 { yourmobilenumbertextfield.text = yourstring yourmobilenumbertextfield.userinteractionenabled = false } update for hold previous value in app go nsuserdefault , step-1 when otp verification success save current mobile number in userdefaults [[nsuserdefaults standarduserdefaults] setobject:yourmobilenumbertextfield.text forkey:@"mobile"]; step-2 if second time user comes on page need call nsstri...

python - Functions get called more and more times with reopening plugin -

i have qgis plugin written in python 2.7.3 pyqt 4.9.1, qt 4.8.1. when run plugin every function works fine. when close window , reopen again, every function happens twice. close/open again , goes 3 times, etc., etc. where should error here? def run(self) part looks this: def run(self): self.dlg.show() self.availablelayers() self.dlg.pushbutton_2.clicked.connect(self.openfile) self.dlg.pushbutton.clicked.connect(self.groupby) self.dlg.toolbutton_4.clicked.connect(self.togglerightpanel) if reload plugin clicking button "plugin builder", starts again one. i should mention wouldn't lose view user created (the plugin table viewer), rather able close window, open , have again there without cells being cleared. every time call connect , adds connection - if it's same slot. need move connections out of run() method , put them in setup method dialog, made once.

assembly - Registers modified by systemcall invoked through gcc's extended asm -

i using gcc's extended asm invoke system call. working on proprietary rtos on powerpc (freescale mpc5200b). according gcc's documentation should add registers assembly code uses - , neither input nor output - clobbers list, because gcc not analyse assembly code , not know registers being altered. the problem don't know registers system call alters. in fact i'm observing case system call alters register holding pointer. after system call has returned, pointer in register being used, leads invalid memory access. how should deal situation? for future readers: the general answer can find registers altered system call in documentation of system's abi. for system (freescale mpc5200b) found answer ibm application note 'developing powerpc embedded application binary interface (eabi) compliant programs'. so added registers marked volatile (namely r3..r12, f0..f13 , flags register) clobbers list.

hook - If the Wordpress session has timed out then run function -

i found examople: add_action( 'auth_cookie_expired', 'action_auth_cookie_expired' ); // define auth_cookie_expired callback function action_auth_cookie_expired( $rest_cookie_collect_status ) { echo 'ok'; wp_redirect( '/' ); }; but not work, when session timeout, , see popup login window add_action( 'auth_cookie_expired', 'action_auth_cookie_expired' ); // define auth_cookie_expired callback function action_auth_cookie_expired( $rest_cookie_collect_status ) { // set login session limit in seconds return year_in_seconds; // return month_in_seconds; // return day_in_seconds; // return hour_in_seconds; echo 'ok'; wp_redirect( '/' ); } please modify code according above code:

html - :hover triggered directly after page reload on Firefox (but not on Mac OS X Chrome) -

please check this codepen a) firefox , b) chrome. proceed follows: move mouse on link click link , not move mouse cursor @ afterwards wait until page has reloaded. if haven't moved mouse cursor, still above link after page has reloaded. firefox apply :hover styles now. chrome (mac os x) display element in it's non-hovered state (which prefer in scenario). anyone here has idea browser right, , how 1 browser mimic other's behaviour? for current scenario, i'd know how avoid :hover being triggered directly after page reload . i'd quite unhappy if had resort javascript that. for completeness' sake, here's demo's code: <a href="https://codepen.io/connexo/pen/pejbqj" target="_top">this codepen</a> a { color: #333; background-color: #ddd; display: inline-block; line-height: 40px; padding: 20px; text-decoration: none; transition-duration: .4s; &:before { content: "non-hove...

caching - Android: How to access/manage cached files after an app restart? -

looking @ docs when comes caching, seems i'm supposed use createtempfile() , if call succeeds, creates empty file. , if called again same arguments, won't return same filename. so if restart app, not have way retrieve temporary file? if wanted implement lru algorithm removing files cache, creating normal (non-temporary) file key value pairs of filenames , timestamps seem reasonable? (since don't think android updates sort last accessed times files) i'd manage cached files in memory alone. create separate directory cache files , use in memory lru singleton class managing files. each time app restarted, scan cache directory , reload lru cache directory contents. loose cache statistics on restart, if that's bad thing can handled when paused. managing cache in memory faster writing , re-writing key-value pair file. how many files intend keep in cache?

osx - Testing IPv6 from iPhone -

i need test ipv6 connection iphone app. followed this , running alright. testing ipv6 fails "no ipv6 address detected". one thing not clear is: doc says should use nat64 network - suppose means connecting name of wi-fi network created? any or have had issues this? as per apple compliance not connecting ipv6 endpoint, ipv6 network continues provide access ipv4 content through translation (dns64/nat64). simply, provider network ipv4 , translating ipv6 network per apple compliance.if have actual ipv6 testing succeed.

Spring Security add Authorities -

we have migrated spring security 3.0.5 3.2.5. using below code adding authorities. userdetails loadeduser = new userdetails(); loadeduser.getauthorities().add(new grantedauthorityimpl("role_admin")); now code giving below error the method add(capture#1-of ? extends grantedauthority) in type collection not applicable arguments (grantedauthorityimpl) can 1 please me issue ? there reason why interface grantedauthority provides getter not setter, objects meant immutable. enforce logout/login on permission change , set authorities on object creation this .

c++ - How can I determine if UBSAN has been compiled in using clang or gcc? -

we use following code determine if -fsanitize=address has been specified @ compile time clang , gcc. how determine if -fsanitize=undefined has been specified? bool issanitized = false; #if defined(__has_feature) #if __has_feature(address_sanitizer) issanitized = true; #endif #elif defined(__sanitize_address__) issanitized = true; #endif i suggest file bug asan github (or gcc bugzilla) (we have defined asan , tsan makes sense cook 1 ubsan well). seems option pass custom define -fsanitize-undefined in makefile.

drupal 8 - Form redirects to page /form_action_cc611e1d -

i installed contact_storage module can set redirect path when completing form, whenever complete form apparently ignores whatever have filled redirect path field , sends me "/form_action_cc611e1d". i have no idea comes from, reference find path in code in bigpipe core module, except module has not been active in project. i've cleared cache 100 times no avail. have idea how resolve this? it seems redirect happens when attaching js library in hook_form_form_id_alter() of form, js adds html (no form controls div's) , click handlers. this happens in 1 of our 6 templates though there must else interfering, unfortunately ran out of time further investigate this. to fix form added request uri form again: function schade_forms_alter(&$form, \drupal\core\form\formstateinterface $form_state, $form_id){ //attach js $form['#attached'] = array( 'library' => array( 'insusite_forms/form', ), ); ...

vba - Set font size of text -

i send text outlook email shows in font size 10. i have set @ 11 rest of email. signature set 11 well. i using this. ebody_tekst = "<font face= calibri size= 11px color=#000000>" & _ but still text show @ fontsize 10. probably may want try this: <body style=font-size:11pt;font-family:calibri>text</body>

java - write a gradle script that saves all the dependency into the ${projectDir}/lib folder -

so have gradle script gets dependencies following repository repositories { maven { url 'http://repository.paychex.com:8081/artifactory/repo1-cache' } ivy { url 'http://repository.paychex.com:8081/artifactory/repo1 cache' layout 'pattern', { artifact '[organization]/[module]/[revision]/[type]/[module]-[revision].jar' } } mavenlocal() } so when run customized gradle task wrote task showmecache << { configurations.compile.each { println } } it show jars being saved locally on c:\users\administrator.gradle\caches\modules-2\files-2.1*** i want write gradle task put dependencies given project ${projectdir}/lib folder instead of default location provided gradle. appreciated. thanks you can write copy task purpose: task copylibs(type: copy) { configurations.compile 'lib' } keep in mind still download , use resolved dependencies gradle cach...