Posts

Showing posts from June, 2012

android - Lollipop inconsistent CPU usage on Galaxy S4 -

Image
i'm developing game android , testing on samsung galaxy s4. however, i'm finding since i've installed lollipop (5.0.1) on game freezing approx. 200ms every often, causing drop around 10 frames. the game has been tested on multiple other (non-s4) devices running lollipop , not doing this. going cpu usage monitor in android studio, i'm having complete opposite more common (upward) spikes in cpu usage. i'm finding cpu usage spiking down instead of up. is common problem lollipop/galaxy s4? have suggestions on can find out causing this?

facebook - ParseFacebookUtilsV4::initializeFacebookWithApplicationLaunchOptions issue in IOS using Parse/FB SDK -

i still using objective-c in project, since legacy one. using parse before , trying add fb integration. managed make compile - these have installed via cocoapods. using bolts (1.2.0) installing fbsdkcorekit (4.3.0) installing fbsdkloginkit (4.3.0) using parse (1.7.5) installing parsefacebookutilsv4 (1.7.5) here code. firstviewcontroller -(void) viewdidappear:(bool)animated { // additional setup after loading view, typically nib. if (![pfuser currentuser] || // check if user cached ![pffacebookutils islinkedwithuser:[pfuser currentuser]]) { // check if user linked facebook pfloginviewcontroller *logincontroller = [[pfloginviewcontroller alloc] init]; logincontroller.fields = (pfloginfieldsusernameandpassword | pfloginfieldsfacebook | pfloginfieldsdismissbutton); [self presentviewcontroller:logincontroller animated:yes completion:nil]; [self presentviewcontroller:loginviewcontroller animated:yes completion:null]; } els

c# - Issue with BackgroundTransfer not saving the downloaded file -

i have issue background transfer service: i trying download file onedrive using backgrounddownloader, transfer seems effective (some bytes transfered), transfer seems never end, , @ end file downloaded size 0 bytes. in addition, transfer never ends because if launch second transfer, never starts (except if switch network connectivity (wifi on/off)). i have tried same link in background transfer sample ms, gets same behavior. have used same link in ie, , transfer goes well. have tried many files (mp3), result same. have added: download.costpolicy = backgroundtransfercostpolicy.always; but still same result. have tried on wifi, debug, release. any idea why file not saved? (i have enough space on sd card of course) if no answer found, know implementation of background transfer service use instead of official one?

javascript - Jquery append() on another line? -

i thought simple code outputs spans on same line. $("<p/>") .append($("<span/>", { class:"time", text: content.time })) .append($("<span/>", { class: "content", text: content.message })); but since append these elements without newline, spans end needing manual spacing, isn't possible @ current scale. <p><span class="time">now</span><span class="content">lorem ipsum ...</span></p> how can force jquery manually append spans on new line? i've tried using .after to. edit: i guess bit unclear, far .append("\n") i'm looking for, if there better ways, i'm ears appending <br/> tag not looking for. <p> <span class="time">now</span> <span class="content">lorem ipsum ...</span> </p> if want html element appen

statistics - R code optimizing for rep function -

i'm working data income/expense per home poll. 9,002 observations sample data base represent 3,155,937 homes through expansion factor this. homeid income factor 001 23456 678 002 42578 1073 .. .. .. 9002 62333 987 i'm trying exact summary of total income per decile expanding each income value times factor give result 3,155,937 ovservations vector , i'm using 'for' loop asign each value decile belongs to. three <- nal %>% select(income,factor) 5 <- data.frame(income=rep(three$income,three$factor)) for(i in 1:31559379){if(i<=3155937){five$decil[i]=1} else{if(i<=6311874){five$decil[i]=2} else{if(i<=9467811){five$decil[i]=3} else{if(i<=12623748){five$decil[i]=4} else{if(i<=15779685){five$decil[i]=5} else{if(i<=18935622){five$decil[i]=6} else{if(i<=22091559){five$decil[i]=7} else{if(i<=25247496){five$decil[i]=8} else{if(i<=28403433){five$decil[i]=9} else{five$decil[i]=10} }}}}

c# - Can't translate method into a store expression -

this question has answer here: method cannot translated store expression 1 answer the closest questions i've found this one , far can see, it's not regarding same issue. might mistaken, in case, hope can explain how similarity goes (except same words referring error, is). being said, have following issue. this works supposed to. list<typo> things = context.things.where(thing => thing.nice).tolist(); this, however, doesn't. list<typo> things = context.things.where(thing => isnice(thing)).tolist(); ... private bool isnice(typo thing) { return thing.nice; } context of type modelcontainer deriving dbcontext . i've been told it's standard setup ef , have no reason suspect otherwise. error message claims following. {"linq entities not recognize method xxx method, , method cannot translated store expression."

What does the -f option mean for the git rm command? -

this question has answer here: when git rm -f used? 3 answers i learning git through this online book . don't understand info git rm command: if modified file , added index already, must force removal -f option. safety feature prevent accidental removal of data hasn’t yet been recorded in a snapshot , can’t recovered git. english not native language. have problems correctly translating of quote... " recorded in snapshot " mean? "commited"? i see git rm 123.txt the same git rm -f 123.txt , if 123.txt changed , added index (i.e. storage area, through add command): removes 123.txt index , working directory. so, don't understand -f option meaning. please, expand me. additional tried read this : the files being removed have identical tip of branch , , no updates contents can staged in index, though default be

Can't shift the origin in python..? -

a=[3,4] b=[5,8] c=[7,4] d=[a,b,c] print (d) in range(3): j in range(2): d[i][j]-=a[j] print (d) in python code output is [[0,0], [5,8], [7,4]] instead of [[0,0], [2,4], [4,0]] can tell me why? d contains reference of a , not copy. a changes [3,4] [0,0] during first iteration of loop. that's why, next iteration of loop d[i][j]-=[0,0] . you should replace d=[a,b,c] d = [list(a), b, c]

ios9 - Issue loading a url in WKWebView using Xcode 7 beta3 -

i doing quick test on wkwebview evaluate benefits , drawbacks. have found able load urls using xcode 6.4 , ios 8 having issues loading same url in xcode 7 beta 3. this doing : - (void)viewdidload { [super viewdidload]; // first create wkwebviewconfiguration object can add controller // pointing viewcontroller. wkwebviewconfiguration *configuration = [[wkwebviewconfiguration alloc] init]; wkusercontentcontroller *controller = [[wkusercontentcontroller alloc] init]; // add script handler "observe" call. added every frame // in document (window.webkit.messagehandlers.name). [controller addscriptmessagehandler:self name:@"observe"]; configuration.usercontentcontroller = controller; // url loaded wkwebview. nsurl *jsbin = [nsurl urlwithstring:k_jsbin_url3]; // initialize wkwebview current frame , configuration // setup ab

javascript - Make floating divs move place smoothly when container resizes -

i'm looking apples' icloud website, when screen gets small divs move new position in effect. i'm looking @ this: .wrap { width: 100%; background-color: green; clear: all; } .wrap div { float: left; background-color: red; height: 100px; width: 100px; margin: 10px; } <div class="wrap"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> as can see when screen gets smaller divs move, how make them float new position in effect? i accept: - pure css - javascript - jquery ,

sql - Sum/aggregate data based on dates -

i have following table items sold out in every shop. table columns shop_id: specific id of shop, sold: purchase amount dollars ($) time: date , time of purchase. data shop_id sold time 1 12.44 23/10/2014 20:20 1 12.77 24/10/2014 20:18 1 10.72 24/10/2014 20:18 1 14.51 24/10/2014 20:18 2 5.94 22/10/2014 20:11 2 15.69 23/10/2014 20:23 2 8.55 24/10/2014 20:12 2 6.96 24/10/2014 20:18 3 8.84 22/10/2014 20:21 3 7.82 22/10/2014 20:21 3 22.19 23/10/2014 20:23 3 13.21 23/10/2014 20:23 4 14.60 23/10/2014 20:20 4 12.19 23/10/2014 20:23 4 5.41 24/10/2014 20:18 4 10.93 24/10/2014 20:19 5 18.54 22/10/2014 20:21 5 7.48 22/10/2014 20:21 5 10.67 24/10/2014 20:18 5 15.96 24/10/2014 20:18 i have 3 classifiers per purchase : purchase classifiers low: 0-8 $ medium: 8-12 $ high: 12 , higher $ what write query usin

javascript - window.document sometimes comes out undefined in IE10 -

javascript code below works fine in ie8 , older. creates pop-up window somehtml . print_window = window.open('', 'blah', 'width=500,height=200,left=300,top=300'); doc = print_window.document; doc.write(somehtml); self.window = print_window; doc.close(); in ie10 code leaves doc variable 'undefined' generating javascript error on doc.write(). interesting when on page first time works subsequent times may or may not work. can advise on cause , how fix it? lot. @jfriend00 please try simple code below , on second, third or fourth button click you'll blank window because window.document undefined. i'm running ie 10.0.9200.17377. function opennew() { print_window = window.open('', 'blah','width=500,height=200,left=300,top=300'); doc = print_window.document; str = '<html><body bgcolor="#cccccc" text="#000000">new window</body></html>'; doc.write(str);

php - How to use localhost to host my HTML and CSS website -

i beginner , learned html , css. when tried host website opened this @ method 2 localhost searched lot didn't understand like: it server side php , phpmyadmin localhost hostname means computer , may used access computer's own network services via loopback network interface i can't understand wikihow said , can host html , css website free? or google said? localhost local computer. has ip4 address 127.0.0.1 ipv6 ::1. so if connect localhost connect own computer (usually not visible outside world unless leave computer on , stay connected internet , have router/firewall configured forwards traffic pc (only when know doing).

android - Can not Use Async Class inside an Activity . The Activity already Consist of a Main class extending from Activity -

public class server_activity extends asynctask<void, string, void> { } an error shown when write class: classserver_activity must either declared abstract or implement abstract method doinbackground(params). what causing error ? add method doinbackground() . because asynctask abstract class, contains abstract method doinbackground() . means, class inheriting asynctask class must implement doinbackground() method. but title seems question, sounding wrote server_activity class in same file of activity. in eclipse error sound like: the public type testclass must defined in own file if case: create new .java file , write there server_activity class. , don't forget implement doinbackground() method there. you can see example of in android developer api .

How to get Amazon MWS Reports Java client library to download specific Document version -

i have code processes amazon settlement reports (xml format). until user download xml file amazon seller central , load application processing. i have added code use mws reports api , via amazon java client library, search available settlement reports , allow user select 1 want, fetch , process it. works fine except refunds not processed. in comparing xml retrieved different methods find downloaded files newer format api. <documentversion>'4.01'</documentversion> versus: <documentversion>'3.01'</documentversion> in older version <refund> element called <adjustment> xml otherwise same. as attempted find answer came across mws forum post dated 11 aug 2014: https://sellercentral.amazon.com/forums/ann.jspa?annid=186 this announces changes settlement reports , "notes" client libraries not changing. the latest version of reports api java client released on 30 sep 2014 (i.e. after announcement) 1 using, no

database - Update taking a row lock -

i have following query in postgres. create schema s; create table s.t1 ( "id1" bigint, "id2" bigint, "id3" boolean default false not null, constraint "pk1" primary key (id1) ) with(oids=false); insert s.t1 (id1, id2, id3) values (1, 22, true); insert s.t1 (id1, id2) values (2, 22); insert s.t1 (id1, id2) values (3, 33); select exists (select 1 s.t1 id2 = 22 , id3 = true update); /* take lock on row. */ select id3 s.t1 id2 = 22 , id3 = true update; /* takes lock on row. */ drop schema s cascade; i understand second query takes lock (when run under transaction) on particular row. no other query able access row till transaction commits. does first query takes lock on row when run under transaction? thanks select exists (select 1 s.t1 id2 = 22 , id3 = true update); /* take lock on row. */ yes. rows retrieved query locked. not matter in form , whether @ returned query. if subquery locks rows outer

Get list of user groups with Facebook API issue -

i'm using facebook api user groups response object not returning array or containing user groups. i checked if i'm connected groups (public , private) , yes, i'm. below code: <fb:login-button scope="public_profile,email,user_birthday,user_education_history,user_location,user_groups" onlogin="checkloginstate();"> </fb:login-button> any idea? thank you!

r - align text on axis to start at same position -

Image
please have @ plot. possible force text on y-axis start @ same position (and not end @ same position case now)? you can use theme adjust axis.text.y . use hjust = 0 left alignment. altogether, add line plot: theme(axis.text.y = element_text(hjust = 0)) and here reproducible example produces similar plot. ggplot(mtcars, aes(x = mpg, y = rownames(mtcars), fill = factor(cyl))) + geom_dotplot(binaxis = "y") + theme(axis.text.y = element_text(hjust = 0))

php - Argument passed must be an instance of longtext, string given - doctrin2 symfony -

i have problem polluting mysql field defined text field data received result of serialize() php command. using symfony2 doctrine annotations . my service code: $oe = serialize($object); $log->setobject(serialize($object)); and entity: /** * @orm\column(type="text") */ protected $object; the error following: symfony search on symfony website exception detected! catchable fatal error: argument 1 passed appbundle\entity\log::setobject() must instance of longtext, string given, called in c:\wamp\www\symfony_learn\src\appbundle\service\loggerservice.php on line 22 , defined 500 internal server error - contexterrorexception it seems there mismatch of data types don't quite understand 1 data type string , second text , mind conversion should take place automatically. know can mysql cast wonder symfony2 , doctrine2 provides tools deal such situation? try using mysql cast: cast(yourvarchar longtext)

javascript - Confusion with returning values from a synchronous ajax call -

i'm having issues returning value synchronous ajax call. value want return class created server response. here's ajax code: function webrequest(file, data) { return $.ajax({ url: "http://xxx.xx.xx.xxxx/xxxxx/"+file, type: "post", data: data, asynch: false, error: function(jqxhr, textstatus, errorthrown){ return new serverresponse(false, errorthrown); }, success: function(data, textstatus, jqxhr){ return new serverresponse(true, data); }, timeout: 7500 }); } here's serverresponse.js var success = false; var text = null; var serverresponse = function(success, text) { this.success = success; this.text = text || null; }; serverresponse.prototype.issuccessful = function() { return this.success; }; serverresponse.prototype.getdata = function() { return this.text; }; the returned value of webrequest(..) follows: obje

jQuery stop previous search result from loading -

i made simple live search function filter results in table. see below: $( "#searchinput" ).keyup(function() { if ($( "#searchinput" ).val() == ''){ //leeg $( "#tabledatadiv" ).html('loading...'); $( "#tabledatadiv" ).load('tabledata.php'); }else{ //niet leeg $( "#tabledatadiv" ).html('loading...'); $( "#tabledatadiv" ).load('tabledata.php?searchquery='+encodeuricomponent($( "#searchinput" ).val())); } }); the problem when user typing fast, , previous "string"my script searching has lot of results, result of previous search overwrites results of final one. so, when searching "ax" gives 2 results, first tries (while typing) search "a" has 5000 results. loading result ax takes less time loading results a, result need short time, , content of div overwritten result "a". how prevent this? when us

routing - Rails form_for multiple models no controller -

i'm new rails , trying create view form_for adds data in 2 different models. i've looked @ stack overflow posts multiple models, , i've used fields_for call submit information second model. however, form submission processes form_for data, , not fields_for. please advise on how fix this. 2 models users , schools (with goal of registering school , own information, being able log in , attach school adviser) view code: <div class="row"> <div class="col-md-6 col-md-offset-3"> <%= form_for(@user) |f| %> <%= fields_for(@school, :url => {:controller => "advisers", :action => "new_school"}) |s| %> ... fields... <% end %> <legend>primary adviser information</legend> ... forms ... <%= f.hidden_field :access_level, :value => "adviser" %> <p>&nbsp;</p> <di

select - SQL: Return first instance of an access request -

i use sql , i'm having trouble task. table has information need. a person can request access sector of building, , 2 types of approbations may needed. i have discover data first request user did each building has access if user jon requested access sector "a" , 2 weeks later sector "b", have return information approved sector's "a" , when. i can find out sector requested first , date. don't know how return approvers since in row. think key here use ticket number. records id eventdate ticket user action event approver building sector status 15 7/1/2015 12:25 17c9f862 4003321 new access request started - ohio it_2 running 14 7/1/2015 12:41 17c9f862 4003321 approved manager approval 4001719 ohio it_2 running 12 7/1/2015 15:29 17c9f862 4003321 - finished - ohio it_2 finished: approved 13 7/1/2015 15:29 17c9f862 4003321 approved director approval 4003468 oh

iterator - Why do generators not support map()? -

it seems utterly natural me generators, function arrays, should support basic list operations, map() , filter() , , reduce() . missing something? i wrote code map , seems simple enough, better have functions embedded in generators: let fancygen = g => { let rv = function*() { (let x of g) yield x; } rv.map = function*(p) { (let x of g) yield p(x); } return rv; } i'm new generators, comments on code welcome. in particular, best way write "the identity generator"? why generators not support map()? because it's easy fill in userland implementation. es3 didn't include array iteration methods either, maybe see transformers iterators in es7 :-) generators, function arrays no, please stop , distinguish iterators generators : an iterator object .next() method conforms iterator protocol. a generator iterator created generator function ( function* ). .next() method takes argument result of each yie

Need help to optimize neo4j cypher CREATE and MERGE queries -

i parsing bitcoin blockchain, whole idea build node graph looks (address)-[redeemed]->(tx)-[sent]->(address) can see how bitcoin addresses related each other. problem execution time, takes few minutes import 1 transaction. besides, of these queries long, few thousands of lines, , won't execute @ all. have read few articles on how optimize match queries, found nothing create , merge. saw few guys here recommending use unwind , send data possible parameters, make queries shorter, have no idea how implement in query. here example of query: http://pastebin.com/9s0klney you can try using following simple query, passing string parameters "hash", "time", "block", , "confs"; , collection parameter named "data": create (tx:tx {hash: {hash}, time: {time}, block: {block}, confirmations: {confs}}) foreach(x in {data} | merge (addr:address {address: x.a}) create (addr)-[:redeemed {value: x.v}]->(tx) ); the values

class - Setting a functools.partial as an instance method in Python -

i'm using functools.partial create closure, , using setattr make callable class instance. idea here create set of methods @ runtime. #!/usr/bin/python functools import partial class myclass(object): def __init__(self, val): self.val = val @classmethod def generatemethods(self): def dummy(conf1, self): print "conf1:", conf1 print "self.val:", self.val print s in ('dynamic_1', 'dynamic_2'): closed = partial(dummy, s) setattr(self, "test_{0}".format(s), closed) it seems me partial bind current value of s dummy 's first arg, free self passed when called instance. it's not working how i'd expect if __name__ == '__main__': # dynamically create methods myclass.generatemethods() # create instance x = myclass('foo') # dynamically created methods aren't callable instance :(

python - ImportError: No module named bs4 how fix -

i have next python 2.7 (debian) code from bs4 import beautifulsoup yandexdiskexception import yandexdiskexception import random yandexdiskrestclient import yandexdiskrestclient import sys i try run, message root@vps-1074211:/tmp/beautifulsoup4-4.4.0# python /var/vah13/untitled/grep.py traceback (most recent call last): file "/var/vah13/untitled/grep.py", line 5, in <module> bs4 import beautifulsoup importerror: no module named bs4 how fix it? i installed pip install beautifulsoup4 apt-get install python-bs4

log4j2 - Why isn't my Log4J code working with the FlumeAppender? -

Image
i'm getting following error log4j : 2015-07-07 18:24:00,974 error error processing element flume: class_not_found 2015-07-07 18:24:01,009 error appender auditlogger cannot located. route igno red the following log4j2 xml file : <?xml version="1.0" encoding="utf-8"?> <configuration status="warn"> <appenders> <console name="console" target="system_out"> <patternlayout pattern="%d{hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/> </console> <file name="myfile" filename="outputlogfile.log" immediateflush="false" append="false"> <patternlayout pattern="%d{yyy-mm-dd hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/> </file> <flume name="auditlogger" compress="true"> <agent host="192.168.10.101" port="8800"/>

javascript - Passing template instance data as a keyword argument to a nested template -

i have template, called skillbar , takes 2 keyword arguments, title , value . so, example, type: {{>skillbar title="strength" value=51}} to render skillbar label "strength" has progress bar filled 51%. i have bunch of these skillbars create , rather doing like: {{>skillbar title="strength" value=51}} {{>skillbar title="willpower" value=80}} {{>skillbar title="imagination" value=30}} id rather create separate template, can register helper on contains array of objects can use parameters. template.abilities.helpers({ abilities: [ {title: 'strength', value: 51}, {title: 'willpower', value: 80}, {title: 'imagination', value: 30} ] }); presumably then, {{#each}} on abilities array in markup can create skillbar template instances way. this encapsulates essence of want do, throws syntax error: <template name="abilities"> {{#each

go - Google Apps API 403 with Service Account -

i've been trying make query against google's admin api list users in google apps organization. have permissions make query in web ui example , results, 403's when try make query service account. import ( "fmt" "io/ioutil" "log" "golang.org/x/net/context" "golang.org/x/oauth2/google" directory "google.golang.org/api/admin/directory_v1" ) func main() { serviceaccountjson, err := ioutil.readfile(serviceaccountfile) if err != nil { log.fatalf("could not read service account credentials file, %s => {%s}", serviceaccountfile, err) } config, err := google.jwtconfigfromjson(serviceaccountjson, directory.admindirectoryuserscope, directory.admindirectoryuserreadonlyscope, ) client, err := directory.new(config.client(context.background())) if err != nil { log.fatalf("could not create directory service client => {

wordpress - Get all product variations of a product given its ID in Woocommerce -

Image
i have custom page i'm trying list every products in store along variations. also, i'm trying list variations' prices sorted product attribute slug 'size' for testing, i'm trying variations of single product id 381 code yet is $handle=new wc_product('381'); $variations1=$handle->get_avaialable_variations(); foreach ($variations1 $key => $value) { echo '<option value="'.$value['variation_id'].'">'.implode('/',$value['attributes']).'-'.$value['price_html'].'</option>'; } but error i'm getting php fatal error: call undefined method wc_product::get_avaialable_variations() i tried using $handle=new wc_product_variable('381'); instead of $handle=new wc_product('381'); but error same. any here? try code. $handle=new wc_product_variable('12');

html - All videos move to left in Chrome when columns is used -

i using -webkit-column-width create multiple columns of videos (videos on youtube used testing purpose). works under ie. can not work under chrome. jsfiddle . .newspaper { -webkit-column-width: 300px; -moz-column-width: 300px; column-width: 300px; } <div class="newspaper" align="center"> <div style=" display: inline-block; border: 5px solid red;"> <iframe style="border-radius: 5px; " src="https://www.youtube.com/embed/mxaf92mmcv4"></iframe> </div> <div style=" display: inline-block; border: 5px solid red;"> <iframe style="border-radius: 5px;" src="https://www.youtube.com/embed/7fdfgeg-9r8"></iframe> </div> <div style=" display: inline-block; border: 5px solid red;"> <iframe style="border-radius: 5px; " src="https://www.youtube.com/embed/98xw8b3

trigger function for back button in browser by javascript -

for example, if running web page , wanted go back, unable function on click on button in browser. javascript provide function trigger button. you can use history.back() on browsers. source: http://www.w3schools.com/jsref/met_his_back.asp

jquery - How to get background color for a div from option list items background color -

i have problem. can find codes here: http://jsfiddle.net/icannot/ux8uv5v0/3/ enter code here as can see there color schemes. when click 1 of them, colors apply background colors of both of primary , secondary option list items. part works fine. when select color primary, color should fill box, next list. doesn't. when select color secondary, works. if select primary color, whatever choose, fill box same color of secondary one. can me please? sorry english. your jquery selectors not accurate enough. anonymous functions inside change events should be: $("select#colorlist1 option:selected").each(function (){... ... $("select#colorlist2 option:selected").each(function (){... working jsfiddle .

How to make my fixed "mobile-nav" bar appear when I scroll down the page? -

#web-nav { display: none; } #mobile-nav { width: 100%; background: url(img/menu-bg.png) repeat; height: 70px; display: block; position: fixed; z-index: 50; top: 0px; } <nav id="mobile-nav"> <a href="index.html"> <img class="logo" src="admin/wp-content/themes/mame/assets/img/sicklehammer.png" /> </a> <img class="drop-nav" src="open.png" /> </nav> <nav id="mobile-expand"> <img class="logo" src="logo.png" /> <img class="close" src="img/close.png" /> <div id="hidden-nav"> </div> <ul id="menu"> <li><a href="index.html">home</a> </li> <li><a href="work/index.html">work</a> </li> <li><a href="about/index.html"&g

microchip - how to make spi connection between arduino uno and dspic33ep512mc502? -

i want test spi comunication between arduino uno , dspic33ep512mc502, use serial port see receiving data microcontroller; -arduino uno master -dspic33ep512mc502 slave here code arduino uno : #include<spi.h> byte y=1; void setup() { serial.begin(9600); spi.begin(); spi.setdatamode(spi_mode1); digitalwrite(ss,high); // spi.setbitorder( lsbfirst); spi.setbitorder( msbfirst); } int trnasfer_spi(int d) { digitalwrite(ss,low); byte r=spi.transfer(7); digitalwrite(ss,high); return r; } void loop() { if (serial.available() > 0) { // read incoming byte: int incomingbyte = serial.read(); y=trnasfer_spi(incomingbyte); } serial.print(y, dec); delay(1000); } here dspic33ep512mc502 code(just spic comunication): initialization : anselbbits.ansb0 = 0; trisbbits.trisb0 = 1; trisbbits.trisb7 = 1; trisbbits.trisb8 = 0; trisbbits.trisb9 = 1; spi1con1bits.dissck = 0; spi1con1bits.dissdo = 0; spi1con1bits.mode16 = 0

C++ issue with division, multiplication, and addition on same line -

this question has answer here: what behavior of integer division? 5 answers this in c++, i'm having problem program converts celsius fahrenheit. the line i'm having issue conversion equation line: fahrenheittemp = (9 / 5) * celsiustemp + 32 the equation/program works fine when put 1.8 in place of 9 / 5 reason 9 / 5 never gets multiplied celsiustemp . returns value of celsiustemp + 32 only. the rest of program good, it's 9 / 5 doesn't anything, have tried different types of combining parenthesis, etc. your problem in fact you're using integer division instead of floating-point division. expression: 9 / 5 evaluates to: 1 because throws away 0.8 remainder. if want use floating-point division, you'll need make sure 1 or both of operands floating-point types: fahrenheittemp = (9.0 / 5.0) * celsiustemp + 32; if far

html - Menu links not clickable -

i have defined in code link go page, not going anywhere when click it. if go page: http://www.davidhechtkitchens.com/ , try click on "portfolio" in top navigation nothing. if @ code you'll see it's defined go portfolio.html. this problem seems in effect when there sub-menu underneith top link. if remove sub-menu "portfolio" works. it seems have kind of script active prevents default action, while checking source code, when click on button adds class anchor. (in cases made make work on mobile devices)

Apache spark: setting spark.eventLog.enabled and spark.eventLog.dir at submit or Spark start -

i set spark.eventlog.enabled , spark.eventlog.dir @ spark-submit or start-all level -- not require enabled in scala/java/python code. have tried various things no success: setting spark-defualts.conf as spark.eventlog.enabled true spark.eventlog.dir hdfs://namenode:8021/directory or spark.eventlog.enabled true spark.eventlog.dir file:///some/where running spark-submit as: spark-submit --conf "spark.eventlog.enabled=true" --conf "spark.eventlog.dir=file:///tmp/test" --master spark://server:7077 examples/src/main/python/pi.py starting spark environment variables: spark_daemon_java_opts="-dspark.eventlog.enabled=true -dspark.history.fs.logdirectory=$sparkhistorydir -dspark.history.provider=org.apache.spark.deploy.history.fshistoryprovider -dspark.history.fs.cleaner.enabled=true -dspark.history.fs.cleaner.interval=2d" and overkill: spark_history_opts="-dspark.eventlog.enabled=t

ios - UINavigationBar background - how to cover all sizes, resolutions and devices? -

i have following code works fine setting background image: [self.navigationcontroller.navigationbar setbackgroundimage:[uiimage imagenamed: @"navbar_bg.png"] forbarmetrics:uibarmetricsdefault]; my question is, xcode6, ios8/9, iphone 5, 6, 6+, ipad, etc, how make sure cover devices, widths , resolutions, make sure background image fills navigation bar correctly? i have seen other questions on , various other sites, have been 2-4 years old, , don't mention or cover latest device widths , resolutions. i want use background image in navigation bar, need make sure looks on possible devices. all have have 3 versions of image in asset catalogue. first in size need second twice size , third 3 times size. xcode put right image on right device. alternatively can put vectorial image , @ complie time xcode generate 3 images on fly. for navigation bar need separate images portrait , landscape. can write this: uiimage *portraitimage = [uiimage imagenamed:@&qu

ios - Keyboard not showing for UITextField -

Image
i have uiview contains uicollectionview, contains custom cells. these custom cells contain uilabel , uitextfield. code custom cell class , uicollectionview 1 of delegate methods is: class durationdaycells: uicollectionviewcell { @iboutlet weak var daylabel: uilabel! @iboutlet weak var dayhourtext: uitextfield! } func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { return daysset.count } func collectionview(collectionview: uicollectionview!,layout collectionviewlayout: uicollectionviewlayout!,sizeforitematindexpath indexpath: nsindexpath!) -> cgsize { return cgsize(width: (self.durationcollectionview.frame.width/cgfloat(daysset.count)), height: self.durationcollectionview.frame.height) } so can see, these cells dynamically created , sized according size of daysset . problem when tap 1 of text fields in cells keyboard not pop (the pink/red view said uiview): i have follow question when did manag

Change external SVG text with javascript -

i'm having issue changing text in external svg. i've found number of solutions listed here none of them have worked. adding listener: document.getelementbyid('id1').addeventlistener('onload', func); the function: function func () { var ele = document.getelementbyid('id1'), svg = ele.contentdocument, p = svg.getelementbyid('id2'); alert(p.textcontent); p.textcontent = 'test'; } the first time load it, p returns null. on second load alert returns correct text within svg text element text not updated next statement. why not working on first load , why text not changing <svg height="90" width="200"> <text x="10" y="20" style="fill:red;">several lines: <tspan x="10" y="45">first line.</tspan> <tspan x="10" y="70">second line.</tspan> </text> <

node.js - Mongoose - access populate field from within schema -

i have schema references model. like var bookschema = new schema({ title: string, series: { type: schema.types.objectid, ref: 'series' } }); now have function in book schema needs access series . want like bookschema.methods.fulltitle = function() { return [this.series.title, this.title].join(" - "); } but doesn't work. how can this? you need populate referenced model prior being able access properties. using existing setup, similar following: bookschema.methods.fulltitle = function() { this.populate('series', function(err, result) { return [result.series.title, result.title].join(" - "); }); } see mongoose population more details on this. http://mongoosejs.com/docs/populate.html

How to get all week dates for given date java -

i have date , how dates fall on week given date belongs in java? example: if give today's date should dates belonging week. 12 july 2015 18 july 2015 could 1 me please. i trying week dates given date, have given explanation why question not duplicate, please read before commenting. you can try following way, calendar cal = calendar.getinstance(); //cal.settime(new date());//set specific date if want for(int = calendar.sunday; <= calendar.saturday; i++) { cal.set(calendar.day_of_week, i); system.out.println(cal.gettime());//returns date } output sun jul 12 08:12:38 ist 2015 mon jul 13 08:12:38 ist 2015 tue jul 14 08:12:38 ist 2015 wed jul 15 08:12:38 ist 2015 thu jul 16 08:12:38 ist 2015 fri jul 17 08:12:38 ist 2015 sat jul 18 08:12:38 ist 2015

android - CollapsingToolbarLayout with multiline title -

is possible make collapsingtoolbarlayout 's expanded title text wraps across several lines (similar textview.maxlines attribute)? i did library https://github.com/opacapp/multiline-collapsingtoolbar add library project , replace collapsingtoolbarlayout net.opacapp.multilinecollapsingtoolbar.collapsingtoolbarlayout

c++ - Wrapper implementation for an abstract method in the base class -

i have base class inherited many subclasses. need define new signature abstract method, wrapper. tried class b { public: virtual void f() = 0; void f(string msg) { /* print msg , call f() */ } }; class d : public b { public: void f() override { /* implementatation */} }; int main() { d d; d.f("msg"); } but doesn't compile , give following error error: no matching function call 'd::f(string) my questions are: why cannot d::f(string) resolved? why of following fix problem? renaming f(string) f2(string) (ugly) defining d::f(string x) { b::f(x)} (ugly has defined in every subclasses) removing abstract method, b::f() (not acceptable) any better solution? the issue hid b::f(std::string) here: class d : public b { public: void f() override; }; when call d.f("msg") , name lookup find 1 f() in d , stop looking. first find candidate functions then perform overload resolution. since 1 happens take no argum

html - How do I make my images scaleable and at the same time maintain their aspect ratio? -

i'm working on website , i've been designing on samsung 22 inch monitor. haven't been playing resizing window, designing site window @ full screen. made image slider on homepage , noticed images in slider scale down while maintaining aspect ratio when resize window images not in slider created fit appropriately in full screen mode remain same size when i'm resizing window messes layout. haven't done css on images except changing margins there can css tell images scale images when resizing window. css code images .project-section img{ display:inline; margin-top: -18px; margin-bottom: -5px; margin-left: -8px; } css code image slider got tutorial i'm still trying understand images here scale when resizing thed window. @keyframes slidy { 0% { left: 0%; } 20% { left: 0%; } 25% { left: -100%; } 45% { left: -100%; } 50% { left: -200%; } 70% { left: -200%; } 7

ada - How to tell if a Gtk.Widget is a Gtk.Container? -

i using gtkada handle callback returns "access gtk.widget.gtk_widget_record'class". how can find out if widget gtk.container or not? thank in advance help. if widget in gtk_container_record'class ...

r - Variation on "How to plot decision boundary of a k-nearest neighbor classifier from Elements of Statistical Learning?" -

Image
this question related https://stats.stackexchange.com/questions/21572/how-to-plot-decision-boundary-of-a-k-nearest-neighbor-classifier-from-elements-o for completeness, here's original example link: library(elemstatlearn) require(class) x <- mixture.example$x g <- mixture.example$y xnew <- mixture.example$xnew mod15 <- knn(x, xnew, g, k=15, prob=true) prob <- attr(mod15, "prob") prob <- ifelse(mod15=="1", prob, 1-prob) px1 <- mixture.example$px1 px2 <- mixture.example$px2 prob15 <- matrix(prob, length(px1), length(px2)) par(mar=rep(2,4)) contour(px1, px2, prob15, levels=0.5, labels="", xlab="", ylab="", main= "15-nearest neighbour", axes=false) points(x, col=ifelse(g==1, "coral", "cornflowerblue")) gd <- expand.grid(x=px1, y=px2) points(gd, pch=".", cex=1.2, col=ifelse(prob15>0.5, "coral", "cornflowerblue")) box() i've

firefox - AppleScript - how do I select a menu item in a pop up button that has no title? -

relatively new applescript here... i'm trying create applescript automate file/save page as... action in firefox. specifically, need select "web page, complete" save as... dialog instead of default "all files" selection in pop button @ bottom of dialog box. (i'm using firefox , option because want save current html contents after javascript code has run - parse out values subsequent processing). i've been able hack way around problem selecting pop menu (which has no title) using: ((pop buttons of window "save as") description "all files") and sending key stroke "w" select "web page, complete" in pop-up menu. i'm trying find more robust way of doing instead of relying upon fact "w" selects menu item want. tried: click menu item "web page, complete" of ((pop buttons of window "save as") description "all files") but didn't work. in looking @ acces

java - Conversion to Dalvik format failed 65536 limit -

issue - unable execute dex: method id not in [0, 0xffff]: 65536 this new question. using eclipse not android studio. have read previous questions on stackoverflow , have tried sorts of solutions enabling progaurd, enabling dexjumbo, importing multidex project , jar in eclipse etc. nothing helped issue. stuck in issue 2 days. have removed unneccessary jar files libs trial , error running app. left thats necessary , still error. what trying do? i trying read docx file internal storage using docx4j on android device. have made independent app works fine. have tested reading, writing , conversion in independent projects of eclipse want integrate code onto group project, error. has 3 more other jar files required other processes. have removed 8 jars didn't change output in independent project , left 10. as per docx4j - "dalvik limit of 65536 method references per dex file more issue running docx4j on android 1 related jaxb, worth noting. we’re running close limit.&quo

Application from Android Studio won't install from signed APK, does installs fine over ADB -

i'm having problem installing application on phone, , other phones, it's apk. when load application android studio's run button on adb, installs fine no issues, when generate signed apk , sideload onto device (both debug , release), throws error saying "app not installed." i've genuinely looked everywhere answer can't find anything, has else came across before? here's video of issue https://www.youtube.com/watch?v=s1ebauldrqs here's info app. uses zxing, therefore uses phones camera, , can see video i've proper permission declared in manifest, still though measure manifest follows: <manifest package="com.android.tighearnan.frenchsscanner" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.camera"/> <uses-permission android:name="android.permission.write_external_storage" /> <uses-feature

html - Apply css rule only if previous div exists -

if have div-a , div-b , possible apply css rule div-b if div-a exists? or apply rule div-a if div-b exists? (without using jquery). <div class="box"> <div class="div-a>..</div> <div class="div-b>..</div> </div> generally, no. unless div-b child or sibling of div-a . for descendant: .div-a .div-b for direct children: .div-a > .div-b for siblings: .div-a ~ .div-b for adjacent siblings: .div-a + .div-b see child , sibling selectors . note these relations work 1 way only. in cases provided above, applied div-b, if div-b inside (child) or after (sibling) div-a. given mark-up, use sibling or adjacent sibling combinator style div-b, there no way style div-a conditionally. i think best option add class parent if contains div-b. use simple combined selector .parent-class .div-a style it.

cordova - How can I call the Blackberry API for a hosted webapp WebWorks? -

i using webworks make hosted web app, i.e. app open website url. want include native blackberry api functions (e.g. toast) app. everything working fine. include url (for example, http://www.example.com/index ) in "main url" field. , on site, have added line so can load cordova.js , use blackberry functions. but if change "main url" https https://www.example.com/index , cordova.js can't loaded anymore. on web inspector console, says [blocked] page @ https://www.example.com ran insecure content local:///cordova.js. i have tried add local:/// whitelist, , turn "enable web security" off, no avail. please advice can do. thank much! this first post of mine (also new bb dev) suggest if not correct , accept sincere appologies. giving step step hope don't offended others new bb dev see helpful them. step 0: start "blackberry 10 simulator". step 1: start "blackberry webworks 2.2.0.15" step 2: opens browse