Posts

Showing posts from July, 2013

angularjs - POSTing and PUTing a restangular object -

i trying create new restangular object, post it, modify , put it. $scope.new_message = restangular.one('messages'); // should post $scope.new_message.save().then(function(message){ $scope.new_message = message; }); // should put $scope.new_message.subject = "hello world"; $scope.new_message.save() unfortunately restangular sending put request to http:/localhost/messages/undefined/5481ebbfe252e4116a8334d0 when should be http://10.211.55.3/messages/5481ebbfe252e4116a8334d0 it seems use .one() must include id 1 of parameters. question is, how can leverage .save() functionality without using id

javascript - HTML images not aligning properly when retrieving data from JSON -

i've been making little league of legends website uses riot api retrieve mastery tree , displays images. i've have 3 divs wrapped in div, , images align correctly except last 2 rows of each div, , can't figure out why. must how handling rows null in them. i've noticed rows seem want self-align (figured out not handling null values), maybe it's inherent divs. can't link site because haven't secured api key, here's picture: http://i.imgur.com/icdxdfk.png here html: <div> <div id="offense_page" style="padding-left: 15px; padding-right: 15px; float: left; border: 5px solid white;">offense</div> <div id="defense_page" style="padding-left: 15px; padding-right: 15px; float: left; border: 5px solid white;">defense</div> <div id="utility_page" style="padding-left: 15px; padding-right: 15px; float: left; border: 5px solid white;">utility&

javascript - Focus is running before the click/change of a radio button. Is it possible to run the click/change before the focus? -

below see code working on , included jsfiddle. issue: the focus running before click/change margin moving before radio button can selected. please explain code can learn this. if not have solution hints or direction helpful. in advance! http://jsfiddle.net/nlgqhqwc/6/ html <div class="panel"> <input type="text"/> </div> <div class="panel"> <input type="text"/> </div> <div class="panel"> <select> <option>option</option> </select> </div> <div class="panel"> <input type="radio"/> </div> <div class="panel"> <input type="checkbox"/> </div> css .panel{ padding:15px; background:grey; margin-bottom:15px; } .panel-primary{ margin:0 15px 0 15px; background:blue; margin-bottom:15px; } jquery $(document).ready(functio

meteor - Distinct layouts for distinct user types -

i have 2 distinct usertypes 'reader' , 'publisher'. information stored in meteor.users document meteor.users.usertype: 'publisher' or can meteor.users.usertype:'reader' how can dynamically add elements appbody depending on usertype? the data context , things menu items of course different usertypes i have referenced https://github.com/eventedmind/iron-dynamic-template html: <head> <title>site</title> </head> <template name="appbody"> //this layouttemplate <div class="navbar navbar-fixed-top navbar-custom"> <div class = "container"> <ul class="nav navbar-nav navbar-right"> <li><a href="#">menu title a</a></li> <li><a href="#">menu title b</a></li> ***dynamically add list element depending on 'usertype' log

r - lrm function from rms package does not function -

i need cluster standard errors dyads, , trying use rms package. need fit model using lrm instrad of glm. when type library(rms) following error: error in loadnamespace(i, c(lib.loc, .libpaths()), versioncheck = vi[[i]]) : there no package called ‘mvtnorm’ error: package or namespace load failed ‘rms’, and when try use following comand cluster standard errors dyads error function lrm not exist. fit=lrm(disease ~ age + study + rcs(bmi,3), x=t, y=t, data=dataf) fit robcov(fit, cluster=dataf$id) bootcov(fit,cluster=dataf$id) and know x=t , y=t are? have started working in r , statistics in general, none of quite obvious me.

java - JComboBox Selection Change -

