Posts

Showing posts from February, 2014

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

External javascript not working? -

i started learning javascript 30 minutes ago. i'm doing online course , gave me code example. person in video did exact same thing, works me when inline not external. .js name right , they're in same folder. the html: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>javascript basics</title> <script src=“cripts.js”></script> </head> <body> <div class="container"> <h1>where place javascript code.</h1> </div> </body> </html> and js: alert("you"); nothing appears me. i've tried make work, including different browsers. computer or did make simple mistake? it looks quotes invalid :') beginner move! simple fix. note “ should ", happens when copying , pasting code! <script src="cripts.js"></script> also make sure path , file name correct?! cripts.js so...

Save log information in mysql stored procedures -

i writing stored procedure in mysql , need save log information in text file. has come across this? well, after long hours of searching conclude there internal constraints in mysql direct writing text files. the contour occurs me write log messages , debugging on table in database, , save relevant records in text file. similarly, grateful may have tried help.

javascript - scrollbar for the dropdown list -

i want show scroll bar drop down list user can select one item available list. drop down menu should show 5 items , scroll bar drag , see remaining items in list when user clicks on drop down list. show drop down list using struts html tag library. below struts html code show drop down list. <html:select name="myform" property="city" styleid="city" tabindex="1" title="please select city"> <html:options property="city" labelproperty="city"/> </html:select> do need write javascript function achieve scroll bar <html:options> . cannot use jquery application not support jquery libraries. please suggest how can achieve using javascript function. simply assign class option list , add overflow equal auto. added style. <html:select name="myform" property="city" styleid="city" tabindex="1" title="please select city"> ...

mysql - How to Merge 2 Tables Tentatively Using Replace With Some Unique Data -

i'm trying merge 2 tables single table. using example of tables below need merge table b's purchase_date table a's blank purchase_date. table has email associated purchase date , in table email unique. however, in table b there many email addresses , they're not unique. when merge 2 tables need recent or greatest date table b go table a. for performance reasons table has ~33.5k rows , table b has ~550k rows. table email purchase_date ----------- --------------- test@test.ca test2@test.ca test3@test.ca table b email purchase_date ----------- --------------- test@test.ca 2016-08-01 0:00:00 test@test.ca 2016-08-03 0:00:00 test2@test.ca 2016-08-13 0:00:00 test2@test.ca 2016-08-14 0:00:00 test2@test.ca 2016-08-15 0:00:00 test3@test.ca 2016-08-27 0:00:00 you can use update join , subquery max date: update tablea join ( select email, max(purchase_date) purchase_date tableb group email ) b on a.em...

sorting - I have an issue with implementing Merge Sort for Java -

public static void main(string[] args) { int[] test = {5,4,3,5,7,5,1,5,96}; system.out.print("before: "); printlist(test); mergesort(test, 1, test.length); //system.out.print("after: "); //printlist(test); } public static void printlist(int[] test){ (int i= 0; < test.length; i++){ system.out.print(test[i] + " "); } system.out.println(); } public static void merge(int[] a, int p, int q, int r){ int n1 = q - p + 1; int n2 = r - q; int[] l = new int[n1]; int[] r = new int[n2]; for(int = 1; <= n1; i++){ l[i] = a[p+i-1]; } (int j = 1; j <= n2; j++){ r[j] = a[q+j]; } int = 1; int j = 1; (int k=p; <= r; i++){ if (i > n1){ a[k] = r[j]; j++; } else if (j > n2){ a[k] = l[i]; i++; } else if (l[i] <= r[j]){ a[k] = l[i]; i++; ...

node.js - Polymer CLI install hangs at gecko driver -

i trying install polymer-cli hangs here: node_modules/polymer-cli/node_modules/wct-local > node scripts/postinstall.js ---------- selenium-standalone installation starting ---------- --- selenium install: from: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar to: /users/limjiewmeng/.nvm/versions/node/v6.4.0/lib/node_modules/polymer-cli/node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar --- chrome install: from: https://chromedriver.storage.googleapis.com/2.23/chromedriver_mac64.zip to: /users/limjiewmeng/.nvm/versions/node/v6.4.0/lib/node_modules/polymer-cli/node_modules/selenium-standalone/.selenium/chromedriver/2.23-x64-chromedriver --- firefox install: from: https://github.com/mozilla/geckodriver/releases/download/v0.10.0/geckodriver-v0.10.0-macos.tar.gz to: /users/limjiewmeng/.nvm/versions/node/v6.4.0/lib/node_modules/polymer-cli/node_modules/selenium-standalone/.selenium/geckodriver/0.10.0-x64-geckodri...

angular - Should I use mongoose sort or pipes to implement my own? -

sort features not included in angular 2. can use mongoose sort , working in shopping-cart application. should use pipes instead? drawbacks? still new angular 2 , mean stack. thanks. i used both pipes , mongoose queries in application. sort category(ele, sh, vid) while product component sorts searched products alphabetically mongoose @ oninit() . <div [ngclass]="displaycategory"> <ul *ngfor="let category of categories | order by: ['fieldname'];let i=index"> <div class="checkbox"> <input type="checkbox" value={category.selected}} [ngmodel]="category.selected" (change)="oncategory($event,i)"> {{category.fieldname}}{{category.count()}}) </div> </ul> </div>

