Posts

renaming files in a directory using python or R -

i went across similar questions of renaming files in directory using python. i have these files in directory want rename: -statistical_analysis_with_r -statistical_pattern_recognition_3rd_edition -statistical analysis r -statistical pattern recognition 3rd edition for wrote script in windows: def naming(so): import re w=re.split('[ _]+',so) r=[] in w: r.append(i.capitalize()) print(' '.join(r)) import os c in os.listdir(os.getcwd()): if c.endswith(".pdf"): os.rename(c,naming(c)) print(os.listdir(os.getcwd())) but getting error: statistical analysis r.pdf traceback (most recent call last): file "<ipython-input-79-d7f645d6d3e5>", line 4, in <module> os.rename(c,naming(c)) typeerror: rename: can't specify none path argument can what's going on? and doing same thing using r (www.r-project.org)? loads of in advance. your naming functio...

ruby on rails - Carrierwave Timeout -

i have used carrierwave users upload files in rails app. when user uploads multiple files of size more 400mb (approx.) timeout error. note: i've hosted app rails app on heroku. uploading large files through heroku not recommended. limit request 30 seconds , not enough time 400mb. if open using s3, heroku provides potential rails solution that.

vbscript - How to batch combine PDFs with sub-folder based non-JavaScript bookmarks -

