Posts

java - How to edit a resource file from within an android app? (Android Studio) -

i'm creating android app utilizes log. i've placed file entitled "log.txt" in "raw" resource folder. have figured out how open inputstream using openrawresource , not sure how open can use printwriter it. i have tried accessing file pre-created on target device, have not succeeded. if explain me either how open resource file printwriter, i'd appreciate it. however not sure how open can use printwriter it. you can't. resources read-only @ runtime. welcome use inputstream write copy of resource's contents file on filesystem (e.g., on internal storage ), though.

fortran - Floating point numbers equality -

i using gfortran in mingw under windows 7 (32bit) compile fortran 77 code. here minimal code contained in testequal.f file: program testequal real*8 a1, a2 a1 = 0.3d0 a2 = 0.7d0 write(*,*) 1.d0 write(*,*) a1+a2 write(*,*) a1+a2.eq.1.0 write(*,*) a1+a2.eq.1.d0 end compile with gfortran testequal.f -std=legacy the output is: 1.0000000000000000 1.0000000000000000 f f but expect 2 booleans both t. problem here? with rare exceptions, don't compare floating point numbers exact equality. rules of finite-precision floating point arithmetic not same rules of real number arithmetic. compare numbers tolerance, e.g., sum = a1 + a2 if ( abs (sum - 1.0) < 1.0d-5 ) ...

windows services - How can I give SQL Server permission to read my SSL Key? -

Image
i created self-signed certificate , turned encryption on in sql server 2014: the problem sql server service won't start: this article 2010 identifies problem permissions issue: sql server service not have necessary permission read ssl cert's private key. the problem stuck on step 4 of solution proposed in article: there no group or user name matching proposed format when bring window shown in article. is there way can determine account sql server service runs under, can give permissions read ssl cert? an entirely different solution welcome too. if specify certificate, should used tls sql server, sql server windows service have read certificate and private key (the file folder %programdata%\microsoft\crypto\rsa\machinekeys ), corresponds certificate. problem is: the sql server configuration manager in not comfortable , makes not required work . thus first of 1 should localize account used sql server. 1 should start services.msc , find account ...

java - unable to send messages on chat program -

i writing chat program in java. can't seem able send messages. clientconnectionhandler handles instance of each client import java.io.*; import java.net.*; import java.text.*; import java.util.*; public class clientconnectionhandler extends thread { private socket socket; string username; private uuid id; //= uuid.randomuuid(); bufferedreader reader; printwriter writer; private final hashmap<uuid, clientconnectionhandler> clients = new hashmap<>(); volatile boolean messageloop = true; servergui servergui; public clientconnectionhandler(socket socket){ this.socket = socket; try{ this.socket.setsotimeout(1000); } catch (socketexception e) { system.out.println(e); } try { reader = new bufferedreader(new inputstreamreader(socket.getinputstream())); writer = new printwriter(new outputstreamwriter(socket.getoutputstream())); } catch (exception e){ e.printstacktrace(); } } public vo...

python - Writing a standard deviation function -

i have dictionary of words keys , ints value. outputs such: print (word_ratings_dict) {'hate': [1, 2, 2, 1, 1, 3, 0, 2, 3, 2, 0, 4, 1, 1], 'joy': [3, 4, 3, 3, 2, 4, 1]} for each key word in dictionary, need calculate standard deviation without using statistics module. heres have far: def menu_validate(prompt, min_val, max_val): """ produces prompt, gets input, validates input , returns value. """ while true: try: menu = int(input(prompt)) if menu >= min_val , menu <= max_val: return menu break elif menu.lower == "quit" or menu.lower == "q": quit() print("you must enter number value {} {}.".format(min_val, max_val)) except valueerror: print("you must enter number value {} {}.".format(min_val, max_val)) def open_file(prompt): """ opens ...

ractivejs - Ractive computed attributes returned in get() -

ref this jsfiddle html: <main /> <div id='result' /> code: window.ractive = new ractive({ el: 'main', template: '<p>a thing called {{thing}}</p>', computed: { thing : function(){return "kablooie"} } }); $('#result').html(json.stringify(ractive.get())) the ractive.get() here does return value of attribute "thing". though docs computed attributes not returned get(). is intentional behaviour or bug? in edge ractive (will 0.8) using, added computed , mapped properties root via ractive.get() feature request. see this issue current proposal able root data object via ractive.get('.') , mean: window.ractive = new ractive({ el: 'main', data: { foo: 'foo' }, template: '<p>a thing called {{thing}}</p>', computed: { thing : function(){return "kablooie"} } }); console.log( json.stringify( ractive.get() ) ); // { foo: ...

python - Adding attachements to slacker chat message -

i'm trying post message using slacker python api slack messages i'm not able attach link messages code below : attachments = [title, link_to_events, "more details"] print type(attachments) # list slack = slacker(slack_api_token) # send message #general channel slack.chat.post_message(slack_channel, message, attachments=attachments) in slacker code, looks looking "list" type of variable: https://github.com/os/slacker/blob/master/slacker/ init .py line 241: # ensure attachments json encoded if attachments: if isinstance(attachments, list): attachments = json.dumps(attachments) return self.post('chat.postmessage', data={ 'channel': channel, 'text': text, 'username': username, 'as_user': as_user, 'parse...