Posts

Showing posts from April, 2013

php - How to insert data into table taking table name value from form? -

<? if($_post['submit']) { $taskselect =$_post['taskoption']; $sql =array(); foreach($_post['task'] $key => $value){ $sql[] =mysql_real_escape_string($value); } $ab ="insert into" .$taskselect. "(u_id,task) values ('".$_session['id']."','".implode(',', $sql)."')"; } $asc =mysql_query($ab); ?> html is possible , i've tried no value being inserted table when i'm using table name taken form? <select name="taskoption"> <option value="today">today</option> <option value="weekly">weekly</option> <option value="month">monthly</option> </select> you miss spaces: $ab ="insert into" .$taskselect. "(u_id,task) values ('".$... should $ab ="insert " .$taskselect. " (u_id,task) values ('".$... that bein...

r - switch() based on two vectors -

i building function run inflation adjustment based on year. function have like cci <- function(cost, year){ switch(year, '2009' = cost, '2010' = cost/1.01298, '2011' = cost/1.0455, '2012' = cost/1.07334, '2013' = cost/1.10387, '2014' = cost/1.13042, '2015' = cost/1.16645) } it works fine if feed 1 set of data, cci(100, '2010') . want run vector, cost year 1 100 2010 2 300 2015 3 222 2012 it rises error saying switch() expr can length of 1. i tried sapply() returns me table. cci <- function(cost, year){ sapply(year, switch, '2009' = cost, '2010' = cost/1.01298, '2011' = cost/1.0455, '2012' = cost/1.07334, '2013' = cost/1.10387, '2014' = cost/1.13042, '2015' = cost/1.16645) } r>...

[MS VS 2013]C++ fail on delete operator "Debug Assertion Failed!" -

i getting error when try complie (trivial, attached below) code: debug assertion failed! program: ......\project1.exe file: f:\dd\vctools\crt\crtw32\misc\dbgdel.cpp line: 52 expression: _block_type_is_valid(phead->nblockuse) so, here code: class t1 { private: int* foo; public: t1() { foo = new int[4]; foo[0] = 1; foo[1] = 2; foo[2] = 3; foo[3] = 4; } ~t1() { delete[] foo; } }; int main() { t1 t1; t1.~t1(); } while kinda ugly , incomplete, unquestionably correct. wrote 1 after experiencing exact same error code performing more sophisticated memory management, see going on. still no clue whats wrong, though. no compiler errors/warnings, no linker errors/warnings. error occurs when execution reaches delete[] foo; line. as if not insane enough, program executes fine when switch solution configuration debug release - execution reaches end of main function no er...

Java: switching between binary and decimal "modes" on a calculator -

i've created 2 separate convoluted calculators, 1 calculates decimal numbers , calculates binary numbers. the user inputs equation want calculated on command line , result printed. >1+1 >2 or binary >0b111 + 0b101 >0b1100 what i'm having trouble being able switch between calculating binary , decimal numbers on fly. i'd make work this: (by default in decimal mode) >1+1 >2 >bin >0b111 + 0b101 = 0b1100 >dec >5 * 10 >50 >exit (while typing exit @ point exit program) is there way can pull off? //decimal calculator import java.util.*; public class decarithmetic { public static void main(string[] args) { scanner input = new scanner(system.in); while(true) { string equation = input.nextline(); if (equation.equalsignorecase("exit")) { system.exit(0); } equation = equation.replaceall("\\s+","...

asp.net - upload image in registration form in asp mvc -