android - DialogFragmment and AppCompat -

its first question here excited , want looks awesome community. and question: i try use class extends dialogfragment, sadly display dialog forced use appcompat theme otherwise throws error. is there way show dialog without using appcompat theme? i need display actionbar , not displayed when use appcompat, optimal solution? <resources> <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat"> <!-- customize theme here. --> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="coloraccent">@color/coloraccent</item> </style> ^ style using, works fine except no action bar. the error if dont use appcompat: 08-28 20:31:31.905 24099-24099/com.hadas.yotam.friendsapp e/androidruntime: fatal exception: main ...

WSO2 APIM 2.0 Clustering deployment issue when deploy sample API -

after deployed apim 2.0 in 1 server 2 pubstore nodes, 2 key manager nodes, 1 gateway manager , 2 gateway worker nodes login publisher , deploy sample api, encounter such error , failed deploy it: tid: [-1234] [] [2016-08-29 00:25:55,799] error {jaggery.site.blocks.item-design.ajax.add:jag} - org.mozilla.javascript.wrappedexception: wrapped org.wso2.carbon.apimgt.api.apimanagementexception: error in adding api :pizzashackapi (/publisher/modules/api/add.jag#108) @ org.mozilla.javascript.context.throwasscriptruntimeex(context.java:1754) @ org.mozilla.javascript.memberbox.invoke(memberbox.java:148) @ org.mozilla.javascript.functionobject.call(functionobject.java:386) @ org.mozilla.javascript.optimizer.optruntime.call1(optruntime.java:32) @ org.jaggeryjs.rhino.publisher.modules.api.c3._c_anonymous_5(/publisher/modules/api/add.jag:108) @ org.jaggeryjs.rhino.publisher.modules.api.c3.call(/publisher/modules/api/add.jag) @ org.mozilla.javascript.scriptruntime....

What happens if I try to define a pointer which points to a string literal in C? -

this question has answer here: string literals: go? 8 answers for example, char * first = "hello world!"; my questions is, is string literal stored in memory? (if guess pointer first address of inital element of string literal " hello world ") if not, kind of random pointer value stored in first ? yes, string literals stored in memory. c , c++ standards string literals have static storage duration, attempt @ modifying them gives undefined behavior, , multiple string literals same contents may or may not share same storage.

node.js - nodejs module depedendencies with different versions -

i have following confusion regarding module dependencies in nodejs, lets have following dependency structure modulea (dependent on version 1 of module c) moduleb (dependent on version 2 of module c) now under normal circumstances when each module has own sub directory modules (a , b) can identity sub modules versions appropriately, if use webpack generates 1 single file. how versions handled in such scenario? on same note how flatten-packages work when comes different versions? webpack include both versions of module c in bundle. modules , b use versions 1 , 2, respectively.

node.js - Webpack Incomplete Chunk Encoding in Chrome -

i have spent weekend trying figure out why getting error err_incomplete_chunked_encoding when application loads bundled client side js file webpack. have realized chrome browser throws error. why happening , how can fix ? it known chrome problem . according chrome , chromium bug trackers there no universal solution this. problem not related server type , version, right in chrome. setting content-encoding header identity solved problem me.

c++ - Cannot include <vector> -

i using gcc under os x , error fatal error: 'vector' file not found when trying include vector implementation. other includes like #include <stdio.h> #include <stdlib.h> are working. vector file located? vector not part of c. must use c++. try compiling g++ rather gcc

javascript - How to resolve this " Uncaught TypeError: Cannot convert undefined or null to object " -

my function : function collect_que_ids(e) { var val = e.val(); var data_lo = e.attr('data-lo'); new_hash = {}; new_hash[val] = data_lo; if(e.is(':checked')){ if(checked_box_hash.includes(new_hash)){ checked_box_hash; }else{ checked_box_hash.push(new_hash); } } else{ new_hash_key = object.keys(new_hash)[0] new_hash_value = new_hash[new_hash_key] $.each(checked_box_hash, function(key, value){ if (typeof object.keys(value) !== 'nil') { current_key = object.keys(value) if (current_key[0] == new_hash_key && value[current_key[0]] == new_hash_value) { checked_box_hash.splice(key, 1) } } }) } }; i getting error on line. if (typeof object.keys(value) !== 'nil') { need resolve it. please do. object.keys(value) returns array , check if undefined or empty this if (typeof object.keys(value) !== 'undefined' && object.k...

java - Eclipse e4 program will not start -

i hava eclipse e4 application. want have runnable exe file. export of exe file don't got errors. when start exported application program doesn't start , give errors: !session 2016-08-29 08:55:19.759 ----------------------------------------------- eclipse.buildid=unknown java.version=1.8.0_102 java.vendor=oracle corporation bootloader constants: os=win32, arch=x86_64, ws=win32, nl=en_us framework arguments: -clearpersistedstate command-line arguments: -os win32 -ws win32 -arch x86_64 -clearpersistedstate !entry cr-it_client 4 0 2016-08-29 08:55:20.930 !message frameworkevent error !stack 0 org.osgi.framework.bundleexception: not resolve module: cr-it_client [26] unresolved requirement: require-bundle: org.eclipse.equinox.launcher; bundle-version="1.3.100" @ org.eclipse.osgi.container.module.start(module.java:434) @ org.eclipse.osgi.container.modulecontainer$containerstartlevel.incstartlevel(modulecontainer.java:1582) @ org.eclipse.osgi.container...

python - How do I compare 2 lists and order 1 based on the number of matches -

say had list, example: first_list = ['a', 'b', 'c'] and had following list: second_list = ['a', 'a b c', 'abc zyx', 'ab cc ac'] how create function re-orders second list based on total number of times element entire first list matches part of individual string second list? for further clarity: in second list 'a' string contain 1 match the 'a b c' string contain 3 matches the second example list end in reverse order once function has finished my attempt: first_list = ['a', 'b', 'c'] second_list = ['a', 'a b c', 'abc zyx', 'ab cc ac'] print second_list = 0 keyword in first_list: matches = 0 s in second_list: matches += s.count(keyword) if matches > second_list[0].count(keyword): popped = second_list.pop(i) second_list.insert(0, popped) print second_list similar answer: f...

ruby - How do I deploy octopress 3 to a subdirectory within an existing gh-pages site? -

i using octopress 3, , when run jekyll build , generates correct set of files (which includes static files, see list of files below): $ cd _site :_site$ ls -a . cname assets google2d8.html index-alternative.html .. blog increase-revenue.html index.html note entire jekyll-generated blog safely stored within \blog\ , how want it. but once octopress deploy , overwrites entire folder (which overwrites existing static files), see listing below: $ cd _site :_site$ ls -a . .. gemfile gemfile.lock css feed.xml index.html jekyll here _config.yml : title: title email: some@email.com description: > # means ignore newlines until "baseurl:" description baseurl: "/blog" # subpath of site, e.g. /blog url: "http://example.com" # base hostname & protocol site twitter_username: myusername source: '../' #...

c++11 - clang-analyzer-alpha.unix.PthreadLock check missing from clang-tidy version 3.8 and 4.0? -

i trying modernize module's c++ source code using clang-tidy. few weeks ago, downloaded , built clang , clang tools version 3.9 , when ran on 1 of cpp files got clang-analyzer-alpha.unix.pthreadlock saying lock has been taken. later, because of space constraints removed version of clang , used version 3.8 , 4.0 available in our 3rd party repos. in both of these versions, did not warnings regarding alpha check. how enable in version 4.0 ? i using -checks=* while analyzing/running clang-tidy on cpp file. it looks there's no way enable checks without building clang-tidy yourself: https://reviews.llvm.org/d28729#646548 .

java - How to use Multithreading concept in Spring MVC for subsequent operations -

i send email , update activity logs after updating profile in web application. sending mails , updating activity logs, use thread profile update response can sent client , subsequents operations can taken care threads. please suggest implementation. there numerous ways achieve this, fact it's spring mvc application irrelevant. if you're using java 8 can call upon executor service give thread pool: string emailaddress = //get email address... executorservice executorservice = executors.newsinglethreadexecutor(); executorservice.submit(() -> { emailservice.sendnotification(emailaddress); }); pre-java 8: final string emailaddress = ""; thread thread = new thread(new runnable() { @override public void run() { emailservice.sendnotification(emailaddress); } }); thread.start(); if you're creating more complex application should possibly using message queue (activemq good). allows more control , visibi...

How to print html output each on its line in python? -

so i'm making alittle project beginner , i'm doing webscraping. wanted print lyrics of song each on it's line using beautifulsoup in python instead it's printing this: i looked out morning , sun goneturned on music start dayi lost myself in familiar songi closed eyes , slipped awayit's more feeling (more feeling)when hear old song used play (more feeling)and begin dreaming (more feeling)till see marianne walk awayi see marianne walkin' awayso many people have come , gonetheir faces fade years go byyet still recall wander onas clear sun in summer skyit's more feeling (more feeling)when hear old song used play (more feeling)and begin dreaming (more feeling)till see marianne walk awayi see marianne walkin' awaywhen i'm tired , thinking coldi hide in music, forget dayand dream of girl used knowi closed eyes , slipped awayshe slipped awayit's more feeling (more feeling)when hear old song used play (more feeling)and begin dreaming (more feeling)t...

angularjs - Tap on ion-delete-button triggers tap on list item too -

i have list onhold , ontap listeners. onhold event triggers ion-delete-button appear. if tap on delete button ontap event executed well. how can avoid this? ionic bug? example: [http://codepen.io/anon/pen/zbgrkw][1]

c# - List of Data Orientation -

i have list of data want change sack of layout. example : name1 val1 val2 val3 val4 name2 val5 val6 val7 val8 name3 val9 val10 val11 val12 want that: name1 name2 name3 val1 val5 val9 val2 val6 val10 val3 val7 val11 val4 val8 val12 i'm using asp.net repeater display data thanks

c# - Windows Service is running but not updating blob/local file -

i have windows service uploads files blob. set blob name year_month_date inside service. log status in local folder cross check. local log file created same format. set timer in service logs "ping {datetime.now.tostring()}". working when install service. problem is,service has status running, did not create new blob new date in next day morning. can ? code : var blobref = container.getblockblobreference($"{cityname}/{datetime.now.year}_{ datetime.now.tostring("mm")}_{datetime.now.tostring("dd")}/{model.callerid}_{model.interactionid}{path.getextension(callermastermodel.filename)}"); but when restart service, again starts working.

Email - Field "From": Possible security issues -

i have question concerning security of from field find in emails. here's use case: want allow customers send emails third parties through java application. from address same , email managed application. want allow customers set custom name in from field. example: from: john doe <noreply@myapp.com> so in example, noreply@myapp.com 1 of application email john doe value submitted customer. i'd know possible security issues? just make sure validate, sanitize , escape user input. if app allow customers control body , recipient aware can send mails looks own mail. recipient not check address, @ name , name can 'ymansour'

java - Logarithm of a BigDecimal -

how can calculate logarithm of bigdecimal? know of algorithms can use? my googling far has come (useless) idea of converting double , using math.log. i provide precision of answer required. edit: base do. if it's easier in base x, i'll that. java number cruncher: java programmer's guide numerical computing provides solution using newton's method . source code book available here . following has been taken chapter 12.5 big decmial functions (p330 & p331): /** * compute natural logarithm of x given scale, x > 0. */ public static bigdecimal ln(bigdecimal x, int scale) { // check x > 0. if (x.signum() <= 0) { throw new illegalargumentexception("x <= 0"); } // number of digits left of decimal point. int magnitude = x.tostring().length() - x.scale() - 1; if (magnitude < 3) { return lnnewton(x, scale); } // compute magnitude*ln(x^(1/magnitude)). else { // x^(1/...

javascript - If picture width is smaller than transparent box content start new line -

Image
$('.img-rate').each(function(){ $(document).ready(function(){ var n = $(".img-rate").width; if (n < 100) { $('img-rate').hasclass('pull-leftt ') } else { $("img-rate").css("background", "orange"); } }); }); i think $('.img-rate') parent class of both image container, if not change line , use parent class instead, second change wrap $('.img-rate').each(function(){}) code in $(document).ready. and final change instead $('img-rate').hasclass('pull-leftt ') use $('img-rate').addclass('pull-leftt '); let me know if work you.

android get url from edit text and use it in rest api to upload data -

here android rest request code url edit text using id " getstring " gets flagged(can't resolved). please class restrequest { //final string add_stroke_url = ""; final string add_stroke_url = new string[]{ getstring(r.id.buttonuploadurl)}; public boolean success = null; private jsonobject params; private string strokeid; private hashset<point> localpoints; private strokemanagercallback callback; public static string encode(object x) { try { return urlencoder.encode(string.valueof(x),"utf-8"); } catch (unsupportedencodingexception e) { return(string.valueof(x)); } } public restrequest(jsonobject params,string strokeid,set<point> points,strokemanagercallback callback) { this.params = params; this.strokeid = strokeid; this.localpoints = new hashset<point>(); this.localpoints.addall(points); th...

OSX homebrew error when install gdb: ''Uninitialized constant Homebrew::FormulaClassUnavailableError" -

i having problems installing gdb on os x el capitan 10.11.6. i ran brew install homebrew/dupes/gdb in terminal, , got error: uninitialized constant homebrew::formulaclassunavailableerror please report bug: https://git.io/brew-troubleshooting /usr/local/library/homebrew/cmd/install.rb:151:in `rescue in install' /usr/local/library/homebrew/cmd/install.rb:82:in `install' /usr/local/library/brew.rb:84:in `<main>' what mean , how fix that? please me. edit: after run brew doctor got these: warning: /usr/local/bin isn't writable. can happen if "sudo make install" software isn't managed homebrew. if formula tries write file directory, install fail during link step. should change ownership , permissions of /usr/local/bin user account. sudo chown -r $(whoami) /usr/local/bin warning: have macports or fink installed: /opt/local/bin/port can cause trouble. don't have uninstall them, may want temporarily move them out of way, e.g....

how to calculate portfolio return series in matlab? -

i have asset return matrix(t*n) , asset weight vector(1*n) t number of obs n asset.if asset return matrix r(i) , asset weight vector b w(i), want sum(r(i)*w(i)), i=1:n t*1 matrix.how can calculate in matlab? example: x = 0.1400 0.2100 0.1800 0.1100 0.1200 0.1500 0.1700 0.1600 0.1700 0.1800 0.2100 0.1400 w = 0.3000 0.2000 0.5000 then want matrix: r(1,1)=(0.14*0.3)+(0.21*0.2)+(0.18*0.5)=? r(2,1)=(0.11*0.3)+(0.12*0.2)+(0.15*0.5)=? r(3,1)=... r(4,1)=... thanks you can multiply x w transposed. note .' transpose, not ' . so, want simply: x * w.' ans = 0.1740 0.1320 0.1680 0.1660 otherwise, if want practice bsxfun : use bsxfun take product of x , w each column, , sum(.., 2) sum along second dimension, this: sum(bsxfun(@times, x, w),2) ans = 0.1740 0.1320 0.1680 0.1660

java - How to execute an inner class inside of Class which accessed from adapter inside of Class -

i have problem access asynctask<> inside of class , class have adapter (recyclerviewadapter) wanted access class extends asynctask<> for short, it'd this: public class mainactivity extends appcompatactivity implements view.onclicklistener{ recyclerview recyclerview; simplerecycleradapter simplerecycleradapter; linearlayoutmanager linearlayoutmanager = new linearlayoutmanager(mainactivity.this); recyclerview.setadapter(simplerecycleradapter); public class getdata extends asynctask<>{ .... } } and simplerecycleradapter public class simplerecycleradapter extends recyclerview.adapter<simplerecycleradapter.versionviewholder> { //from execute getdata class } try this, public class mainactivity extends appcompatactivity implements view.onclicklistener{ recyclerview recyclerview; simplerecycleradapter simplerecycleradapter; linearlayoutmanager linearlayoutmanager = new linearlayoutmanager(mainactivity.this);...

android - ActionBar icon is not showing if setDisplayHomeEnabled is false -

i want set icon on actionbar. when have setdisplayshowhomeenabled set true icon shows, when false - nothing. don't want show button on actionbar, icon. what's problem? actionbar.settitle(""); actionbar.setdisplayshowcustomenabled(true); actionbar.setdisplayshowhomeenabled(true); actionbar.setdisplayshowtitleenabled(true); actionbar.seticon(getresources().getdrawable(r.drawable.logo_big)); for button write code: actionbar.setdisplayshowhomeenabled(true); actionbar.setdisplayhomeasupenable(false); its bydefault false though, in case if showing have false programatically. you have use getsupportactionbar() instead of actionbar() object.

angularjs - Add component inside another component ui-view -

after login form change view home page this home.js import homecomponent './home.component'; import listtemplatescomponent 'listtemplates/listtemplates.component'; import angular 'angular'; import uirouter 'angular-ui-router'; angular.module('home',[ uirouter ]) .config(($stateprovider, $urlrouterprovider)=> { "nginject"; $urlrouterprovider.otherwise('/home'); $stateprovider .state('listtemplates', { url: '/home', component: 'listtemplates' }); }) .component('home',homecomponent) .component('listtemplates',listtemplatescomponent); home.html <h3>home</h3> <h1>menu</h1> <div ui-view></div> i want when show home page want show default listtemplates import listtemplatescomponent './listtemplates.component'; import angular 'angular'; import uirouter 'angular-ui-router'...

swing - Java `KeyListener` not working -

i working on game (the repo here ), , run in issue: when game switch gamepanel keyboard stop working. gamepanel.java correctly call gui#registerspritemanager , keyboard actions aren't recorded spritemanager . in gamepanel.java public gamepanel(gui gui) { this.gui = gui; this.back = new background(this); this.manager = new spritemanager(); this.manager.add(new roflcopter( gui.width/2, gui.height/2 )); gui.regiterspritemanager(this.manager); this.level = new level1(this.manager); } in gui.java public void regiterspritemanager(spritemanager manager) { this.manager = manager; this.addkeylistener(manager); } why not working? i fixed problem adding this.setfocusable(true); in gui.java

swift - How to make an effect of expandable UICollectionView cell in iOS -

i have collection view 3x3. item (collection cell) contains icon , label. want additional text shown inplace when user touches cell. view text must fullscreen width. in other words want insert view text between collection rows. it's desirable view appears animation. how should that? first ideas i've got are: divide collectionview rows sections , use section footer purpose. make footer of 0 size , show when needed. dynamically create full-width cell , insert @ end of row selected item located. both methods seems tricky me. maybe there more straight forward way? any ideas? thanks!

c++ - bad_cast is not thrown always from dynamic_cast -

i'm facing issues while using exception handling dynamic_cast . not returning bad_cast always. the statement below not throwing me bad_cast , though d1 returned nullptr , compiler showing me warning derived *d1 = dynamic_cast <derived *> (&base); but if try following statement: derived d1 = dynamic_cast <derived &> (base); then it throw std::bad_cast am missing in logic? classes polymorphic. this defined way. if new type casted pointer result nullptr on error. if reference throws exception. see http://en.cppreference.com/w/cpp/language/dynamic_cast if cast successful, dynamic_cast returns value of type new_type. if cast fails , new_type pointer type, returns null pointer of type. if cast fails , new_type reference type, throws exception matches handler of type std::bad_cast.

android - On touch listener will not fire up when the user is too fast -

i have ontouchlistener , waiting action , down events. when user touches surface quick/short down event fire , not event. fixed temporarily sleep thread know sure not ideal solution. have better idea? button mybutton = (button) findviewbyid(r.id.button); mybutton.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view view, motionevent motionevent) { long timelasttouch = system.currenttimemillis(); if (motionevent.getaction() == motionevent.action_up) { long timetouchnow = system.currenttimemillis(); if (timetouchnow - timelasttouch < 400){ return true; } return false; } if (motionevent.getaction() == motionevent.action_down) { long timenow = system.currenttimemillis(); if ((timenow -...

java - Gridlayout with 2x2 imageview android -

i,ve got gridview gets 4 imageviews adapter, want have them 2x2 resized , fitted on screen. here´s code that: @override protected view createquizcontentview() { manswerview = new gridview(getcontext()); statelistdrawable selector = new statelistdrawable(); selector.addstate(new int[]{android.r.attr.state_pressed}, new colordrawable(color.ltgray)); selector.addstate(new int[]{-android.r.attr.state_pressed}, new colordrawable(color.white)); manswerview.setselector(selector); //manswerview.setselector(r.drawable.selector_button); manswerview.setnumcolumns(2); manswerview.setadapter(new optionsquizadapter(getquiz().getoptions(), r.layout.imgitem_answer)); manswerview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { manswered = position; allowanswers(manswerview,position); ...

php - Style CodeIgniter "human name" in form validation -

i want apply custom general style "human names" in codeigniter set_rules method of form validation class: $this->form_validation->set_rules(<name of field>, <human name>, <rules>); say want make "human names" in boldface, know can do: $this->form_validation->set_rules(<name of field>, <strong>human name</strong>, <rules>); however difficult manage once number of fields style gets larger. is there way access using set_error_delimeters ? $this->form_validation->set_error_delimeters('<div class="error">', '</div>'); wherein can set delimeters "human name" or 2nd parameter in set_rules method? currently there no (at least explicitly discussed) way documentation . you can change set_rules functions of form_validation library.you need change label parameter of function. set_rules function in library. change line $label = ($label === ...

reactjs - Passing function with bound this causes diffing without needing to render -

class extends react.component { handleclick() { console.log("hello other side"); } render() { <b onclick={::this.handleclick}/> } } class b extends react.component() { render() { return <div>useless stuff/> } } when renders b passes handleclick function bound this. causes previousprops.onclick !== nextprops.onclick because binding create new function every time. how prevent this? use "shouldcomponentupdate" there better ways? instead of binding method inside render method, bind function inside of constructor, this: class extends react.component { constructor(props, context) { super(props, context); this.handleclick = this.handleclick.bind(this); } handleclick() { console.log("hello other side"); } render() { <b onclick={this.handleclick}/> } } class b extends react.component() { render() { return <div>useless stuff/> } } you use autobind core-de...

string - Encoding byte data to base64 crashes for some byte data in vb6 -

i have following code convert byte data base64 string : redim g_template(dwlen) byte = 0 while len(m_strtemplate) > 0 ipos = instr(1, m_strtemplate, "$") if (ipos > 0) g_template(i) = mid(m_strtemplate, 1, ipos - 1) m_strtemplate = right(m_strtemplate, len(m_strtemplate) - ipos) = + 1 else exit end if loop dim dm, el set dm = createobject("microsoft.xmldom") ' create temporary node base64 data type set el = dm.createelement("tmp") el.datatype = "bin.base64" ' set bytes, encoded string el.nodetypedvalue = g_template fingerdata = el.text but code crashes following byte data : a123 +#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww; ;:61wwwwwwwwwww :8531.wwwwwwwww :6430/0wwwwwwww ;:63200.-wwwwww :9631/.--wwwwww:8620.,,-wwwww 8750-,++,wwwww 82-+++*)wwww 9...

twitter bootstrap - Jquery responsive slider with text block under it -

Image
i looked lot slider (jquery or bootstrap) didn't find anything. slider has image in top, bullets many slides , then, under it, each slide has text block. i tried ones text in top in caption, didn't work. if knows slider in image please tell me, or if have idea great. just add following css if using bootstrap .carousel-indicators { bottom: 0; margin-bottom: -20px; } .carousel-indicators li{ border: 1px solid #f44336; } .carousel-indicators .active { background-color: #f44336; } demo

javascript - Get icons from browser resources -

is there possibility dynamically images/icons browser? i have problem custom dropdown control (written in asp/c#). have same icon browser has standard select control. control has few html elements, including img , holds image dropdown button. there no option use select control this. there differences between browsers , want cross-browser.

angularjs - How to give priority to angular routing instead of node routing while using html5Mode(true) in angular JS -

i want route application according angular routes in html5mode(true) . here angular code snippet. index.html <!doctype html> <html lang="en"> <head> <title>myapp</title> <base href="/"> <!-- import angular --> <script type="text/javascript" src="bower_components/angular/angular.min.js"></script> <!-- import angular route --> <script type="text/javascript" src="bower_components/angular-route/angular-route.min.js"></script> <!-- import local js files --> <script type="text/javascript" src="app/app.routes.js"></script> <script type="text/javascript" src="app/usercontroller.js"></script> <script type="text/javascript" src="app/app.js"></script> </head> ...