having been avid reader here many years, have question of own couldn't find answer for. i looking solution, preferably vb scriptable, combines several pdf files different subfolders 1 new pdf , adds bookmarks based on folder structure, i.e. first page originating first file folder gets first level bookmark based on folder name, , second level bookmark based on file name. subsequent files folder second level bookmarks linked under first level bookmark. as added complication, bookmarks must point location in document; must not javascript based , call actions. this should happening on win7 pc. unfortunately don't know how internal workings of pdfs (yet), can't quite believe that problem uncommon isn't solved already!? can pointing me in right direction (or providing script, of course, if it's easy), or confirming above isn't possible, or else, really? thank much! best

Images won't display through CSS -

if try set background image using css, flat out not load. if use same path in html, will. making slider of these images, hence need work css. i've browsed every answer on internet similar problems , nothing works. relevant html: <div class="slider-container"> <div class="slider5"></div> <div class="slider4"></div> <div class="slider3"></div> <div class="slider2"></div> <div class="slider1"></div> </div> css: .slider-container { overflow: hidden; width: 100%; height: auto; } .slider1, .slider2, .slider3, .slider4, .slider5 { width: 100%; height: auto; position: static; top: 0px; cursor: pointer; transition: 0s linear; -webkit-transition: 0s linear; -moz-transition: 0s linear; -o-transition: 0s linear; } ...

html - outline-style different in chrome compared to firefox and internet explorer -

seems firefox , ie have default of black dotted outline while chrome has default of light blue solid outline. i tried change doing this: a{ outline-style: dotted; outline-color: black; } this seems catastrophe links got dotted black outline not hovered or focused. terrible because "outline" thing can differentiate mouse focus keyboard key focus. any other idea on how make chrome's outline others ? <!doctype html> <html> <head> <style type="text/css"> body{ font-size: 1.5em; font-family: verdana; } .zone2 a{ outline-width: thick; outline-color: red; } .zone3 a{ outline-style: solid; } </style> </head> <body> outline tests:<br/> <div class="zone1"> <a href="#">test link 1</a><br/> <a href=...

javascript - Spinner in Angular.js -

i want use spinner can show during of rest api calls better ux. have come across many existing github projects similar things. https://github.com/cgross/angular-busy https://github.com/urish/angular-spinner but i'm not able use of existing projects. think before start writing of own, want know if things i'm looking can done using these projects or other existing project. requirement: during of rest api calls uploading images, fetching data, deleting images, etc, want show spinner background faded. once have result, can show background again , remove spinner. i want use spinner start/stop controller not html. i don't want spinner xhr requests default. i think angular-busy demo solves of above requirements except needs promise param in html. there anyway can control start/stop dynamically controller rather giving promise. angular-spinner demo doesn't fade out background. there way fade out background ? can give me pointers how can solve prob...

c# - Valueinjecter map base derived class -

i have base class ad . public class ad { public int id{get;set;} public string title{get;set;} public string price{get;set;} } then have lot of derived classes like: public class carad : ad { public string modelname {get;set;} } public class mobilead : ad { public string companyname {get;set;} } and accordingly have viewmodels these classes well. public class adviewmodel { public int id{get;set;} public string title{get;set;} public string price{get;set;} } public class caradviewmodel : adviewmodel { public string modelname {get;set;} } public class mobileadviewmodel : adviewmodel { public string companyname {get;set;} } i trying map derived class base class using value injecter. like: [httppost] public async task<ihttpactionresult> post([frombody] caradviewmodel caradmodel) { var ad = new ad(); ad.injectfrom(caradmodel); } but not mapping properties of derived class. can tell me if...

javascript - How to open a third party HTML project from a web application ,in a separate browser tab -

i'm developing java web application. , want add help component that.(so user clicks on help button page open in separate tab) the help page separate html project it's own css , js. (let's it's small separate html project) . , can manually run clicking index.html file in project.( help/index.html ) so how can add button in web application user clicks on , open help page in new browser tab. you put web application: <a href="#" onclick="window.open('help/index.html', '_blank');"> click here</a>

bash - display text file and update when the file contents change -

i want have window open content of file file.txt . not care command use open it, nano, cat, vi or whatever. want update every time changes, if open in window, edit , save it, file in original window update, kind of screen . suggestions? i have tried having open new cat file.txt command every few seconds, unreliable. use watch cat file.txt that should update when changes occur, try man watch to see options has can update frequency of updates.

osx - Creating a png image from SpriteKit Node/SpriteNode in Xcode for Mac -

currently i'm making isometric map editor (in swift) each map tile added sknode called maplayer . want know whether possible produce png image maplayer , once have finished designing map? not in swift should give idea on how it. you can capture screen uiimage doing this: cgrect bounds = self.scene.view.bounds; uigraphicsbeginimagecontextwithoptions(bounds.size, no, [uiscreen mainscreen].scale); [self drawviewhierarchyinrect:bounds afterscreenupdates:yes]; uiimage* screenshotimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); then create png image uiimage (and write disk) this: // create paths output images nsstring *pngpath = [nshomedirectory() stringbyappendingpathcomponent:@"documents/test.png"]; nsstring *jpgpath = [nshomedirectory() stringbyappendingpathcomponent:@"documents/test.jpg"]; source here . // write uiimage jpeg minimum compression (best quality) // value 'image' must uiimage object ...

Java, Catching an exception and passing it to a method -

i created method accepts ioexception argument. method opens out stream , prints information exception text file. problem seem running into.. how call method catch block? try{ if(true) throw new ioexception(); } catch(ioexception e){ //pass method } :::edit::: public void logerrors(ioexception e){ printwriter out = yada yada; out.println(e.getcause()); } basically have call name of method, want method's code executed this: try{ if(true) throw new ioexception(); } catch(ioexception e){ //pass method methodtoexecute(e); } also, can see throw ioexception in both cases perhaps may want consider modifying code use block edit on second thought, can use if statement throw always. if (...) { yourmethod(throw new ioexception()); }

How to plot the discrte form of the logistic model in matlab -

i want plot y(k) againts k of following formula in matlab: y(k+1)=r(y(k))(1-y(k)) so did following: %logistic model in discrete form. r=2.5; y=rand(1); j=1:100 y(j+1)=r*y(j)*(1-y(j)); end plot(y(j+1),j) but when run it, thing gives me white plot, is, axis. did wrong here?, can me fix it? thanks lot in advance. you need create array of values of function. %logistic model in discrete form. r=2.5; y = zeros(100, 1); y(1) = rand(1); j=1:100 y(j+1)=r*y(j)*(1-y(j)); end plot(1:101, y) plot function 2 arrays, first values of x axis, second values of y axis.

Run as Ant build' Missing in my eclipse -

i unable right click , run build.xml file choosing 'run ant' . whenever click says run configuration , goes running java file options . this works me. go to.. 1. -> install new software work -> " http://download.eclipse.org/releases/juno " drop down list "general purpose tools" select "eclipse plug-in development environment" after doing this...eclipse started showing option of ant build in run as

ios - Xcode Display Image if there is no image on Imageview -

i need make this iboutlet uiimageview *imageview; iboutlet uiimageview *imageview2; if(imageview have no image){ set image @"x"; }else if(imageview2 have no image){ set image @"x"; } and save , load code nsuserdefaults try this uiimageview *myimageview; if(myimageview.image){ myimageview.image = [uiimage imagenamed:@"myimage1"]; //image exists } else { myimageview.image = [uiimage imagenamed:@"myotherimage"]; //image doesnt exists } //by time image or other set save image [[nsuserdefaults standarddefaults]setobject:myimageview.image forkey:@"myimage"]; i dont know if nsuserdefault can set image object coz havnt tried u might exception, best if can save image's name right in if statement using [[nsuserdefaults standarddefaults] setobject:@"imagenameoftheimage" forkey:@"myimagename]"

Gradle leaves java as a process even after closing android studio -

Image
on mac system whenever close android studio leaves java process , java process keep running , keep hogging ram memory.having mac 4gb sometime painful if see java process taking upto 1gb of ram is there option in android studio quit process related should closed or command can run cleanup? from the documentation : daemon processes automatically terminate after 3 hours of inactivity. if wish stop daemon process before this, can either kill process via operating system or run gradle --stop command. --stop switch causes gradle request running daemon processes, of same gradle version used run command, terminate themselves.

c - Why this code not giving desired output? -

#include <stdio.h> //compiler version gcc 6.3.0 int main() { float da,hra,s,gs; scanf("%f",&s); da=40/100*s; hra=20/100*s; gs=s+da+hra; printf("%f",gs); return 0; } for example if entered 25000 s output must 40000 showing 25000.000000. try fix below. note 40.0 , 20.0 instead of 40 , 20 . issue doing integer division. 40 / 100 == 0 , da 0 . using 40.0 / 100 instead gives floating point division , value 0.4 , want make calculations correct. (the same holds computation of hra .) #include <stdio.h> int main() { float da, hra, s, gs; scanf("%f", &s); da = 40.0 / 100 * s; hra = 20.0 / 100 * s; gs = s + da + hra; printf("%f", gs); return 0; }

python - For loop in matplotlib only plots first iteration -

i want read several columns csv file , plot them on single window. have this: fig1=pl.figure(num=1, figsize=(8, 4), dpi=80, facecolor='w',edgecolor='k') a=np.random.rand(50,9) ax = pl.gca() in range(0,6,2): ax.errorbar(a[:,i], a[:,i+1], yerr= a[:,i+2]) ax.set_xscale('log') ax.set_xlim(1e19, 1e22) pl.show() i no error message, output plot first iteration, when there should 3 in sample file. have put different parts of code in loop @ best first plot window , 2 empty windows not looking either. why isn't loop cycling through values? or assuming cycling through why plotting first one? thanks! update: tcaswell, x range restrictive. classical case of not looking @ data close enough. embarrassing.

c++ - What's the point of logical operators vs. bitwise operators -

given statement logical operation ((a > 5) && (b > 4)) and statement bitwise-operation ((a > 5) & (b > 4)) above 2 statements not equivalent. because (a > 5) element of {0,1} so, why need logical operators & bitwise-operation ? edit : of feedback. regarding short circuit behaviour of logical operators, not want behaviour - writing code gpu branches degrade performance: short circuit results in 2 branches instead of 1 in code. for numerical comparisons in c, in case short circuit not needed, seems logical , bitwise have identical behaviour. in case, bitwise ops faster logical. i apologize not putting these details in original posting. i think no, take example (0b - means binary): a = 0b00000010 b = 0b00000100 now, neither a nor b 0. a & b == 0 (due way bitwise , defined). however a && b != 0 (because logical , result 0 if @ least 1 operand 0 - not case a , b above). also there short circ...

R: Number of obs between min and max -

i need extract number of observations between min , max. know can subset data, creating new df calculate length interested in less involved process. example, have , number of observations min max, ddd <- mydf[,list(minvar1 = min(var1, na.rm=true), maxvar1 = max(var1, na.rm=true)), by="group"] is there direct approach without intermediate df? thanks. edit: guess bit more complicated stated. group = 1, minimum value 2 need minimum indexed lower max value index/position. so, range 3 7 length of 3. idx variable scores measured index/position of var1. so, max position of var1 must first identified, insure min position extracted idx less of max position. group var1 idx 1 3 4 1 5 5 1 7 6 1 3 7 1 2 8 2 5 12 2 6 13 2 9 14 2 11 15 2 5 16 group min max length 1 3 7 3 2 5 11 4 by using data.table , expected output. convert 'data.frame' 'data.table' ( setdt(df1) ). grouped 'group', order 'idx', position of maximum...

node.js - Divide Node App in different files -

i'm developing first node.js app socket.io , fine app getting bigger , i'd divide app-code different files better maintenance. for example i'm defining mongoose schemas , routings in main file. underneath functions socket.io connection. want have file schemas, file routing , 1 functions. of course, i'm aware of possibility write own module or load file require. not make sense me, because can't work vars app, io or db without making them global. , if pass them function in module, can't change them. missing? i'd see example how done in practice without using global vars.. it sounds have highly coupled application; it's difficult split out code modules because pieces of application should not depend on each other do. looking the principles of oo design may out here. for example, if split dataabse logic out of main application, should able so, database logic should not depend on app or io --it should able work on own, , require other p...