Posts

Showing posts from June, 2011

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

objective c - Can React-Native run a background task in IOS -

desired spec: react native app queries healthkit data , posts db building react-native app query user's healthkit data intermittently. aware can't interact healthkit while phone unlocked. this thread how can run background tasks in react native? tells me such functionality isn't possible rn. however, in context of starting background-timer. i'd app perform following steps query healthkit data # of steps post data db questions is possible react native without writing kind of native bridge? (swift seems have capability somehow) if not possible without writing bridge, accessing native pedometer?

Spring Boot running java and web content on different ports in a single application -

is possible run static content , java related code on different ports? i have spring boot project java code resides on src/main/java , web content on src/main/resources/static . is there possibility run static content on port 8080 , java (rest controller) on 8081 ? i don't want create separate project ui.

python - Pandas groupby sum using two DataFrames -

i have 2 large pandas dataframes , use them guide each other in fast sum operation. 2 frames this: frame1: samplename gene1 gene2 gene3 sample1 1 2 3 sample2 4 5 6 sample3 7 8 9 (in reality, frame1 1,000 rows x ~300,000 columns) frame2: featurename geneid feature1 gene1 feature1 gene3 feature2 gene1 feature2 gene2 feature2 gene3 (in reality, frame2 ~350,000 rows x 2 columns, ~17,000 unique features) i sum columns of frame1 frame2's groups of genes. example, output of 2 above frames be: samplename feature1 feature2 sample1 4 6 sample2 10 15 sample3 16 24 (in reality, output ~1,000 rows x 17,000 columns) is there way minimal memory usage? if want decrease memory usage, think best option iterate on first dataframe since has 1k rows. dfs = [] frame1 = frame1.set_index('samplename') idx, row in frame1...

android - Bitmap to Base64 String -

i trying following code encode bitmap base64 string, wrong encoding. by way, filepath image file path. public string encode(string filepath) { bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap bitmap = bitmapfactory.decodefile(filepath, options); bitmap.compress(bitmap.compressformat.png, 100, stream); byte[] byte_arr = stream.tobytearray(); return base64.encodetostring(byte_arr, base64.default); } how know if wrong encoding? use website: http://codebeautify.org/base64-to-image-converter try code proper encoding me. hope may you. public string getstringimage(bitmap bmp) { bytearrayoutputstream baos = new bytearrayoutputstream(); bmp.compress(bitmap.compressformat.jpeg, 100, baos); byte[] imagebytes = baos.tobytearray(); string encodedimage = base64.encodetostring(imagebytes, base64.default); return encodedimage; }

DB2 SQL : Combine two queries and select max of one aggregate column -

i have 2 queries (example version)- query a: select col1 col1, col2 col2, sum(col3) col3 table1 join table11 .. group col1, col2; query b: select col1 col1, col2 col2, count(col3) col3 table2 group col1, col2; i want join both of them , have output below. tried this select a.col1, a.col2, greatest(a.col3, b.col3) (query a) union (query b) b but getting error sql0104n unexpected token "end-of-statement" found following "col2) b". expected tokens may include: "join <joined_table>". sqlstate=42601 both queries individually running fine, when combined using union above, giving error. is there better way achieve this? it looks need join , not union : select a.col1, a.col2, greatest(a.col3, b.col3) (query a) join (query b) b on a.col1 = b.col1 , a.col2 = b.col2 depending on needs, may need left join , right join or full outer join instead of inner join .

c# - How to remove trailing empty lines in FileHelper -