i want save model in database , upload picture server want when hit save button my view model is: public class postviewmodel { public int postid { get; set; } [required] [stringlength(255)] public string address { get; set; } [required] [stringlength(255)] [display(name = "title")] public string posttitle { get; set; } [required] [display(name = "full text")] public string postcontent { get; set; } [stringlength(30)] [display(name = "image")] public string postimage { get; set; } [display(name = "date")] public datetime createdat { get; set; } public virtual ilist<tagcheckbox> taglist { get; set; } } and create.cshtml : @model first.areas.admin.viewmodels.postviewmodel @using (html.beginform("create", "posts", formmethod.post, new { enctype = "multipart/form-data" })) { @html.antiforgerytoken() <div class="row...

less - webpack output css file -

i'm trying webpack output css file less instead of inline styles. i've been using extract-text-webpack-plugin . i've set based on documentation , have had @ similar questions on stackoverflow can't figure out why below webpack config file not outputting file or putting in index.html var webpack = require('webpack'); var extracttextplugin = require('extract-text-webpack-plugin'); module.exports = { entry: [ 'webpack/hot/only-dev-server', './app/main.js' ], output: { path: __dirname + '/dist', filename: 'bundle.js' }, module: { loaders: [ { test: /\.js?$/, loaders: ['react-hot', 'babel'], exclude: /node_modules/ }, { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, { ...

winforms - How to display text in a TextBox on a Windows Form C# -

there several answers online question none of them have answered question. have windows form has list of details of user, of data can edited while cannot. want 'getusername()' (which returns username) , display in textbox // display student details form public void displaystudent() { studentdetails sd = new studentdetails(); sd.showdialog(); } the above creates new form contains several labels , textboxes, when created (and displayed), textboxes on form should populate contain student information (such username, name, address etc) private void displayusername_textchanged(object sender, eventargs e) { displayusername.text = displayusername.text = s.getusername(); } s student object the above code, wish take username student object , display in textbox user see , possibly edit. try code note specify text displayusername box given after i've created object , x merely whatever have ensuring instance ha...

javascript - changing variable with prompt -

i'm working through odin project curriculum , stuck on sketchpad project. assignment create grid jquery, have squares fill in when hovered over, , have button clears area , gives option change # of squares in area. in code trying change number of squares in grid input prompt, variable isn't changing after enter different number prompt. my javascript- $(document).ready(function() { //create table var area = 16; for(i=0;i<area;i++) { $('table').append('<tr></tr>') }; for(i=0;i<area;i++) { $('tr').append('<td></td>') }; //fill in background when hovered on $('td').hover(function() { $(this).addclass('fill') }); //clear pad when button clicked , set new area $('button').click(function() { $('td').removeclass('fill') var input = prompt("enter desired area of new sketchpad (ex. \"16\" 16x16 grid, \"64\" 64x64 grid)",...

java - How to include JAR dependency into an AAR library -

summary: i have aar file depends on jar file, when build aar project, doesn't contain jar code. details: i have java sdk library project contains code use java web projects , such, library created using gradle , resides in internal nexus server (as jar). the goal provide "android configured" version of jar library through aar library multiple android applications can use , minimize effort (and boilerplate code) implement it. aar file uploaded nexus server used android application projects. my aar project includes gradle dependency java sdk library (the jar) when built, aar doesn't include classes it. code: this java sdk project's gradle file: apply plugin: 'java' //noinspection groovyunusedassignment sourcecompatibility = 1.7 version = '1.1.1' repositories { mavencentral() } jar { { configurations.compile.collect { it.isdirectory() ? : ziptree(it) } } } dependencies { testcompile group: 'junit...

java - JSP Delete Row from MySQL -

i generated list of people in jsp using mysql , problem how should delete them. code: jsp: <% applicantdao applicantdao = new applicantdao();%> <% (int = 0; < applicantdao.viewapplicant().size(); i++) {%> <div class="column"> <div class="col-sm-3 col-xs-4"> <div class="list-group"> <a class="list-group-item active"> <img src = "th_1x1.jpg" class = "img-responsive" alt = "responsive image" width = "100%" height ="100"> <h4 class="list-group-item-heading" id="guardname<%=+i%>" id="guardname<%=+i%>"><%=applicantdao.viewapplicant().get(i).getapplicantfirstname() + " "%> ...

javascript - Can not build V8 for Android on Mac -

i tried following steps build v8 android. 1.install depot_tools git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git export path=`pwd`/depot_tools:"$path" run “fetch v8” download code , dependencies. cd v8 , run “make ia32.release” build. make android_arm.release -j16 android_ndk_root=[full path ndk] step 3 build , got libraries. while 4 failed because can't find standard headers. /users/philip/v8/third_party/llvm-build/release+asserts/bin/../include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found #include_next <stdio.h> ^ in file included ../src/api.cc:5: in file included .././src/api.h:8: in file included .././include/v8-testing.h:8: in file included ../include/v8.h:20: /users/philip/v8/third_party/llvm-build/release+asserts/bin/../include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found #include_next <stdio.h> ^ in file included ../src/asmjs/asm-wasm...

javascript - Expand all grid rows by default with rowexpander - EXTJS 5 -

i using rowexpander plugin in grid. to expand , collapse rows use rowexpander override: https://www.sencha.com/forum/showthread.php?280175-issue-with-expand-all-when-using-rowexpander-bufferedgrid however, grid must have on render rows expanded. i tried solution of following fiddle, without success, giving error: "uncaught typeerror: cannot read property 'hascls' of null" any idea how solve this? fiddle: https://fiddle.sencha.com/#fiddle/10bg edit: remove comments on lines 99 , 100. you can try using viewready event (instead of afterrender ): fires when grid view available (use selecting default row). working example: https://fiddle.sencha.com/#fiddle/10bt

node.js - Strongloop file upload - conflicting containers during simultaneous uploads -

i'm developing application on strongloop has multiple image uploads. i'm using loopback component-storage uploading files using rest api. the containers dynamic (client app sends unique container ids) , i'm creating folder container within 'beforeremote' using container id. have application logic inside 'afterremote'. recently faced strange issue image uploading under 1 container gets overridden image upload happens under different container id. rare issue came across twice. beforeremote method: mymodel.beforeremote('upload', function (ctx, res, callback) { var arrstr = ctx.req.url.split(/[//]/); var mkdirp = require('mkdirp'); var path = '../storage/images/' + arrstr[1]; //arrstr[1] container folder mkdirp(path, function (err) { console.log(err); }); callback(); }); afterremote method: mymodel.afterremote('upload', function (ctx, res, callback) { var mainlogics = func...

java - Activity class does not exist? -

Image
i trying make game switches activity whenever user clicks button. trying use application class use variable throughout of activities, variable current time in milliseconds when app starts. then, in game on screen want find current time again, , subtract currenttime new current time. should give me amount of time user has been playing game. after finding value; want display on screen. problem is, getting following error: starting: intent { act=android.intent.action.main cat= [android.intent.category.launcher] cmp=com.example.username.buttonsmasher/.main_menu } error type 3 error: activity class {com.example.username.buttonsmasher/com.example.username.buttonsmasher.main_menu} not exist. here main_menu oncreate activity, set currenttimemillis variable currenttime, mycurrenttime class: here gameover screen display total time spent on app: here android manifest file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=...

c# - Regex returning only portion of a string -

i have following regex string: (@model.[a-z]*) i'm trying use pull values razor view email. have following values: @model.firstname @model.company i expect following code return these values in list: regex.matches(emailstring, "@model.[a-z]*").cast<match>().select(match => match.value) instead list of same value "@model." missing here? the values can contain both lowercase , uppercase, therefore regexp should be: (@model\.[a-za-z]*) ... or can put regexoptions.ignorecase option apply model part.

ruby on rails - count number of records with matching values associated with a specific record -

i have model x has_many models y. y has field called 'type', can a, b, or c. know on show view x, can use: <%= @x.ys.count %> to return number of y objects associated instance of x. or, can use: <%= y.group(:type).count["a"] %> to return total number of y objects of type a, across x objects. what if want return number of y objects of type associated particular instance of x, such @x particular instance show view being accessed? edit: the ys method defined within x.rb such: class x < activerecord::base has_many :fs has_many :gs has_many :f_ys, through: :fs, source: :ys has_many :g_ys, through: :gs, source: :ys def ys f_ys + g_ys end end could fact 'through' relationship interfering ability access methods 'where'? it should simple as: <%= @x.ys.where(type: 'a').size %> if ys method returns array instead association, can tweak this: <%= @x.ys.select{|y| y.type == ...

linux - Capture top command to file -

i want capture output of top file there problem, output same. example, code below grabs %cpu returned top command. problem everytime execute code shows same %cpu usage, why? top -n 1 | awk '/^%cpu\(s\)/ {print $2}'

ios - How to tell if currently selected tab was pressed again? -

i assign action if user attempts select selected tab. for example, if tab 1 selected , user tries select tab 1 again, want make app something. are there uitabbarcontroller methods intercept attempt? i've looked through uitabbar , uitabbarcontroller , , uitabbaritem apis , can't find obvious. you have set uitabbarcontrollerdelegate . - tabbarcontroller:shouldselectviewcontroller: method can check self.selectedviewcontroller against view controller passed in. if same, selected being selected again.

Ansible execute each role in different host -

my intention execute each role in different host. doing simple task of downloading files in each host. have host file looks so [groupa] 10.0.1.20 [groupb] 10.0.1.21 below main_file.yml file --- - hosts: local connection: local gather_facts: no roles: - oracle - apache structure of roles main_file.yml roles |-- oracle | |-- tasks | |-- main.yml | |-- download_file.yml |-- apache | |-- tasks | |-- main.yml | |-- download_file.yml oracle/main.yml --- - name: downloading file in groupa hosts: groupa tasks: - include: tasks/download_file.yml oracle/download_file.yml --- - name: download file shell: wget http://dummyurl.com/random.sh same steps followed apache role "groupb". when execute main_file.yml getting below error error! no action detected in task. indicates misspelled module name, or incorrect module path. error appears have been in '/etc/ansible/roles/oracle/tasks/main.yml':...

xaml - Getting rid of strange margin above pivot in WP8.1 -

i have frustrating problem. have wp8.1 app (winrt - universal) in use pivot control , above have search button (screen here: http://oi67.tinypic.com/2r5s13d.jpg ). search button in grid.column 0 , pivot in grid.column 1, have strange margin (marked on screen) can't rid of , covers search button (only half of active). grid.column 1 , pivot should start on line closer word "test" , theoretically is, second line (higher one) shouldn't there, it's there, it's empty it's prohibit search button tapped. in header template have following code: <pivot.headertemplate> <datatemplate> <grid> <textblock text="{binding}" fontsize="20" margin="0,3,0,0" fontweight="normal"/> </grid> </datatemplate> </pivot.headertemplate> can me? try add margin inside pivot control etc. margin="0,-20,0,0" , add pivot ...

php - Updating from Null to something and vice versa through IF/ELSEIF/ELSE? -

i making php script use if/elseif/else statement. have table column null(empty) field , trying store column when user decides not click submit button , clear column field when user submits. $field storing specific column. if($field == null) { $sql = mysqli_query("update table set = 'something' id='1'"); if(isset($_post["x"])) { $sql = mysqli_query("update table set = null id='1'"); } else { echo "null1 error"; } } elseif (!empty($field)) { if(isset($_post["x"])) { $sql = mysqli_query($db_conx, "update table set = null id='1'"); } else { echo "null2 error"; } } else { echo 'error'; } the problem while want @ end $_post happens elseif statement , if don't refresh page(to test) , hit submit button $_post comes if statement. doing wrong here? ps: more specific on doing user gets f...

render a gvc (graohviz) from c++ console application / or qt gui application -

i writing programme can generate dot desctiption file directly on screen. i got following code graphviz.org on how use library , works int main(int argc, char *argv[]) { agraph_t* g; gvc_t* gvc; gvc = gvcontext(); /* library function */ file* fl; file* ot; ot = fopen("/home/test.png", "w"); fl = fopen("/home/my.gv", "r"); g = agread(fl,0); gvlayout (gvc, g, "dot"); /* library function */ gvrender(gvc, g,"png", ot); gvfreelayout(gvc, g); /* library function */ agclose (g); /* library function */ return (gvfreecontext(gvc)); } when run qt console application project, gives press <return> close window... i can see generate test.png file. thinking there must way can show gvc directly without opening png file, right? because writing gui application scratch seems awesomely bad idea, how using external program achieve this? you can launch within...

namespaces - How do you use namespacing with php packages and phpunit? -

edited add code mainclass requested in comments. i'm trying learn how make php packages , how use phpunit @ same time, may using wrong terminology here , doing wrong.. everything works expected when import package composer. decided add unit tests started see how useful me having trouble , suspect has namespaces i'm not sure. i have put tests in own directory , used use statements @ top of test classes importing main src classes. so, example, in test class have following: use myname\package\mainclass; use myname\package\resources\resource; use myname\package\resources\extendedresource; class resourcetest extends phpunit_framework_testcase { public function testartistisresource() { $resource = '\\myname\\package\\resources\\resource'; $main = new mainclass('artist'); $artist = $main->find(1383508); $this->asserttrue($artist instanceof $resource); } } this test passes. running same code outside of tes...

java - Data retrieval optimization using AOP in a REST service -

i'm implementing rest service using spring mvc (spring boot) , i'm creating aspect s handle cross functionalities of service. an example service method this: public void dosomethingwithuser(int userid){ // retrieve user db , something... } and in aspect class method this: @around("execution(* com.test.myrestsvc.services.myservice.dosomethingwithuser(..))") public void arounddosomething(proceedingjoinpoint pjp) throws throwable { // retrieve user (the same retrieved in method) , else... } as can see, have 2 methods doing different things same user object, have execute same query 2 times if user retrieved in main method. note methods in service layer have several aspects triggered single method invocation, multiply user retrieval several times. so i'm wondering: there way share objects @ least among aspects in rest (stateless) application? can suggest different approach minimize data access in these situations? you can try use spr...

optimization - Table access vs function call + conditional determination: which is faster? -

i need check if particular string 1 of set of predetermined strings. two methods came mind: setting table return true on particular value local isparticular = { [string1] = true, [string2] = true } print(isparticular[string1]) -- true print(isparticular[randomstring]) -- nil -> false or setting function check conditional determination function isparticular(s) return s == string1 or s == string2 end print(isparticular(string1)) -- true print(isparticular(randomstring)) -- false from understand table method take same time both of particular strings , different strings, while function call because of short-circuit evaluation take less time string1 , more time string2 , randomstring . also, both function call , table access known causing little overhead, maybe short-circuit evaluation can make difference (in being slower think, considered have more 2 particular strings , of times string won't match of them). so method should use? a hash-tab...

functional programming - Haskell- War card Game -

one of rules i'm trying program is: when 2 players play cards of equal rank, triggers “war”. each player sets down 3 cards, , flips 1 more card. whoever wins between these last 2 flipped cards gets take cards in round, including 3 cards set down each player. if flipped cards match again, war triggered, resolved in same way. i can implement first round of war inside code, part stuck when second round of war initiated when 2 players same card again. trouble having when second round of war initiated, 2 players put aside cards first war , whoever whens second war gets cards second war , first war. don't know understand how make war function store first round of cards, can see in otherwise dropped cards first round. war :: ([int], [int]) -> ([int], [int]) war (x:xs,y:ys) | head(drop 3 xs) > head(drop 3 (ys)) = (drop 4 (xs) ++ player1pot (x:xs) ++ player2pot (y:ys), drop 4 (ys)) | head(drop 3 xs) < head(drop 3 (ys)) = (drop 4 (xs), drop 4 (ys) ++...

node.js - Firebase custom token authentication (firebase version 3) -

i have authentication server (nodejs) authenticate user , create custom firebase token var token = firebase.auth().createcustomtoken(userid); i used able verify user token (previous version), not simple... i decoded userid token firebase.auth().verifyidtoken(token).then(function).... does not work server generated custom tokens. does know how done? you should using jsonwebtoken validate token in case. need pass firebase private key additional parameter. var jwt = require('jsonwebtoken'); var fbprivatekey = //your firebase key string here jwt.verify(token, fbprivatekey, { algorithms: ['rs256'] }, function(err, decoded) { console.log(decoded); //your token info available here. }); update: you have use private_key .json config file set in firebase.initializeapp({ , use library convert key public pem format . can use node-rsa trick var nodersa = require('node-rsa'); var fbprivatekey = //key .json file. var key = new n...

angularjs - Angular 2 Testing Issue -

whilst attempting run integration tests angular 2 , karma test runner following issue became clear. test passing when should have been failing. issue occurs when expect() method placed inside subscribe() method of observable. need arose test subscribe observable , continue processing rest of test before observable has finished executing. however, placing expect within subscribe() method automatically causes test pass when there obvious syntax errors: it('should pass or fail', inject([service], (_service : service) => { let result = _service.returnobservable(); result.subscribe((sfasdasdaa23231gr) => { expect(r.isafhahzdzd vailable).not.35q6w623tyrg /.0824568sfn tobe(truddidididdie); }); })); the previous code passes, how? there syntax errors everywhere. know issue lies? in testing or in subscribe() method? because it's asynchronous processing, should add async method: it('should pass or fail'...

import Python plugins from a folder -

i want put python script module script pil on server. server might not have pil installed. (this why want load file myself) if possible, how can have python script import image library current directory of script without having installed on machine? using python virtual machine using v2.7 of python locally, on server. one option import modules relative path described here . it possible use virtual environments pack need , don´t mess python installations on server. here , here other references: loading modules in folder in python how relative imports in python?

javascript - JS: Modify Value/Pair in JS Object -

i'm trying work out best way modify object without writing out similar object 3 times. have these 3 objects: var object1 = { start: start, end: end, type: 1 } var object2 = { start: start, end: end, type: 2 } var object3 = { start: start, end: end, type: 3 } the thing changes type. there better way write i'm not repeating myself? you can set common properties prototype object. example: function objectmaker (typeval) { this.type = typeval; } objectmaker.prototype.start = "start"; objectmaker.prototype.end = "end"; var object1 = new objectmaker("1"); var object2 = new objectmaker("2"); gives > object1.start "start" > object1.end "end" > object1.type "1" you pass in object maker function if number of variables more. since prototype shared across objects, have lighter memory footprint having same on each object.

Twain driver concurrent requests -

Image
it's possible use 1 twain driver manage concurrent request 2 different multifunction printer? i mean, if have 2 mfps , can 2 scan request in paralel using same twain driver? it depends on if driver supports it. from twain spec page 125: if application attempts connect source supports single connection when source opened, source should respond twrc_failure , twcc_maxconnections. also spec on page 212: source responsible managing this, not source manager (the source manager not know in advance how many connections source support). i tested fujitsu fi-7260 scanner , got twcc_maxconnections error twacker:

javascript - Value substitution while accessing nested json object -

this json object { "a1": { "b1": { "name": "tim", "status": "completed" } "c1" { "field1": "name", "field2": "status" } } i need access value tim getting field key within c1. example, need value of a1.c1.field1 gives me value name1 , need access value tim a1.b1.(value of a1.c1.field1) not know how this. can give possible ways accomplish this? var a1 = { "b1": { "name": "tim", "status": "completed" }, "c1": { "field1": "name", "field2": "status" } }; console.log(a1.b1[a1.c1.field1]); do fix error in json ;)

eBay API - addItem ShipToLocation save only last value -

this first contact ebay api , have problem @ beginning. coding in python , trying call additem, cant define international shipping options. i send item domestic 2.50gbp, , international asia, japan, australia 20gbp , europe, europeanunion, germany 10gbp. , have no idea how declare it... what tried far? "shippingdetails": { "globalshipping": "true", "shippingtype": "flat", "shippingserviceoptions": { "shippingservice": "uk_othercourier", "shippingservicecost": "2.50", }, "internationalshippingserviceoption": { "shippingservice": "uk_royalmailairmailinternational", "shippingservicecost": "10", "shiptolocation": "europe", "shiptolocation...

apache - How to Install mod_wsgi in a virtual Environement -

introduction i have web api writtten in python 3 , uses flask. code runs fine when run web api terminal , hosted following line in code. if __name__ == '__main__': app.run(host='', port=8010, debug='true') current situation the code runs , want set on apache server. apache server has websites built using python 2 , need mod_wsgi python 2. i looked if there way set both mod-wsgi on apache server according following source can't mod_wsgi python 2 python 3 on 1 apache server attempt @ solution i 'm trying install mod-wsgi virtual environment. downloaded package here , tried install environment after activating it. i ran sudo python setup.py install terminal got error below file "setup.py", line 139, in 'missing apache httpd server packages.' % apxs) runtimeerror: 'apxs' command appears not installed or not executable. please check list of prerequisites in documentation package , install mis...

angularjs - Add Controller outside of View -

i using requirejs alongside angularjs , want give body controller. the important elements nav , .container . now, .container changes automatically route, want give navigation controller can change current active tab. don't understand, however, how give nav controller static element , isn't loaded alongside route , loaded before async scripts (angular, etc...) have loaded, can't use ng-controller directive. if you're using ui-router, create abstract state under exists app. clarify, nav still part of app, primary application sit underneath ui-view directive. edit can read abstract states on documentation page . bonus, if use controlleras, child controller prototypical inherit properties of parent. keeps application scope open, nice , clean.

mysql - Join vs subquery to count nested objects -

let's model contains 2 tables: persons , addresses. 1 person can have o, 1 or more addresses. i'm trying execute query lists persons , includes number of addresses have respectively. here 2 queries have achieve that: select persons.*, count(addresses.id) number_of_addresses `persons` left join addresses on persons.id = addresses.person_id group persons.id and select persons.*, (select count(*) addresses addresses.person_id = persons.id) number_of_addresses `persons` and wondering if 1 better other in term of performance. the way determine performance characteristics run queries , see better. if have no indexes, first better. if have index on addresses(person_id) , second better. the reason little complicated. basic reason group by (in mysql) uses sort. and, sorts o(n * log(n)) in complexity. so, time sort grows faster data (not faster, bit fast). consequence bunch of aggregations each person faster 1 aggregation person on data. t...

javascript - logo will change when scroll down -

i'm kinda stuck doing this, need :) i working on project in shopify and here problem on site: scroll down bit, navigation menu appear heritage logo [black] white background. open shop button scroll up, white background of navigation should remain along heritage logo [black] plus search icon [black] scroll down bit, navigation menu appear heritage logo [black] white background. open shop button close it, heritage logo [black] should remain white background plus search icon [black] you can test work here jsbin or if want see live website: click here , password is: chough please let me know further information needed, understand better. thanks in advance :) javascript & html $(document).ready(function(){ //jquery.scrollspeed(50, 800); $('#shop-menu-dropdown').on('click', function (e) { if($('.livery-collection-menu-container').hasclass('hide')) { $('.sticky-target-menu').ad...