Posts

Python get property value in dict for large dict -

i have large dictionary, this: d['property1']['property2'][0]['property3']['property4']['property5']['property6'] i need property6 . what's simplest way me value? i thinking work: d.lavel6[0]['property6'] unfortunately, there no generic way value of key nested dict based on levels (due obvious reasons). but, may write function specific scenario in order simplify it. example: def get_value_from_dict(my_dict, level, key): return my_dict['property1']['property2'][level]['property3']['property4']['property5'][key]

html - How to center two buttons next to each other but center of the screen? -

Image
this such basic question i'm trying in ionic. i've been trying margin: 0 auto; text-align: center; position: relative; so many things it's not working, help? update: i've tried 1 of solutions , css, still doesn't work, center, way @ top .square{ width: 25vw; height: 8vw; } .container { display: flex; justify-content: center; align-items: center; height: 100%; } html: <div class="container" <div class="button-wrapper"> <button class="button button-outline square button-calm"> male </button> <button class="button button-outline square button-royal"> female </button> </div> </div> you can use flexbox achieve this. firstly wrap buttons within container: <div class="container"> <div class="button-wrapper"> <button class="male"...

html - Why are only some of my links selectable and react when hovered over? -

i'm working on tumblr theme , have run across problem links. links in navigation bar (.navstuff) respond when hovered on , lead link want. in posts, tags, dates, heart/reblog buttons, , note count should respond when hovered over, none of them except post on bottom. why happening , how can fix this? can see on jsfiddle here . .tags { text-align: left; margin: 0; padding: 0; list-style-type: none; } { color: #808080; /*link color remove link underline */ text-decoration:none; } a:hover { color: #f5cfe0; /*hover on link */ } <div class="post"> {block:title} <h3> <a href="{permalink}">{title}</a> </h3> {/block:title} {body} <ul class="like-reblog"> <li>{likebutton}</li> <li>{reblogbutton}</li> <li>{block:notecount}...

ios - Pairs of cells in columns in a custom UICollectionView layout -

i'm trying make collection view. | imageview | |label| |value| |label| |value| so far have been able display 2 sections (the first being image view, second being label), i'm lost @ how add second column second section. i've been looking around how i've seen how make same type of cell displayed in columns. should these labels , values different sections create different custom cells? , should using uicollectionviewflowlayout display 2 different sections side side? you can make image view supplementary view of collection view. here tutorial can show how that.

regex - How to read a paragraph from a file in java -

i have been given file has many paragraphs in it. output expecting read 1 paragraph @ time , perform operations on it. final string paragraph_split_regex = "(?m)(?=^\\s{4})"; string currentline; final bufferedreader bf = new bufferedreader(new filereader("filename")); currentline = bf.readline(); final stringbuilder stringbuilder = new stringbuilder(); while(currentline !=null) { stringbuilder.append(currentline); stringbuilder.append(system.lineseparator()); currentline = bf.readline(); } string[] paragraph= new string[stringbuilder.length()]; if(stringbuilder!=null) { final string value = stringbuilder.tostring(); paragraph = value.split(paragraph_split_regex); } (final string s : paragraph) { system.out.println(s); } file (every...

cordova - Phonegap push plugin and GCM. Is it that complicated? -

i've been trying phonegap / cordova app (for android) work gcm no luck. i've followed documentation here: https://github.com/phonegap/phonegap-plugin-push setting sample phonegap application , sending notification using phonegap cli built-in push function quite easy , works expected. the problem starts when i'm trying work gcm account. started setting sender_id gcp project number (verified correct id...) i executed "phonegap serve" cli , accessed phonegap android developer app in order receive new device registration id , got new registration id (after clearing app data). the problem think device doesn't registered gcm because if enter "test123xxx" sender id, still new device registration id suspect setting sender_id alone won't trick , question how phonegap app register device gcm? any appreciated! thank you. edit - found solution @jcesarmobile apparently when using "phonegap serve" push plugin use phonegap intern...

nativescript - Angular 2 do not refresh view after array push in ngOnInit promise -

i created nativescript app angular 2, have array of objects expect see in frontend of application. behaviour if push object array directly inside ngoninit() works, if create promise in ngoninit() doesn't work. here code: export class dashboardcomponent { stories: story[] = []; pusharray() { let story:story = new story(1,1,"asd", "pushed"); this.stories.push(story); } ngoninit() { this.pusharray(); //this shown var promise = new promise((resolve)=>{ resolve(42); console.log("promise hit"); }); promise.then(x=> { this.pusharray(); //this not shown }); } } the relative html is: <label *ngfor="let story of stories" [text]='story.message'></label> when app starts see 1 push, created button trigger "console.log(json.stringify(this.stories));" , @ moment, when tap button, ...