Posts

python 2.7 - Ask for user input in a while loop -

this example supposed 5 words, print them in reverse order. this tried: n = 5 while n > 0: print "tell me word", n word(n) = raw_input() n = n - 1 print r = 1 while r < 6: print word(r) r = r + 1 what correct way assign this? you can using list. words = [] python won't let assign using unassigned index, need call append method: n = 5 words = [] while n > 0: words.append(raw_input('tell me word: ')) n -= 1 notice can use first argument raw_input print prompt, there's no need separately. can use quicker -= decrement , reassign n . a while loop sort of unusual choice here, although works. you'd better off for loop using python's built-in range function. for n in range(5): words.append(raw_input('tell me word: ')) once you're doing can shorten list comprehension , assign list @ once: words = [raw_input('tell me word: ') n in range(5)] once you've got...

ssl - Java - HTTPS GET call fails from EC2 instance with handshake_failure, works locally -

i'm running out of ideas, why i'm asking here. have small class rest call on https. i'm doing kind of scraping, , avoid installing ssl certificates if possible. the code works locally (both eclipse , standalone tomcat), fails javax.net.ssl.sslhandshakeexception: received fatal alert: handshake_failure every time when running aws ec2 instance. code is: // apiurl looks https://hsreplay.net/api/v1/games/jdubsjsecbl5rct7dgmxrn private string restgetcall(string apiurl) throws exception { system.setproperty("javax.net.debug", "all"); sslcontextbuilder builder = new sslcontextbuilder(); builder.loadtrustmaterial(null, new trustselfsignedstrategy()); sslconnectionsocketfactory sslsf = new sslconnectionsocketfactory(builder.build(), sslconnectionsocketfactory.allow_all_hostname_verifier) { @override protected void preparesocket(sslsocket socket) throws ioexception { try { log.debug...

ios - How can I make the particles in my SKEmitterNode opaque? -

Image
i've experimented lot settings in particle emitter editor, none of them seem allow me make particles opaque. i've tried editing in actual code: if let explosion = skemitternode(filenamed: "toothexplosion") { explosion.particlecolor = skcolor.whitecolor() explosion.particlecolorblendfactor = 1.0; explosion.particlecolorsequence = nil; explosion.position = contactpoint addchild(explosion) } did change particle texture? try put (in sks file, toothexplosion.sks ) solid circle, spark not opaque:

How to display best seller products on front-page using Shopify -

Image
i have dev theme shopify store. it's child theme. how display best selling products on front page. tried no luck maybe because sample outdated. <div class="row"> {% product in collections["all"].products | limit:12 | sort_by: 'best-seller' %} {% include 'product-grid-item' "all" %} {% endfor %} </div> is there way can create this? in advance. an easy way of doing it, sort on shopify won't work value best-seller , create new collection called (for example) best sellers have products (you set sole condition product price greater $0 if applies on store). then, set collection sorting by best selling on admin dashboard. finally, use liquid in similar way per following: <div class="row"> {% product in collections.best-sellers.products | limit:12 %} {% include 'product-grid-item' "all" %} {% endfor %} </div>

php - Laravel Language Translation Not loading at first route -

i have been working in localization project ,in app language translation files not loading in pages.i don't know wrong loadpath function. in app user can change there language on profile section , changes works on same session.but when user logout , login app @ first user not seen his/her preferred language. here code protected function loadpath($path, $locale, $group) { if ( app::runninginconsole() ) { return parent::loadpath( $path, $locale, $group ); } $domain = get_subdomain(); $dir = "lang/{$locale}/{$domain}"; $key = $dir.'/'.$group.'.php'; if(\session::has($key)){ $results = \session::get($key); $d = json_encode($results); view::share('lang',$d); return $results; }else{ $this->s3 = app::make('aws')->factory(tenent_aws_config())->get('s3'); $domain = get_subdomain(); $bucket = "localbulkload"; ...

javascript - Can't get Eslint work with Webpack dev server -

i can't webpack-dev-server working eslint. here wepback config: const path = require('path'); const paths = { app: path.join(__dirname, 'app/js/app.js'), build: path.join(__dirname, 'build') }; module.exports = { entry: { app: paths.app }, output: { path: paths.build, filename: 'bundle.js' }, devserver: { contentbase: 'dist' }, module: { loaders: [ { test: /\.(jsx|js)?$/, exclude: /node_modules/, loader: ['babel'] }, { test: /\.js$/, loader: "eslint-loader", exclude: /node_modules/ }, { test: /\.json$/, loader: "json-loader", exclude: /node_modules/ }, { test: /\.css$/, loader: "style-loader!css-loader" }, { test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/, loader: "url-loader?limit=10...

java - how can i overwrite a file if it exists in directory -

i'm saving image in directory same name (for purpose) when file exists there won't overwritten , how know ? because when i'm saving file existing file not changing when use different name file works. want replace existing file new one. far i'm trying : content.setdrawingcacheenabled(true); bitmap bitmap = content.getdrawingcache(); // bitmap file saving file file = new file(context.getapplicationcontext().getfilesdir() + "/img.jpg"); //here's path i'm saving file if (file.exists()){ file.delete(); // here i'm checking if file exists , if yes i'm deleting not working } string path = file.getpath(); try { file.createnewfile(); fileoutputstream ostream = new fileoutputstream(file); bitmap.compress(bitmap.compressformat.jpeg, 60, ostream); ...