everyone quite new java gui, having issue jcombobox , firing when removeallitems combo box refresh it, issue because getting selected items details , populating textboxes them firing @ point getting null pointer. there simple(ish) way have method on combobox called when selected item changed not when combo box contents changed? code combobox current method private void customercomboactionperformed(java.awt.event.actionevent evt) { setdetails(); } method setting items in combo box public void setcustomers() { customercombo.removeallitems(); (customer curr : main.getnewcustomerlist().getcustomers()) { customercombo.additem(curr); } } method setting details public void setdetails() { customer selected = (customer) customercombo.getselecteditem(); forenametext.settext(selected.getforename()); surnametext.settext(selected.getsurname()); costperkgtext.settext(string.valueof(selected.getdeliverycost())); line1text.set

javascript - Mathemmatical formula for incremental breakdowns -

i have dialog displays buttons according users settings. want have buttons layed out in best sequence of rows of 6. meaning, if user entered 1-6 entries, there should 1 row of 6 buttons. if entered 7 entries, shouldn't 6 on row 1 , 1 on row 2, rather, 4 on row 1 , 3 on row 2. if entered 8, should have 4 buttons on each row , on..... being seasoned developer, feel little dumb this.... having difficulty figuring out correct method of finding out these numbers programmatically. if can me appreciate it thanks, david if a / b integer division , a % b remainder of division of a b , need rows = (buttons + 5) / 6 rows of buttons. can divide number of rows find best partitioning. if want minimize absolute difference of row lengths, i-th line (zero-based) example contain buttons_in_line[i] = buttons / rows + (i < buttons % rows ? 1 : 0) buttons. e.g. 22 buttons following layout: # # # # # # # # # # # # # # # # # # # # # # or 19 buttons: # # # # # # # #

vb.net - Tying ComboBox/NumericUpDown selections to an array? -

i'm working on vb project has lot of comboboxes , numericupdown items. lets have combobox1, 2, 3, 4, , 5; , have numericupdown1, 2, 3, 4, 5. when user clicks "save" button, want save of selected combobox items , numericupdown numbers csv file. there elegant/automatic way tie of .selectedindex , .value these items array can write array out csv? the way know far manually associate each 1 array position: arr(0) = combobox1.selectedindex arr(1) = combobox2.selectedindex ... arr(5) = numericupdown1.value arr(6) = numericupdown2.value ... etc. this wouldnt bad, except have lot of these items, , writing line each 1 seems silly. i'm new vb, might obvious solution some. ideas? having them bound array handy because allow user load csv file, automatically populate comboboxes , numericupdowns csv values. way know manually move each array item respective combobox/numeric item when click load file button: combobox1.selectedindex = arr(0) combobox2.selectedi

large actionbar title in android -

in android app, have 3-inch sized title text ( requirement our designer). i have actionbar tabs under title bar. i tried make text big using below code gets clipped off. so, not able make taller. appreciated void setcustomactionbar() { actionbar mactionbar = getactionbar(); linearlayout.layoutparams lp = new linearlayout.layoutparams( layoutparams.match_parent, layoutparams.wrap_content); mactionbar.setdisplayshowhomeenabled(false); mactionbar.setdisplayshowtitleenabled(true); layoutinflater minflater = layoutinflater.from(this); view mcustomview = minflater.inflate(r.layout.actionbar_customview, null); // actionbartitle textview mtitletextview = (textview) mcustomview .findviewbyid(r.id.actionbartitle); // lp.setmargins(0, 10, 0, 10); mtitletextview.settext("applause insights"); mtitletextview.settextsize(32); mtitletextview.setgravity(gravity.center_horizontal); mactionbar.

javascript - Get node position in D3 sankey diagram -

Image
i'm using d3 plug-in make sankey diagram, , add labels above each column of nodes. this: is there function in sankey object can return location of nodes? var sankey = d3.sankey() .nodewidth(15) .nodepadding(10) .size([width, height]); i'm following pattern here: http://bost.ocks.org/mike/sankey/

c++ - Intercepting exit() -

i have class may this: class streetsim{ public: void operator(){ //do cool things if(street_exploded) exit(5); } }; this works great small program this: int main(){ streetsim ss; ss(); return 0; } however want embed in program. not fork process child, i'm not allowed change streetsim . prefer this: int main(){ streetsim ss; int k = catch(ss()); if(k==5) fprintf("the street exploded!"); return k; } is @ possible catch program exit signal this? suspect not, perhaps gurus here might have useful tribal knowledge this.

ios - ReactiveCocoa repeat command does not use modified values -

i trying write code iterates forever, , here how have written it: - (void) testrepeat { __block dataclass * dc = [[dataclass alloc] init]; [[[[self repeatfunc:dc ] donext:^(id x) { dc = nil; }] repeat] subscribenext:^(id x) { nslog(@"next"); } completed:^{ nslog(@"completed"); }]; } - (racsignal *) repeatfunc: (dataclass *) dc { return [racsignal createsignal:^racdisposable *(id<racsubscriber> subscriber) { nslog(@"dc : %@", dc); [subscriber sendnext:nil]; [subscriber sendcompleted]; return nil; }]; } the first time code iterates, value object "dc" correct. after first call repeatfunc, setting "dc" nil, however, when iterates back, change in "dc" not reflected , still previous value. what correct way achieve above purpose? the method -repeatfunc: captures immutable reference own pointer dc , , each repeat sends reference, not local reference hav

c# - How to change default images in Windows Phone 8.1 app? -

Image
i'm trying pass certification using windows app cert kit i'm getting error due using default images tiles, splash screen , logo. i know because need replace these default images own when try change images in package.appxmanifest no option in application change these images. i've looked in wmappmanifest there no option change. does know how can access images being set? looks you're using wp 8.1 silverlight. to edit settings using gui, need double click on wmappmanifest.xaml in properties folder under solution.

python - Global name XXX is not defined on RPI interrupt -

i new python raspberry pi. below example program use gpio. problem in conditional cannot see have variables span other statements in block the entire program included example of problem code follows: turn on gpio pin 23 print uptime nameerror: global name 'uptime' not defined any suggestions? thank in advance **************************** python code ***************************************** !/usr/bin/env python2.7 import time; import rpi.gpio gpio time import sleep # lets have time delay (see line 12) gpio.setwarnings(false) gpio.setmode(gpio.bcm) # set bcm gpio numbering gpio.setup(17, gpio.in) # set gpio17 input (button) gpio.setup(23, gpio.out) ## setup gpio pin 23 out gpio.output(23,false) ## turn off gpio pin 23 define threaded callback function run in thread when events detected def my_callback(channel): global start_time, uptime if gpio.input(17): # if port 17 == 1 end_time = time.ti

javascript - ChartNew does not show item legend -

i'm facing issue couldn't find here helps me. i'm using chartnew.js possible set legend of datas in chart end user. set option in javascript, option seems nos working me. although chart works ajax request , shows results in screen, legend option seems not cooperate. can me , find out why legend not working? my entire javascript code bellow: $(document).ready(function(){ $.ajax({ type: "get", url: "<?php echo "http://".$_server['server_name']."/epedidos/dashboard/datachart/";?>", success: function(response) { var obj = json.parse(response); //console.log(obj.cidade); var valormax = obj.reduce(function(a, b) { return math.max(a, b.valor); }, 0); var scale = valormax / 10; //console.log(valormax); var ci

How to write a query contains fact in Prolog -

i implementing program need somehow add facts "prolog" query. don't know how it. example: in "prolog" database, have rule: engineer(x) :- employee(x,department_a). now want check if jack engineer, query be: engineer(jack). to make query success, there should fact as: employee(jack,department_a). in database. in program, don't want add (or assert) fact database, reason program working on distributed system department jack belongs unknown database. in other words, looking way can make prolog engine deduct based on own database , given facts (the given fact not stored in database along query). is there way how can it? suggestions appreciated. you can put facts , rules in different prolog text files if want to. , freely mix different prolog text files command line while loading. for example following: file 1: foo.p engineer(x) :- employee(x,department_a). file 2: bar.p employee(jack,department_a) then can on command l

reactjs - How do I use Jest to test a React view wired to store? -

i have react view communicates store . i've tested views , stores separately, not in combination. i followed structure documented here received typeerror . looks jest trying register store component if use dontmock . using jest cli v0.2.0 pass __tests__/unit/spec/stores/viewstore-spec.js (0.248s) fail __tests__/unit/spec/components/view-spec.react.js (0.942s) undefined ● view › defaults 0 unread - typeerror: /users/matnorri/dev/projects/matnorri/web-client/src/app/scripts/components/view.react.js: /users/matnorri/dev/projects/matnorri/web-client/src/app/scripts/stores/viewstore.js: cannot call method 'register' of undefined @ /users/matnorri/dev/projects/matnorri/web-client/src/app/scripts/stores/viewstore.js:43:31 @ object.runcontentwithlocalbindings (/users/matnorri/dev/projects/matnorri/web-client/node_modules/jest-cli/src/lib/utils.js:357:17) ... i've included believe relevant code below, can provide in entirety if necessary

c# - Unity RPC not being called -

i have been bashing head against rpc call few hours now, , despite extensive googling cannot figure out going wrong. at moment, doing testing within unity editor, (player set run in background if matters). for reason, rpc call isn't going through. there lot of stuff going on in code, important bit (i think) is: public void generatedungeon() { debug.log ("generating dungeon"); tiles = dungeon.setdungeondata(); //begin looking through every single tile for(int = 0; < tiles.length; i++) { //if our tile useful, aka not void area in dungeon if(tiles[i] != 0){ //bogus location int x = 0; int z = 0; //real world location convert.convertindextoxy(i,ref x,ref z); //wouldn't need if understood math, since don't being careful int lefttile = tiles[convert.convertxytoindex(x-1,z)]; int righttile = tiles[convert.convertxytoind

android - onOptionsItemSelected called twice -

running android 5.0 on nexus 5. app uses v4 support library 21.0.0 . minsdkversion 11 , targetsdkversion 21. i have activity deriving android.support.v4.app.fragmentactivity . have number of menu items on action bar. now, if double-tap 1 of action bar's menu items, onoptionsitemselected called twice resulting in 2 instances of menu-triggered child ctivity! , yes, menu handlers return true . i have googled this, couldn't find anything. facing bug, or have missed something? i've implemented in past, , never encountered weird behavior. ideas? not sure why happens in latest support lib, in past, views, i've used solution - private long mlastclicktime = 0; protected boolean isnotafastclick() { boolean result = true; if (systemclock.elapsedrealtime() - mlastclicktime < fast_click_threshold) { result = false; } mlastclicktime = systemclock.elapsedrealtime(); return result; } before handling click events, call met

python - Non-graphical output from pycallgraph -

i've started writing small python utility cache functions. available caching tools ( lru_cache , beaker ) not detect changes of sub-functions. for this, need call graph . there exists excellent tool in pycallgraph gerald kaszuba . however, far i've got output function-name strings. need either function-objects or function-code-hashes. what mean these 2 terms: let def foo(x): return x , foo function-object, , hash(foo.__code__.co_code) function-code-hash . what have you can see have here . below minimal example. problem have in example, can't go function name (the string) function definition again. i'm trying eval(func) . so, guess there 2 ways of solving this: proper pycallgraph.output , or otherway want directly pycallgraph. dynamically loading function function.__name__ string. import unittest pycallgraph import pycallgraph pycallgraph.output import graphvizoutput class callgraph: def __init__(self, output_file='callgraph.png'

duplicate removal - How to SQL Query records from Multiple that Equal 0? -

i have table has multiple duplicate records in first column (id records), has varying numerical data in second column. i want able identify id records have 0 of numerical records. for example table can like: id value 1 2 1 2 1 0 2 0 2 0 2 0 i want identify id 2 because values equal 0. don't want id 1 because there values > 0 sorry if isn't formatted or confusing. select distinct id table id not in (select distinct id table value <> 0) this take id in table there not row value non-zero.

java - Executing a command in terminal using php -

i trying run external command via php. want compile java file. i've tried this , this . unfortunately, in case java file doesn't compiling. what wrong in code ? exec("javac main.java"); but when compiled manually, , execute follwing command, works fine. exec("java main");

html - Prevent local caching of images, for security -

is there reliable way stop browsers caching image locally. not (just) freshness of image, rather concern sensitive images being stored on local drive. adding random url param img url suggested in similar questions not because ensures next request not last request in cache (at least understanding). need image never saved locally or @ least not accessible outside browser session if saved. you need send appropriate cache-control headers when serving response image request. see post information on standard ways in several programming languages. how control web page caching, across browsers? there alternate, , possibly more foolproof yet more complex, approach directly populate base 64 encoded images data directly img src attrbitute. far know not subject caching, there not separate http request made retrieve image. of course still need make sure page not cached, gets initial problem of serving appropriate headers primary html request.

html - How to make a div and a footer extend to the bottom of a page and not just the window? -

i've been searching on how colored div on side of page , footer go way bottom of page. i've tried sticky footer couldn't work. see i'm talking go here: http://web2.nicholls.edu/maco-web-2/habitat/workfiles/trial%20fix.html both light blue rectangle (the events background div) , footer bar go bottom of window, when scroll down,you can see content has extended down past them. here's html , css. (i apologize if code super awful, class , first website i've ever tried build. @charset "utf-8"; /* css document */ html,body { height:100%; } body { font-family: helvetica, arial, sans-serif; margin:0; } #navbar{ position:absolute; top:0px; height:88px; background-color: #314d89; width:100%; z-index:75; } #wrapper { width:90%; margin-left:auto; margin-right:auto; position:relative; height:100%;;

javascript - Exclude blank images in JQuery carousel -

i'm trying work bit of code pulls list of new book titles our library catalog , uses create jquery carousel. builds url image src each title using book's isbn number. issue not every book on new title list has isbn , don't have cover image. there can add make titles don't have cover image not added carousel? have limited jquery experience haven't been able figure out. $.each( records.hitlisttitleinfo, function () { $("<img/>").attr("src", coverurlprefix + this.isbn[0] + coverurlsuffix).attr("alt", this.author).attr("title", this.title).addclass("cloudcarousel").appendto("#carousel1"); }); $(record.hitlisttitleinfo).not( function(index, element) { var isbn = this.isbn[0] return isbn == null || isbn.length == 0; // true means it's removed }).each( { $("#carousel1").attr("src", coverurlprefix + this.isbn[0] + coverurlsuffix) .attr("a

google chrome - Enable disable Camera settings in Firefox/Safari -

i working on product uses camera access browser. need create page users if there issue can check browser camera settings. chrome browser has nice page enabling , disabling camera access permissions website. https://support.google.com/chrome/answer/2693767?hl=en was wondering if there similar pages other browsers firefox or safari?

osx - Setup MySQL 5.6 with Macports -

macos 10.10, up-to-date macports. want mysql 5.6 on port 3306. 1) installing port install mysql56-server mysql56 installs mysql56@5.6.22_0, after which mysql or which mysql56 returns nothing. so first question mysql client? 2) configuring installation script suggests do sudo -u _mysql /opt/local/lib/mysql56/bin/mysql_install_db then /opt/local/lib/mysql56/bin/mysqladmin -u root password 'new-password' which asks running server , start by cd /opt/local ; /opt/local/lib/mysql56/bin/mysqld_safe & then mysqladmin complains socket , comment --skip-networking in /opt/local/etc/mysql56/macports-default.cnf , after command goes ok. then /opt/local/lib/mysql56/bin/mysqladmin -u root -h bp.local password 'new-password' which returns error: 'host '10.0.1.9' not allowed connect mysql server' i don't know here without mysql client. , i'm kind of stuck. suggestions? macports installs mysql , derivativ

java 6 - Spring batch 3.0.2 dependency with javax.batch.runtime.JobInstance -

updates: after adding javax.batch-api-1.0.jar file, below exception gone , application running. origianl post i have been using java 6 along spring batch , integration year now. application stand alone java application using java 1.6. since version of spring batch outdated, trying update libraries today. upgraded, spring framework 3.2 4.1.2 spring batch 2.1 3.0.2 spring integration 2.2 4.1 due upgrade, added new jar file spring-retry-1.1.jar after upgrade, having below exception. caused by: java.lang.classnotfoundexception: javax.batch.runtime.jobinstance @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) it looks spring batch core 3.0.2 not support java se6 me. looks ja

php - mysql group by any one or more of several fields -

i looking group following criteria: so lets have how can group them product1,brand1,null,null,12,null,1234 product2,brand1,null,null,12,null,null product3,brand2,null,null,null,1234 product1,brand1,null,null,null,null,null (product_name , brand_name) upc or isbn or mpn or ean or model_number is possible create single select statement return these grouped values ? many in advance the short answer "no." how mysql know 1 want group in particular situation? wouldn't. need send mysql different sql query each situation. if in ui user chose group 1 thing, send mysql query group that. if chose group else, send mysql query group that. have choose in php before tell mysql do. can't expect mysql read mind , know "in case wants group x." you can, however, group fields, giving them priority. i.e. group 1 first, one, etc. like: select * products group product_name, brand_name, upc, isbn, mpn, ean, model_number but not going

java - Random Test Generator with Classes -

i'm relatively new java , i'm trying develop test generator program in class called testgenerator, randomly selects 2 questions pool of 5 multiple choice questions in string array. i've been given hints create 1 dimensional array of 2 rows, within testgenerator class, randomly populated numbers 0 4 correspond questions array testbank. call array selectednumbers. whatever numbers selected, questions asked user. want questions asked separately through different windows , @ end tells me score. of have 5 5 string array, testbank, in first column question, next 3 answer choices, , fifth column correct answer. public class testgenerator { public static void main(string[] args) { string testbank[][] = {{"what color grass?","a. green","b. red","c. pink","a"}, {"whats first month called?","a. december","b. january","c. march","b"}, {"what shape soccer ball?",&quo

html - How do I do a website with more than 1 background color? -

this got, 1 background color fill 90% of screen. have color under. position: fixed; top: 0px; left: 0px; width: 100%; height: 90%; background-color: #20a2d6;} you can find example of i'd here http://www.spelltower.com/ using html section tags colored backgrounds. it's not single element multiple background colors. javascript used resize each section browser window resized. html <div> <section id="first_section">first section</section> <section id="second_section">second section</section> <section id="third_section">third section</section> </div> css #first_section { background_color: blue; } #second_section { background_color: red; } #third_section { background_color: green; } javascript //when browser window resized... $(window).resize(function() { // new window height var windowheight = $(window).height(); //determine height want each section

ruby on rails 3 - RoR: Passing collection to partial won't work -

i'm extending open source ror project , have following problem: original programmers passed collection partial this <%= render partial: "option", collection: survey.options %> and use in partial, e.g. this <%= option.name %> all works fine , understandable when reading guide http://guides.rubyonrails.org/layouts_and_rendering.html a survey has answer_pairs (with string fields "answer1" , "answer2") , try pass them partial this <%= render partial: "table_head", collection: survey.answer_pairs %> and try use in partial _table_head.html.erb this <td><b><%= answer_pair.answer2 %></b></td> but rails gives me nameerror - undefined local variable or method `answer_pair' #<#:0x007fa07b9e0098>: app/views/surveys/_table_head.html.erb:1 could tell me why, please? when pass "as:" this <%= render partial: "table_head", collection: survey.answer_pair

css - How to ALWAYS show scrollbar in iframe in HTML5 -

is there way show scrollbar on iframe in html5, if content not overflowing? scrolling="yes " attribute doesn't work in html5. there way using css? it seems scrolling="yes" supported browsers only. judging simulation of older versions in ie 11, seems ie 8 dropped support: although attribute such recognized, value yes not—scroll bars shown when content not fit in. this change in browser practices. has nothing html5. in fact, html5 describes attribute scrolling="yes" mapping css setting overflow: scroll , misleading. modern browsers implement iframe scroll bars present, if needed accessing of content, not otherwise. using scrolling=no or overflow: hidden , can prevent scroll bars appearing, not make them appear if content fits (there no overflow). to make scroll bars appear, need make embedded document set them up, e.g. using body { overflow: scroll } in it. not matter iframe element says. scroll bars passive (and light grey),

ios - Ensure arbitrarily rotated CGRect fills another when rotation occurs -

Image
update: partially working implementation below . i've asked couple questions on here , here . the first works great determine if "image" rect sufficiently contained inside "crop" rect. second works little bit, something's off in implementation of it doesn't work. i'm looking @ problem little differently, , change behavior: when user begins rotate image, i'll run check method (below) determine if needs fixing or not. if need fixing, rather waiting until user has finished rotating it, i'd resize image simultaneously fit bounds. there simpler (or more reliable) way implement behavior? i'm going block rotation greater 35º in either direction don't have worry severe enlargements. assumptions/constraints: i'm using autolayout point of rotation center of crop rect , may or may not center of image rect. this demonstrates working square crop, user can resize whatever, imagine it's going bite me in ass more when

php - How to select data from multiple tables and display them in a json format? -

i have many of same tables. need data each of tables , bring them out in json format: [ "table1": { ["first colomn value", "second colomn value", ...], ["first colomn value", "second colomn value", ...], ["first colomn value", "second colomn value", ...], ... }, "table2": { //values table2 }, ... ] is possible make 1 request mysql? how request , php code? to in 1 request need stored procedure, iterate through result set , iterate through result. portability better off not using stored procedures, not portable. heres code modified http://php.net/manual/en/pdostatement.nextrowset.php using pdo <?php // dont forget instantiate $conn $sql = 'call multiple_rowsets()'; $stmt = $conn->query($sql); $jsonarr = array(); { $rowset = $stmt->fetchall(pdo::fetch_num); if ($rowset) { $jsonarr[] = tojson($rowset, $i); } } while (

Media query in HTML link is not linking to separate CSS file -

when use media query link multiple css files html link, full-size css file applies. i able media queries work within 1 single css file using: @media screen , (max-width: 700px) { body { /* style changes */ } however, want separate files each media query. here test code not work me: index.html <head> <meta name='viewport' content='width=device-width, initial-scale=1' /> <link rel='stylesheet' media='screen , (max-width: 700px)' href='mobile.css' /> <link rel='stylesheet' href='stylesheet.css' /> </head> <body> </body> mobile.css body { background-color:red; } stylesheet.css body { background-color:blue; } all files correctly named , saved within same folder. appreciated! this due order in linking css files. you need mobile.css classes override ones specified in stylesheet.css, include second. <link rel='stylesheet&#

ruby on rails - Assiging model reccord to more than one user -

i'm working on rails app , 1 of features lets give virtual gifts other users. one user gives gift(through gift model) user. 1 user giver(gift.giver) other user receiver (gift.receiver) my question how assign each gift 2 users, giver , receiver, can later call user.gifts_received list of gifts user received , user.gifts_given list of gifts user gave? is better have user.gifts instead of user.gifts_received , user.gifts_given? plan on using acts_as_follower gem let users see gifts given , received users follow. in past apps, when user created post, post belonged 1 user, assigned with: @post.user = current_user and how use acts_as_follower gem gifts 1 user user follows? i guessing gift model looks this: gift.rb class gift < activerecord::base belongs_to :giver, class_name: 'user' belongs_to :receiver, class_name: 'user' ... end so this, need make user model this, acts_as_follower stuff added: user.rb class user < activer

android - Clear EditText error message onActivityResult -

in android 5.0 project, have edittext widget displays errors seterror(error) method. if try clear error seterror(null) in onactivityresult callback, error persists: view not updated sure seterror(null) invoked. tried invalidate() statement after doesn't solve problem. bug of android 5.0 lollipop or there new practice clear error message? the problem present in android 5.0 (api 21) emulator not in 4.1.1 (api 16) edit : project member answered: this has been fixed internally not in aosp yet. https://code.google.com/p/android/issues/detail?id=81870

java - What is the time complexity of Collection.toArray()? -

what time complexity of method collection.toarray() ? o(n), if yes benefits offer on looping , individually assigning values in list array( beside nice , effort of course). because toarray() method abstract, speaking time complexity in general makes no sense. however, native implementations, complexity indeed o(n) . noteworthy collection subinterface of iterable . quite absurd implement iterable cannot efficiently iterated over. the fact implementation of toarray() kept open, leaving space optimizations. there may approaches faster building array using simple iteration (array copying, running in multiple threads...). however, default implementaion in abstractcollection uses exact approach mention in question.

jquery - Javascript - How next line wait to be executed after asyncronus function is done? -

i'm using filetransfer.download function phonegap plugin download files in app mobile. this function assyncronus, next lines executed without dependence of conclusion of function. my app app capture user photo server during login process, user can't moved home screen after action concluded. actual code, doesn't happen, because don't know how it. below can check code: var usuarios = json.usuarios; var filetransfer = new filetransfer(); for(var key in usuarios) { if(usuarios.hasownproperty(key)){ if(usuarios[key].tipo == "titular"){ var titular = { "id" : usuarios[key].id, "email" : $("#login-email").val(), "foto" : "images/perfil.jpg" }; localstorage.setitem('appnowa-titular', json.stringify(titular)); if(usuarios[key].foto == "1"){

osx - Simple arithmetic calculus that should be 0 returns infinity -

so...i have check values if equal. never , knew should be, debugged application , reached following conclusion -2.5f - mathf.round(1.1f) * 0.6f - (-3.1f) doest not equal 0 instead it's value -1.192093e-07 is there reasonable explanation , there workaround? need equation in format. ps: values here hardcoded variables , have other values too. problem when result should 0 here line of code: debug.log(string.format("{0} ", -2.5f - mathf.round(1.1f) * 0.6f - (-3.1f))); using unity 4.5.1f3 monodevelop 4.0.1 on os x 10.9.5. like said in comments -1.192093e-07 not infinity close zero. notice minus sign after "e". value .0000001192093 . when comparing floating point numbers should never use == , because floating point arithmetic causing kind of small errors. instead can use this: float diff = avalue - bvalue; if(diff < 0.000001f && diff > -0.000001f){ } it might idea read "what every programmer should know floating-point a

Add two selected value together, then display results JavaScript -

Image
been trying values id tags totaldiv-totaldiv1 each display results selected values, add them display values combined in real time in id tag totalall keep getting nan . <h2>£10 each</h2> <select name="iteam1" onchange="calc1()"> <option value="10">1</option> <option value="20">2</option> <option value="30">3</option> <option value="40">4</option> <option value="50">5</option> </select> <div id="totaldiv1">&pound;10</div> <h2>£10 each</h2> <select name="iteam" onchange="calc()"> <option value="10">1</option> <option value="20">2</option> <option value="30">3</option> <option value="40">4</option> <option value="50">5<