Posts

java - Simplifying Retrofit2 and Rxjava2 chained calls to use a Single instead of Observable in the final result -

what want accomplish update calls @ end of all, when subscribe, return single , not observable because ever receive 1 result due nature of combining calls, had move observable take advantage of observable methods join results single result. the issue having trying figure out how use results 1 call , combine result 1 , return combination of both. the sequence of calls follows: upload list of logos receive result of logos upload more detailed data of logos uploaded. use list of results got , use in new request make create book. receive newly create book response book more auto generated data get current author/user info ( forced make observable because single doesn't work .zip operator ) use author result , book details create pojo object. return final result. currently, returned observable there ever 1 entry returned makes little sense return observable. not sure how can transform return single appreciate suggestions. this code have right now. objects , such e...

Processing a job in background with Haskell Servant -

i'm building facebook messenger chatbot can process long running jobs (that may fail), , need respond 200 facebook before job completed. i've tried using pipes, after while realized didn't know doing. how can achieve this? thanks in advance edit: epsilonhalbe pointed, question broad. try make more clear. right have this: myhandler :: message -> handler text myhandler msg = dosomestuff msg return "ok" the problem "dosomestuff" long proccess , can give timeout error. want achieve respond "ok" before process completed. http code 202 accepted. i thinking sending message mailbox solution. more idiomatic way doing it. i use hworker @ work -- sending batch emails. make instances of job , tojson , , fromjson long-running job, use queue whenever want start job. you'll need redis keep track of state of jobs use hworker.

python 3.x - How to add columns to a tkinter.Listbox? -

i trying add these panda columns listbox , read this: new zealand nzd united states usd etc. i using pandas data .csv, when try , use loop add items list box using insert error nameerror: name 'end' not defined or nameerror: name 'end' not defined using code: def printcsv(): csv_file = ('testcur.csv') df = pd.read_csv(csv_file) print (df[['country','code']]) your_list = (df[['country','code']]) item in your_list: listbox.insert(end, item) you turn csv file dictionary, use combined country , currency codes keys , codes values, , insert keys listbox . code of current selection, can this: currencies[listbox.selection_get()] . listbox.selection_get() returns key use currency code in currencies dict. import csv import tkinter tk root = tk.tk() currencies = {} open('testcur.csv') f: next(f, none) # skip header. reader = csv.reader(f, delimiter=',') co...

regex - Display content of page in subfolder but preserve URL -

i have website people can purchase custom pages. main part of website (the main pages) in root directory, , custom pages located in folder / subdirectory. let's main pages 1 , 2 in root directory, , page 3,4,5,6,etc. (the custom pages) in subdirectory "u". website.com/page1 brings me website.com/page1, website.com/page2 brings me website.com/page2 now, pages in subfolder can accessed this: website.com/page3 gives me 404 error, website.com/u/page3 brings me website.com/u/page3 what want this: website.com/page3 brings me website.com/page3 displays content of website.com/u/page3. in other words, want have pages 3,4,5,6,etc., in folder " u " not want have " u " in url. user should able type in directly website.com/page3 , display contents of website.com/u/page3 , url must still remain website.com/page3 this should not affect page 1 , page 2 (which located in root directory). i've tried several pieces of code answers similar questi...

What does the single colon mean in this PHP statement? -

it used slimframework. first argument router pattern , second should callback. teacher gave class cdapi inside media namespace. understand ::class returns qualified class name resolution, concatenated part don't understand: ":getone" . getone function never saw colon used that, mean? $app->get('/super', \cdapi::class . ':getone'); slim framework has routing feature called "container resolution", , that's you're seeing when see single colon. see slim docs: https://www.slimframework.com/docs/objects/router.html you not limited defining function routes. in slim there few different ways define route action functions. in addition function, may use: container_key:method class:method an invokable class container_key this functionality enabled slim’s callable resolver class. translates string entry function call. their example: $app->get('/', '\homecontroller:ho...

angular - How to change Yeoman generator templates? -

i'm trying use old yeoman generator ( angular-crud ) create frontend rest api, need change templates , that's not working. it going well; found templates, changed them, saw changes - of sudden don't see more changes when generate. original author not responding , it's late find else. i've restarted computer several times same old code keeps being generated. questions, besides obvious general plea help, are: what's best way change generator's templates? does yeoman sort of disk-based caching might surviving restarts , causing old code generated. if #2 yes, how flush cache new code gets used?

google cloud endpoints v2 - GTLRObject not found -

Image
i trying link google cloud endpoint library ios application. using google cloudendpoint framework 2(migrating framework version 1) , compiling source files directly application. . when try build application error "gtlrobject not found". created google cloud endpoint ios client library using discovery document , service generator described here. https://github.com/google/google-api-objectivec-client-for-rest my application-bridging-header.h file this #ifndef myapp_bridging_header_h #define myapp_bridging_header_h #import "gtlrcloudendpoint.h" #endif /* myapp_bridging_header_h */ my header search path includes following - i have google cloud endpoints in lib my gtlrcloudendpoint.h has following code // note: file generated servicegenerator. // ------------------------------------------------------------------ ---------- // api: // cloudendpoint/v1.0 // description: // api #import "gtlrcloudendpointobjects.h" #import "gtl...

python - Arbitrary Precision Arithmetic in Julia -

this has kinda been asked, not in way. have little python program finds continued fractions square roots of n (1 <= n <= 10000). i have been trying in julia , can't see how to. because deals irrational numbers (sqrt(x) irrational if x not perfect square, e.g. sqrt(2) = 1.414213...). don't think can use rational class. it says here https://docs.julialang.org/en/release-0.4/manual/integers-and-floating-point-numbers/#man-arbitrary-precision-arithmetic julia can arbitrary precision arithmetic bigfloats. don't seem accurate enough. i have tried use pycall , decimals package in python (from julia), weird errors (i can post them if helpful). here python program works. , question how in julia please? def continuedfractionsquareroots(): ''' each number 100, length of continued fraction of square root it. ''' decimal.getcontext().prec = 210 # need lots of precision problem. continuedfractionlengths = [] in range(1, 101): ...

java ee - How to package an EJB as an EAR from Netbeans -

Image
to follow-up on ear versus jar question, how netbeans build project ear deployment on glassfish? the java-ee tutorial describes: 5.2.1 packaging enterprise beans in ejb jar modules an ejb jar file portable , can used various applications. assemble java ee application, package 1 or more modules, such ejb jar files, ear file, archive file holds application. when deploying ear file contains enterprise bean's ejb jar file, deploy enterprise bean glassfish server. can deploy ejb jar not contained in ear file. figure 5–2 shows contents of ejb jar file. figure 5–2 structure of enterprise bean jar the project created selecting "new ejb module" -- doesn't build ear jar ? there gui configuration made, or involved editing ant build file netbeans creates? interestingly enough, there's dist-ear build option in ant build file: thufir@doge:~/netbeansprojects/helloejb$ thufir@doge:~/netbeansprojects/helloejb$ ant -p tasks bu...

Implementing Oja's Learning rule in Hopfield Network using python -

i following paper implement oja's learning rule in python oja's learning rule u = 0.01 v = np.dot(self.weight , input_data.t) print(v.shape , self.weight.shape , input_data.shape) #(625, 2) (625, 625) (2, 625) so far, able follow paper, on arriving @ final equation link, run numpy array dimension mismatch errors seems expected. code final equation self.weight += u * v * (input_data.t - (v * self.weight) if break down so: u = 0.01 v = np.dot(self.weight , input_data.t) temp = u * v #(625, 2) x = input_data - np.dot(v.t , self.weight) #(2, 625) k = np.dot(temp , x) #(625, 625) self.weight = np.add(self.weight , k , casting = 'same_kind') this clears out dimension constraints, answer pattern wrong stretch (i fixing dimension orders knowing result incorrect). want know if interpretation of equation correct in first approach seemed logical way so. suggestions on implementing equation properly? i have implemented rule based on link oja rule . r...

c++11 - A text based c++ game with a mystery in code error -

im trying make basic tic tac toe game in c++. while code compile , run keep getting error code above board game: 0x6fefec84. i'm very new c++. error segfault? or there kind of ub going on in code? appreciated. thanks! #include <iostream> using namespace std; char square[10] = {'0','1','2','3','4','5','6','7','8','9'}; int checkwin(); int board(); int main() { int player = 1,i,choice; char mark; { board(); player=(player%2)?1:2; cout << "player" << player << ", enter number: "; cin >> choice; mark=(player == 1) ? 'x' : 'o'; if (choice == 1 && square [1] == '1') square [1] = mark; else if (choice == 2 && square [2] == '2') square [2] = mark; else if(choic...

arrays - C function pointer neither function nor pointer -

before go on, closest question mine found : subscripted value neither array nor pointer function error yet solution has not applied mine. i have c function goal take in array of floats , array of functions, apply each function value of same index in float array saving values in array passed in argument. i careful syntax , defined type function pointers: typedef float (*func_ptr)(float); (and if cares explain im comment or solution why syntax not (does not work as) typedef float (*)(float) func_ptr appreciated) the function (i think closest functioning) in question looks as: void vector_function(void * _f, float v[], size_t size, float ret[]){ func_ptr (*f)[size]=_f; //trying cast pointer array of function pointers float (*f)[size]=_f; for(size_t i=0; i<size; i++){ ret[i]=f[i](v[i]); } } the error is: > error: called object not function or function pointer > ret[i]=f[i](v[i]); > ^ what gets me seems typedef blatantly maki...

selenium - I am getting session not created exception, i am using Kepler version of eclipse, appium 1.6.5 and AVD version 7.0, below are the TestNG error logs: -

log:org.openqa.selenium.sessionnotcreatedexception: unable create new remote session. desired capabilities = capabilities [{appactivity=com.knowarth.hrmsapp.ui.loginactivity, platformversion=7.0, androidpackage=com.knowarth.hrmsapp, platformname=android, device=android, devicename=nexus 5x api 24}], required capabilities = capabilities [{}] build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800' system info: host: 'ka-lpt-104', ip: '192.168.43.85', os.name: 'windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_60' driver info: driver.version: androiddriver @ io.appium.java_client.remote.appiumprotocolhandshake.lambda$1(appiumprotocolhandshake.java:95) @ java.util.optional.orelsethrow(unknown source) @ io.appium.java_client.remote.appiumprotocolhandshake.createsession(appiumprotocolhandshake.java:95) @ io.appium.java_client.re...

smartcard - Verofone VX520 how to write custom software -

i have vx520 1 pin-pad. task is: store virtual money (f.e. litres of fuel) on chip card client can pay knowing pin-code terminal should available register , program new cards where start? there kind of sdk verifone terminals? found adk on official site, needs license (their email doesn't work when write them). there way develop own software without license? p.s. i'm using "sle4428" smart card--is ok? i think going wrong way. don't typically store data on card itself. instead, want have terminal read card , send data back-end server. server looks account based on unique card data , returns balance, etc. and, yes--you need develop own software work require license. in experience, little in verifone world ever free... or cheap, matter. yes, there sdk, can't use without license. if serious project , willing purchase need, can try , reach verifone through main site here or through developer site, here started. (disclaimer: don...

inheritance - How to invoke method which rewrite in sub class using javascript(es5) -

Image
i hava 2 class, 1 base class called chartbase, other sub class called chartextend, code following: /*base class defined*/ function chartbase(element, data, settings, type) { // this.init(); }; chartbase.prototype = { init:function(){ this.initconfig(); // other things; }, initconfig:function(){ this.setbaseconfig(); }, setbaseconfig:function(){ // something; } } /*sub class defined*/ function chartextend(element, data, settings, type) { chartbase.apply(this, arguments); }; chartextend.prototype = { initconfig:function(){ this.setbaseconfig(); this.setexternalconfig(); }, setexternalconfig:function(){ // something; } }; /*sub class extend base class*/ var tempclass = function() {};   tempclass.prototype = chartbase.prototype;   chartextend.prototype = new tempclass();  chartextend.prototype.constructor = chartextend; chartextend.uber = chartbase.prototype; /*instance*/ new chartextend(selector, data, settings, 'line...

android - AppMeasurementReceiver not registered/enabled and AppMeasurementService not registered not enabled -

**hey guys, know might question might have been asked before, need help. keep getting 'app_measurement_receiver' not registered/enabled, 'app_measurement_service' not enabled. cant seem login app. might problem guys , how may go it? ** 08-19 21:13:50.826 3019-3255/? e/fa: 'appmeasurementreceiver' not registered/enabled 08-19 21:13:50.827 3019-3255/? e/fa: 'appmeasurementservice' not registered/enabled 08-19 21:13:50.827 3019-3255/? e/fa: uploading not possible. app measurement disabled ** android manifest file** <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hushtagstudios.towme"> <!-- auto-complete email text field in login form user's emails --> <uses-permission android:name="android.permission.get_accounts" /> <uses-permission android:name="android.permission.read_profile" /> <uses-permission android:name="and...

Akka Http Code vrs Spring Boot Application -

i new akka http, moved spring boot application akka http seeing actor model benefits facing 1 issue. max-connection property in spring boot allows set max connection property spring boot application, not able set in new akka http application. fyi: developed new application using akkahttp performance comparison reports akkahttp less springboot application in terms of max connection , response time. testing used jmeter put load in both application 2000 user per second akkahttp code bad , spring boot awesome. during analysis figured out 1 property max-conection have configured in spring-boot enhancing it's performance. how set in akkahttp? can 1 me work around. note : have seen configuration akkahttp code http://doc.akka.io/docs/akka-http/10.0.9/scala/http/configuration.html not able figure out how use it. thanks file based configuration as indicated in link provided: usually means provide application.conf contains application-specific settings differ ...

Python: Find a substring in a string and returning the index of the substring -

i have: a function: def find_str(s, char) and string: "happy birthday" , i want input "py" , return 3 keep getting 2 return instead. code: def find_str(s, char): index = 0 if char in s: char = char[0] ch in s: if ch in s: index += 1 if ch == char: return index else: return -1 print(find_str("happy birthday", "py")) not sure what's wrong! ideally use str.find or str.index demented hedgehog said. said can't ... your problem code searches first character of search string which(the first one) @ index 2. you saying if char[0] in s , increment index until ch == char[0] returned 3 when tested still wrong. here's way it. def find_str(s, char): index = 0 if char in s: c = char[0] ch in s: if ch == c: if s[index:index+len(char)] == char: ...

android - How do I set my RadioButtons to increase the score only once even after being clicked multiple times? -

my issue have set scoring system each of radio buttons in radio group when click radio button multiple times or change answer score keeps on increasing. how set score increases once when radio button clicked , when answer changed show score of new option selected? public class mainactivity extends appcompatactivity { int score = 0; public textview tv; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tv = (textview)findviewbyid(r.id.textview); } public void onradiobuttonclicked(view view) { //is current radio button checked? boolean checked = ((radiobutton) view).ischecked(); //now check radio button selected //android switch statement switch (view.getid()) { case r.id.radiobutton: if (checked) score += 1; break; case r.id.radiobutton2: if (checked) score += 1; bre...

ssh - How to capture the output of executed command (python paramiko )? -

i executing commands , capture output of same. import paramiko ssh = paramiko.sshclient() ssh.set_missing_host_key_policy(paramiko.autoaddpolicy()) ssh.connect(ip,username="username",password="pwd") stdin, stdout, stderr = ssh.exec_command("whoami") out = stdout.read() print out # prints username print stdout.read() # prints nothing, why ? # instance #1 stdin, stdout, stderr = ssh.exec_command("kill -9 1111") out = stdout.read() print out #prints nothing. expected doesn't capture if it's successful # print out # should print "-bash: kill: (1111) - no such process" , if doesn't exist #--> instance #2 in instance #1, why print stdout.read() , prints nothing ? in instance #2, how capture such outputs/response ? instance #1 out = stdout.read() print stdout.read() the first stdout.read() has consumed output second stdout.read() returns nothing. instance #2 usually e...