thought easy, cannot find methods in filehelpengine remove trailing empty lines in text or csv file, causes readfile fail. if number of empty lines known, example 2, can use in record class: [ignorelast(2)] public class ... another option ignore empty lines ignored in place appear [ignoreemptylines()] public class ... the last thing can try ignore lines code using inotifyread interface like: [fixedlengthrecord(fixedmode.allowvariablelength)] [ignoreemptylines] public class ordersfixed :inotifyread { [fieldfixedlength(7)] public int orderid; [fieldfixedlength(8)] public string customerid; [fieldfixedlength(8)] public datetime orderdate; [fieldfixedlength(11)] public decimal freight; public void beforeread(beforereadeventargs e) { if (e.recordline.startswith(" ") || e.recordline.startswith("-")) e.skipthisrecord = true; } public void afterread(afterreadeventargs e) { // want ...

bootstrap-select, center title -

i'm using https://github.com/silviomoreto/bootstrap-select , trying center select list title, not managed far. i've tried center title using title : <select class="selectpicker" style="text-align: center;" title="select one"> and data-title: <select class="selectpicker" style="text-align: center;" data-title="select one"> and using data-hidden option: <option data-hidden="true" class="text-center" value="">select one</option> however, title aligned on left. tips might work? maybe text-align-last: center; would help

asp.net mvc - Get property name in Tag Helper -

asp.net core introduced custom tag helpers can used in views this: <country-select value="countrycode" /> however, don't understand how can model property name in classes: public class countryselecttaghelper : taghelper { [htmlattributename("value")] public string value { get; set; } public override void process(taghelpercontext context, taghelperoutput output) { ... // should return property name, "countrycode" in above example var propertyname = ???(); base.process(context, output); } } in previous version able using modelmetadata : var metadata = modelmetadata.fromlambdaexpression(expression, html.viewdata); var property = metadata.propertyname; // return "countrycode" how can same in new asp.net tag helpers? in order property name, should use modelexpression in class instead: public class countryselecttaghelper : taghelper { public modelexpression {...

xml - How to improve resolution of image on Android -

Image
i have uploaded image on 3000 3000 pixel onto android studios. when try add image application, image not sharp. here xml code <imageview android:layout_width="match_parent" android:layout_height="200dip" android:scaletype="fitcenter" android:contentdescription="" android:layout_margintop="20dip" android:layout_marginbottom="28dip" android:src="@mipmap/login_logo" /> i believe image should big enough image view. can advise me on how increase resolution of image? updated when uploaded image, 4 different versions of image created automatically in system the problem creating icon set, wich not have 3000 3000 pixel. check it. the application using more appropiate size (hdpi, xhdpi, etc). resizing manually. that's why icon not sharp in screen. when create manual image asset, real size depending on screen size. assistan takes original image , resizze it. ldp...

php - Mybb noCaptcha reCaptcha not working on server but working on localhost -

recently installed mybb on web server , stop spam, configured google nocaptcha recaptcha. the problem here was, when tried register on forum, says an error occurred human verification. please try again. anyway i, tried 2 three-time register can't register same problem comes again , again. i installed same mybb script on local server using xampp , there captcha working fine on it. checked privet key , public key well, seems good. i ran vanilla forum on same server , worked nocaptcha recaptcha. on vanilla forum worked on mybb not. please me out problem. my site address causing problem : http://forum.howi.in there issues php version or php modules, please check php modules (ttf) , install modules install on localhost.

javascript - Redux-Saga not able to correctly read response from fetch api -

hi how read data coming fetch call: export function* fetchmessages(channel) { yield put(requestmessages()) const channel_name = channel.payload try { const response = yield call(fetch,'/api/messages/'+channel_name) const res = response.json() console.log(res) yield put(receivemessages(res,channel)) } catch (error){ yield put(rejectmessages(error)) } } when console.log(res) get: promise {[[promisestatus]]: "pending", [[promisevalue]]: undefined} __proto__ : promise [[promisestatus]] : "resolved" [[promisevalue]] : array[7] how "info" (side array[7] promise? new this. thanks response.json() async , returns promise change const res = response.json() to const res = yield response.json() webpackbin example

Python list comprehension to populate 2D array from excel data only gives 1 column -

python 3.5 on windows. have 9x2 range in excel want read array in python. excel range data: 2 2 0.833333333 1 2.166666667 2 0 0 1 0 1 1 1.5 1.166666667 0.833 1.333 1.667 1.333 python code: import openpyxl import numpy # physicians physicians = ['dra', 'drb'] # activities activities = ['admin1', 'frac2', 'spec3', 'fleb4', 'latr5', 'endo6', 'surg7', 'surg8', 'noth9', 'annl10'] wb = openpyxl.load_workbook('m_a_j2pasted.xlsx') type = wb sheet = wb.get_sheet_by_name('sheet_mean_a_j') m = [[sheet.cell(row=rows, column=cols).value rows in range(1, len(activities))] cols in range(1, len(physicians))] m = numpy.array(m) numpy.transpose(m) print(m) print(m) out: [[ 2. ] [ 0.83333333] [ 2.16666667] [ 0. ] [ 0.5 ] [ 0.5 ] [ 1.5 ] [ 0.83333333] [ 1.66...

android - Error:java.lang.OutOfMemoryError: GC overhead limit exceeded error on Telegram -

i'm newbie android , trying run telegram source code provided on github android faced terrible errors , after days of googling found nothing @ all! i followed instructions it's not working. error say's error:java.lang.outofmemoryerror: gc overhead limit exceeded after increasing max heap size it's throwing same error more memory. buildvars.java: public class buildvars { public static boolean debug_version = false; public static int build_version = 821; public static string build_version_string = "3.10"; public static string app_hash = "94706fdc9f5d86e2c3749bd8d0a2559e"; //obtain own app_hash @ https://core.telegram.org/api/obtaining_api_id public static string hockey_app_hash = "f7a81fd2b9cd40d3a8687311defcfe88"; public static string hockey_app_hash_debug = "f7a81fd2b9cd40d3a8687311defcfe88"; public static string gcm_sender_id = "760348033672"; public static string send_logs_...

java - Cache replication -

i'm using ehcache 2.10.2. synchronous replication (replicateasynchronously=false) between 2 servers (s1 , s2). i have next situation: first http request going s1 s1 can't find object in cache , loads db state "a" , puts cache s1 changes object's state "b", saves db , puts cache s1 sends success response next request going s2 s2 finds obect in cache state "a" s2 sends error response, because object must have state "b" on second request. when server puts object cache, thread blocked on put operation send serialized object server, , don't wait while server deserialize , put element cache. @ point 6 can state "a" or "b", if lucky. is possible configure ehcache block operations until changes replicated on nodes? may need replace ehcache other cache implementation, or change everything? what experience weakness of cache replication. scenario seems require strong consistency. note in a...

visual studio - Form1.button2.text.. is not accessible in this context because its private -

Image
what after clicking button14 login change button in forms text "sample" change class button2 private public still error public sub button14_click(sender object, e eventargs) handles button14.click if textbox2.text = "sample" , textbox3.text = "****" form1.show() me.hide() button2.text = ("sample") form1.button2.text = ("sample") else msgbox("sorry, username or password not found", msgboxstyle.okonly, "invalid") textbox2.text = " " textbox3.text = " " end if end sub this form 1 public sub button2_click(sender object, e eventargs) handles button2.click login.show() me.hide() end sub my guess winform project. you can change access modifier of button in form designer. select button press f4 property grid, find modifiers , change whatever.

html - Pop up window modal appears, but it does not work properly. It is not active -

Image
i trying create pop window modal. modal appears not work properly. here screenshot: here html code of following modal: <span class="glyphicon glyphicon-pencil" data-toggle="modal" data-target="#editcard-modal"></span> <div class="modal fade" id="editcard-modal" tabindex="-1" role="dialog" aria-hidden="false" style="display: none;"> <div class="modal-dialog"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">modal header</h4> </div> <div class="modal-body"> description here </div> <div class="modal-footer" id="outercard"> <div class="innercard"><button type...

Check if push enabled or location enabled ios sdk -

i'm using following code detect these 2 (push notifications , location services) [postvars setobject:([cllocationmanager locationservicesenabled])?@"true":@"false" forkey:@"locationservicesenabled"]; bool pushenabled = [[uiapplication sharedapplication] isregisteredforremotenotifications]; [postvars setobject:(pushenabled)?@"true":@"false" forkey:@"pushservicesenabled"]; but issue i'm getting true both if tap don't allow when prompted in app. in settings app checked location set never , notifications subheading shows off. what's wrong code ? can guide me in this. just checking [cllocationmanager locationservicesenabled] not enough. if([cllocationmanager locationservicesenabled] && [cllocationmanager authorizationstatus] != kclauthorizationstatusdenied) { [postvars setobject:@"true" forkey:@"locationservicesenabled"]; } for notifications ch...

xamarin - How to await iOS openURL overridden method? -

i have share feature in mail application can open application clicking share button. able open app when user click share mail app, issue openurl method. below openurl method: public override bool openurl(uiapplication application, nsurl url, string sourceapplication, nsobject annotation) { upload(url); return true; } async public task<bool> upload(nsurl shareduri) { //upload } problem above code since upload function not awaited, before upload function finishes app opened. how can await task in openurl ? you have many options here, 1 of returning upload's result. remember await time consuming task inside of upload. public override bool openurl(uiapplication application, nsurl url, string sourceapplication, nsobject annotation) { return this.upload(url).result; } async public task<bool> upload(nsurl shareduri) { await someuploadtask(); return true; } i agree sunil should show indication of action user, here's...

Why is there only 1 type parameter in scala list flatmap parameter signature -

why flatmap list takes b type parameter def flatmap[b](f: (a) => u[b]): u[b] instead of def flatmap[a, b](f: (a) => u[b]): u[b] because a deduced type parameter defined on list : sealed abstract class list[+a] and since flatmap defined each element of type a in list , there's no need explicitly declare it.

java - What does the difference of the JNI method CallObjectMethod,CallObjectMethodV and CallObjectMethodA? -

there 3 kinds of methods in jni callobjectmethod callobjectmethodv callobjectmethoda difference of methods? jobject (*callobjectmethod)(jnienv*, jobject, jmethodid, ...); jobject (*callobjectmethodv)(jnienv*, jobject, jmethodid, va_list); jobject (*callobjectmethoda)(jnienv*, jobject, jmethodid, jvalue*); the difference way how java arguments passed. docs explain well: call<type>method routines programmers place arguments passed method following methodid argument. callmethod routine accepts these arguments , passes them java method programmer wishes invoke. call<type>methoda routines programmers place arguments method in args array of jvalues follows methodid argument. callmethoda routine accepts arguments in array, and, in turn, passes them java method programmer wishes invoke. call<type>methodv routines programmers place arguments method in args argument of type va_list follows methodid...

c# - Operator '==' cannot be applied to operands 'method group' or 'string' -

Image
i have following code: <span>@model.licenseholder.legalperson.contactdetails.select(x => x.name == "fish")</span> when run this, error: operator '==' cannot applied operands 'method group' or 'string' i don't understand why this. here can see picture of contactdetails: ' i want access contactdatatype property , compare name-property inside contactdatatype, don't know how it. basically, want this: @model.licenseholder.legalperson.contactdetails.contactdatatype.select(x => x.name == "primaryphone") you need apply where not select function: <span>@model.licenseholder.legalperson.contactdetails.where(x => x.name == "fish").firstordefault()</span> or better: <span>@model.licenseholder.legalperson.contactdetails.firstordefault(x => x.name == "fish")</span>

How to generate oauth token using QuickBooks API and postman? -

can me on generating oauth token using quickbooks api , postman? not able create 1 using api. , can u me sample account data account quickbooks api ? you can refer following blog shows how generate oauth1 tokens using oauthplayground tool , use tokens in postman make api calls. https://developer.intuit.com/hub/blog/2016/04/25/quick-start-to-quickbooks-online-rest-api-with-oauth1-0 you can try entire qbo postman collection link below. https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0012_postman?isexpand=false#/1500 hope useful. thanks manas

c# - Controlling a buttons enabled state using 3 combobox selecteditem values -

i developing wpf application. have 3 comboboxes. each combobox has list source , there 3 items : 1,2,3 in each combobox. have button too. want disable button if user has selected same value in atleast 2 of comboboxes. ie. if user selects 1 in first cb , 1 in second cb too, disable button. have tried achieve using below code within of button. doesn’t work anyway. <button> .... <style> <style.triggers> <multidatatrigger> <multidatatrigger.conditions> <condition binding="{binding elementname=cb1, path=selecteditem}" value="1" /> <condition binding="{binding elementname=cb2, path=selecteditem}" value="1" /> <condition binding="{binding elementname=cb3, path=selecteditem}" value="1" /> </multidatatrigger.conditions> <setter property="isenabled" value="false...

javascript - Uncaught illegal access while adding element in array -

here javascript function: note: resultarray defined in calling function var resultarray = []; onaddelement : function (win,id,resultarray) { var controller = this; if(!win.flag){ ext.messagebox.show({ title: 'yes or no', icon: ext.messagebox.question, msg: 'do want continue?', buttontext: {yes:'yes', no:'no', cancel:'cancel', fn: function (me) { if(me === 'yes'){ ver = win.curver; resultarray.push({ id: id, ver: ver }); controller.anotherfunc(win,id); }else if(me === 'no'){ ver = win.ver; resultarray.push({ id: id, ver: ver }); controller.anotherfunc(win,id); ...

java - How to show the hibernate binding validation exception in part of JSP page i.e in one particular div -

while submitting form checking binding errors, since name , short name must non-empty defined in model. while doing giving errors. not sure why.?? can me this.? company-definition.jsp <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <%@ taglib prefix="tg" tagdir="/web-inf/tags"%> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> <jsp:usebean id="pagedlistholder" scope="request" type="org.springframework.beans.support.pagedlistholder" /> <main class="container padcontnr"> <div class="row"> <div class...

This loop is infinite but it should not be - C -

look @ this: int find_grad(int * table, int * value) { int = 0; while (find_max_value(table) >= value) { table[(find_max_position(table))] = 0; i++; } return i; } this pretty simple function: uses function (that works sure, tested it) called "find_max_position" iterates through vector of integers find position of max value. if vector {1, 3, 19}, find_max_position returns integer, in case 1. i need find_grad find "grade" of value entered. example, if call find_grad(table, 3) on vector {0, 1, 5, 4, 3}, function should return me 2, because 3 third bigger value (it starts 0). when call function loop becomes infinite. thought because when "table[(find_max_position(table))] = 0;" i'm acting on copy of vector , not vector itself, , when loop restarts bigger value it's there. maybe explained situation bit bad think it's easy understand reading code. can help? edit: forgot > find_m...

html - Move parent div and keep child at same position -

i want move parent div via transition in x-direction, child element supposed stay @ position. parent div rotated , affects child div position. how can achieve child div stand still? js fiddle html <div><span>hello</span> scss div { width: 200px; height: 200px; transform: rotate(13deg) ; overflow: hidden; transition: 1s; span { display: block; transform: rotate(-13deg); transition: 1s; } &.move { transform: translate(200px,0) rotate(13deg); span { transform: translate(-200px,0) rotate(-13deg) ; } } } &.move { transform: translate(200px) rotate(13deg) ; span { transform: translate(0) rotate(-13deg) ; } } }

python - Combine dictionaries based on key value -

how combine rows of dictionaries having same keys. instance if have my_dict_list = [{'prakash': ['confident']}, {'gagan': ['good', 'luck']}, {'jitu': ['gold']}, {'jitu': ['wins']}, {'atanu': ['good', 'glory']}, {'atanu': ['top', 'winner','good']}] my objective my_new_dict_list = [{'prakash': ['confident']}, {'gagan': ['good', 'luck']}, {'jitu': ['gold','wins']}, {'atanu': ['good', 'glory','top', 'winner','good']}] how do in python? edit: dictionaries in final list must contain repeated values if present in starting list. a minimalist approach using defaultdict : from collections import defaultdict my_dict_list = [{'prakash': ['confident']}, {'gagan': ['good', 'luck']}, {'...

Azure domain configuration -

i have app awarded gorunning.pt domain. happens when call gorunning.pt domain without www works, when add www http://www.gorunning.pt/ receive page 404 application not found. i've set dns cname application of ip , tried url gorunning.azurewebsites.net defined azure , created type registration. this expected. dns configuration correct. azure web app's front-end doesn't recognize www sub-domain not mapped in portal. you have map www.gorunning.pt web app gorunning.azurewebsites.net in azure portal. :)

angular - Testing Angular2 component @Input and @Output -

how can structure tests angular2 simple form component: import { component, eventemitter, input, output } '@angular/core'; @component({ selector: 'user-form', template: ` <input [(ngmodel)]="user.name"> <button (click)="remove.emit(user)">remove</button> ` }) export class userformcomponent { @input() user: any; @output() remove: eventemitter<any> = new eventemitter(); } angular2 rc.5 import { component } '@angular/core'; import { formsmodule } '@angular/forms'; import { fakeasync, tick, testbed } '@angular/core/testing'; import { } '@angular/platform-browser/src/dom/debug/by'; import { dispatchevent } '@angular/platform-browser/testing/browser_util'; function findelement(fixture, selector) { return fixture.debugelement.query(by.css(selector)).nativeelement; } import { userformcomponent } './user-form.component'; describe('user form com...

php - How to use order by in date using mysql query -

i using mysql database.but when sort date not sort. select * `client` order `nextdate` asc this query want data sort date in ascending order client table , nextdate field type varchar. please how can sort date in ascending order.and want date formate 24/12/2016(d/m/y). when use query sort first day not month this 01/08/2016 07/10/2016 21/08/2016 but want sort this 01/08/2016 07/08/2016 21/10/2016 25/12/2016 so please me how can do.in advance thax, this long comment. presumably, not storing date date . instead storing string. should use built-in mysql data types -- there for. if have to store date string, use yyyy-mm-dd format. sorts correctly. you can fix str_to_date() : order str_to_date(`nextdate`, '%d/%m/%y') asc

python - pyhs2 set queue in query -

i using pyhs2 query hive through python cannot set queue inside query. i want set queue adhoc cursor.execute("set mapred.job.queue.name=adhoc;") cursor.execute("select * test") pyhs2.error.pyhs2exception: 'error while processing statement: failed: execution error, return code 1 org.apache.hadoop.hive.ql.exec.mr.mapredtask' and when try put queue inside query: cursor.execute("set mapred.job.queue.name=adhoc; select * test") the second part of query doesn't executed apparently not possible run multiple statements pyhs2 therefore unable set mapred queue name. pyhs2 no longer maintained , readme advises use pyhive supports these kind of operations.

OCaml - Implement nested functions -

i want implement nested functions recursive. how that? getting error in following code "an operator expected" let powerset_cf f1 = if (let rec f lst = match lst [] -> true | h::t -> if (f1 h) (f t) else false ) true else false;; here, lst = list (e.g [1;2;3]) f1 characteristic function returns true if element in set defined characteristic function. (e.g. let f1 x = (x mod 3 == 0 && x<=15);; ) powerset_cf function returns true if lst member of power set of characteristic function. please fixing this. in advance. let powerset_cf f1 lst = let rec f lst = match lst | [] -> true | h::t -> if f1 h f t else false in if f lst true else false ;; of course can simplify code, that's not question asked.

javascript - HTML printing limit 1 page only -

i printing html table, varies in length. when printing table, may print 1 page 10 pages. there way limit printing 1 page using programming code? yes there option in browser print dialog set printing 1 page (this last option opt) printing html using window.print() method you try setting print css this: @media print { html, body { height:100%; margin: 0 !important; padding: 0 !important; overflow: hidden; } } the basic idea have page 100% height , hide overflow. should allow show content of height of 100% of page = 1 page. edit: based on comment show example 5 different tables on separate tables this: @media print { table { /* or specify table class */ max-height: 100%; overflow: hidden; page-break-after: always; } } the page-break-after tell browser make page break after each table. in case need discard css styles set above html , body . each table limited 100% height of page. it's hard include example in these...