Posts

Showing posts from September, 2015

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

Wrapping default windows thumbnail handler for photos -

i write new thumbnail handler photos. want thumbnail handler activated on specific folders. if file not in on of these special folders, forward call windows default thumbnail handler. want thumbnail handler simple wrapper on default one. there way call default handler handler code? if matters, relevant windows 10. thanks,

java - How to make JTable with JComboBox respond only on double click instead of single click -

Image
so first time tried using celleditors jtable embed jcombobox , jspinner . works fine expected wherein can see values in jcombobox model jspinner 's model values. however, noticed displays jcombobox 's values make single click on jtable's column has jcombobox . it's not user friendly because think user prefer double click on jtable 's column dropdown box values , select values instead of single click . how can change jcombobox 's behaviour display on double click? i thought i'd apply mouselistener jcombobox don't know next. here's i've written far. public class scheduledaycelleditor extends defaultcelleditor{ private jcombobox jcmbdays; private jtable jtblschedule; private defaultcomboboxmodel model; public scheduledaycelleditor(){ super(new jcombobox()); model = new defaultcomboboxmodel(new string[]{"mon","tue","wed","thu","fri"}); jc...

html - What do percents regarding above-the-fold content mean? -

upd i've read related pages carefully, doesn't answer particular question. percents mean? well, there's attempt @ explanation: google page insights tell how many % of css referring content above fold being loaded late , page have been rendered earlier. but not @ clearer pagespeed says. if @ correct. i have page css inlined in head (not yet probably, 12k) , one dummy external stylesheet @ end of body tag: <!doctype html> <html><head> ...<style>...</style>... </head><body> ... <link rel="stylesheet" href="1.css"> <script src="..."></script> <script src="..."></script> <script src="..."></script> </body></html> 1.css: .not-used-selector {color: red;} pagespeed tells me: approximately 55% of above-the-fold content on page rendered without waiting following resources load. try defer...

unicode - Powershell full-width characters overlapped -

Image
when type full-width characters on cmd , powershell '가방을 먹는 나', contrary cmd, characters overlap each other , won't displayed normally. how can fix it? i typed "가방을 먹는 나", in picture, "가방을 먹 displayed, , 는 나" omitted.

sql server - The type initializer for '<module>' threw an exception -

i tried searching problem found problem in visual studio. using sql server 2012 in application.i able connect database through c# application when open sql server management studio,i getting error message this message . tried restarting sql server configuration manager,but still getting same error.

nginx-tomcat setup: readv() failed (104: Connection reset by peer) while reading upstream, client -

i have setup nginx front-facing server , tomcat instances upstream servers in reverse proxy setup. i keep getting error on various requests: 2017/07/20 11:43:11 [error] 16892#16892: *3154964 readv() failed (104: connection reset peer) while reading upstream, client: , server: myserver, request: "get // http/1.1", upstream: "http:///", host: "myserver", referrer: " https://myserver/ " what error mean , how fix it? below relevant parts of nginx conf directives: user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 2000; multi_accept on; use epoll; } http { upstream backend { server localhost:8080 max_fails=3 fail_timeout=120s; } location /path { proxy_pass http://backend; proxy_redirect off; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $remote_addr; ...

Node.js crypto gives webpack compile error -

i developing appilication using node.js, react, yarn , webpack , not experienced in these technologies. i needed use encryption , tried use build-in crypto module. problem simple command: crypto = require('crypto'); in js file, webpack compilation fails following messages: @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.js error in ./node_modules/parse-asn1/aesid.json module build failed: syntaxerror: unexpected token, expected ; (1:25) > 1 | {"2.16.840.1.101.3.4.1.1": "aes-128-ecb", | ^ 2 | "2.16.840.1.101.3.4.1.2": "aes-128-cbc", 3 | "2.16.840.1.101.3.4.1.3": "aes-128-ofb", 4 | "2.16.840.1.101.3.4.1.4": "aes-128-cfb", i have tried use other encryption libraries node-simple-encryptor , sjcl same error! i guess must webpack (version 3.5.2) problem, because when use same libraries in test javascript file...

javascript - How to return promise up the chain after recursion -

i making request returns paged data, want call function recursively until have of pages of data, so: router.get("/", (req, res) => { dorequest(1, []) .then(result => { res.status(200).send(result); }) .catch(error => { console.error(error); res.status(500).send("error request"); }); }); function dorequest(page, list){ let options = { uri : "www.example.com", qs : { "page" : page } }; request(options) .then((results) => { list.push(results); if(page === 2){ return promise.resolve(list); } else { return dorequest(++page, list); } }) .catch((error) => { return promise.reject(error); }); } my route returning cannot read property 'then' of undefined , dorequest() apparently returning undefined righ...

build - Duplicate entry: com/google/android/gms/security/ProviderInstaller.class -

what this: error:execution failed task ':app:transformclasseswithjarmergingfordebug'. com.android.build.api.transform.transformexception: java.util.zip.zipexception: duplicate entry: com/google/android/gms/security/providerinstaller.class i got while trying build apk.

shell - sort duplicates date wise -

i have file two-column elements(id , date). want sort elements depending on id, , in case several elements have same id, sorted depending on dates. i used sort -t" " -k2 -t"/" -k3 -k2 -k1 file.txt didn't work. don't know how use filed separator. input file 01/02/2012 1 02/03/2012 1 04/04/2012 1 01/02/2015 2 02/03/2014 2 04/04/2013 2 and output file should : 01/02/2012 1 02/03/2012 1 04/04/2012 1 04/04/2013...

php - CodeIgniter Date or DateTime -

i have 1 problem, can not resolve , have no idea mistake 1 create tabel called posts , in codeigniter create form posts, after createing post want display posts in index.php , have table called date of departure, , date of return. 1 create post date looking when display in index.php it's 0000-00-00 00:00:00 in begginig data type date, change datetime nothing happend, same problem maybe make mistake in js script comment ? my script <script> $( function() { $( "#datepicker" ).datepicker(); $( "#datepicker1" ).datepicker(); } ); </script> when field in mysql date-time aspects proper format before saving in database. so convert string date time format in php using. date("y-m-d h:i:s", strtotime($string)); or can same in datepicker $(function() { $('#datepicker').datepicker({ dateformat: 'yy-dd-mm', onselect: function(datetext){ var d = new date(); // ...

javascript - Block request URLs that don't contain a specific pattern in chrome -

Image
i going block request urls don't contain specific pattern. i know there request blocking tab in google chrome network tab (after right click on request row select block request url). for example have 7 request urls: http://www.test.com?userid=5 http://www.test.com?username=username http://www.test.com?email=email http://www.test.com?name=x http://www.test.com?family=q http://www.test.com?family=y http://www.test.com?family=z i can block requests have specific pattern adding pattern(for example pattern *family* blocks 3 below requests): http://www.test.com?family=q http://www.test.com?family=y http://www.test.com?family=z be careful! because patterns case sensitive how block requests don't contain family word?(the same below) http://www.test.com?userid=5 http://www.test.com?username=username http://www.test.com?email=email http://www.test.com?name=x can use of regular expression?

php - Laravel 5.4, Login page keep redirecting -

i'm having issue login page keeps redirecting me login instead of going homepage. my routes file: route::group(['middleware' => ['auth']], function () { route::get('/', function () { return redirect()->route('dash'); }); route::get('dash', 'dashcontroller@index')->name('dash'); }); route::get('login', ['as' => 'login', 'uses' => 'ldapauthcontroller@index']); route::post('login', 'ldapauthcontroller@login'); everything else set normal default setting: redirectifauthenticated middleware: <?php namespace app\http\middleware; use closure; use illuminate\support\facades\auth; class redirectifauthenticated { /** * handle incoming request. * * @param \illuminate\http\request $request * @param \closure $next * @param string|null $guard * @return mixed */ public function handl...

c# - how to set session variable in the global asax -

Image
hi trying set session variable on global asax, intention , when test whole project no need keep relogin, in end have investigate , found article. session state not available in context - in global.asax so put session application_acquirerequeststate not occur error of session state not available in context. however after use it, error still there... wrong it?

python - Django, capturing client IP getting -

i trying capture client ip , store log in database, have tried using packages ipware still getting same error when run application file "/users/abdul/documents/tutorial/drftutorial/urls.py", line 2, in <module> . import views file "/users/abdul/documents/tutorial/drftutorial/views.py", line 24, in <module> class usercreateview(generics.createapiview): file "/users/abdul/documents/tutorial/drftutorial/views.py", line 27, in usercreateview ip=get_client_ip(request) file "/users/abdul/documents/tutorial/drftutorial/views.py", line 17, in get_client_ip x_forwarded_for = request.meta.get('http_x_forwarded_for') attributeerror: 'module' object has no attribute 'meta' i believe error happening because not accessing request method properly, using django-restframework , tutorial followed did not pass request object when calling view. here code: def get_client_ip(request): x_forwarded_for = request.meta...

Transforming XML by means of XSLT — how to remove tags totally? -

at moment, working xslt & need help. have xml file: <?xml version="1.0" encoding="utf-8" standalone="no"?> <entries> <entry> <field>1</field> </entry> <entry> <field>2</field> </entry> <entry> <field>3</field> </entry> <entry> <field>4</field> </entry> <entry> <field>5</field> </entry> </entries> i need format xml reseive this: <?xml version="1.0" encoding="utf-8" standalone="no"?> <entries> <entry field="1"> <entry field="2"> <entry field="3"> <entry field="4"> <entry field="5"> </entries> but reseive this: <?xml version="1.0" encoding="utf-8" standalone=...

ssh - MySQL gone away error running mysql command large file -

i want load large .sql file (1.5gb) everytime stuck on 623.9 mb error: mysql server has gone away. running following command: mysql -u {db-user-name} -p {db-name} < {db.file.sql path} already changed my.cnf file following values, did not help: wait_timeout = 3600 max_allowed_packet = 100m innodb_lock_wait_timeout = 2000 what missing here? refer link - mysql server has gone away when importing large sql file - various combinations have worked problem.

pdf - Which CFF font fields make a visual difference? -

i'm writing converter cff (postscript type 2) fonts, , i'm wondering fields converter can remove without making visual difference when font used in pdf file. i think these fields can removed or changed: /fontname /postscript.fstype /postscript.origfonttype /postscript.origfontname /postscript.origfontstyle /fontinfo.version /fontinfo.notice /fontinfo.copyright /fontinfo.fullname /fontinfo.familyname /fontinfo.weight /fontinfo.isfixedpitch /uniqueid /xuid i think these fields must kept, because affect rendering: /strokewidth /painttype /charstringtype /fontmatrix /encoding /charstrings /private.bluevalues /private.otherblues /private.familyblues /private.familyotherblues /private.bluescale /private.blueshift /private.bluefuzz /private.stdhw /private.stdvw /private.stemsnaph /private.stemsnapv /private.subrs /private.globalsubrs /private.defaultwidthx /private.nominalwidthx i'm not sure these fields: ...

Ceasars Cipher in Ruby -

class ceasarscipher def initialize text @text = text.split '' end def encrypt key @text = @text.each |letter| key.times if letter != "z" letter.next! else letter = "a" end end end end def printcipher puts @text end end cipher = ceasarscipher.new "abcdefghijklmnopqrstuvwxyz" cipher.encrypt 2 cipher.printcipher when run code output is: c d e f g h j k l m n o p q r s t u v w x y z z z i don't understand why there z 3 times. thought long time don't it... answers. it's because when letter = "a" don't change string, instead declare new variable. here fix using map : def encrypt key @text.map! |l| key.times.reduce(l) |l| l == 'z' ? 'a' : l.next end end end

javascript - Is it possible to convert select dropdown into horizontal months list in jQuery UI Datepicker? -

Image
i'm building calendar based on jquery ui datepicker possibility choose date range 3 months displayed @ once. looks on screenshot: so need add block above calendar 12 horizontally positioned months starting current month. think need convert default select dropdown months horizontal list, due little experience javascript wasn't able bring work of similar examples internet. when choose month in block should switch calendar 3 chosen months. hope able suggest me solution. here current code: $("#datepicker").datepicker({ numberofmonths: 3, showbuttonpanel: false, dateformat: 'dd.mm.yy', mindate: 0, maxdate: new date(new date().gettime() + 365 * 24 * 60 * 60 * 1000), beforeshowday: function(date) { var startdate = $.datepicker.parsedate('dd.mm.yy', $('#start-date').val()); var enddate = $.datepicker.parsedate('dd.mm.yy', $('#end-date').val()); if (startdate && enddate && startdate - endd...