Posts

Featured post

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...