Posts

Showing posts from July, 2011

python - Sqlalchemy detect change in table -

in thread check whenever particular value in database table changes. this: def my_background_thread(): while true: check_for_changes_to_database if change: do_something() i'm using mysql , sqlalchemy . sqlalchemy provide way this? sqlalchemy events do_something() can registered listener of sqlalchemy's 'set' event 'changes' in database. eg. listen('changes', 'set', do_something)

Magento customer and order tracking -

i new in magento. when hit site tracking parameters: www.yoursite.com?utm_source=abc&utm_medium=def&utm_content=ghi&utm_campaign=jkl&utm_term=mno , parameters saved session , cookie. when customer signes up, tracking string saved in customer_entity_varchar table attribute customer_campaign_params . when customer places order, tracking string saved in sales_flat_order table in order_campaign_params column. tracking string looks that utm_source=abc|utm_medium=|utm_content=|utm_campaign=|utm_term= but saves data string in 1 field want save data separately in 5 different fields separately. tried unable that. please see code data.php class robm_tracking_helper_data extends mage_core_helper_abstract { const customer_campaign_params = 'customer_campaign_params'; const tracking_cookie_lifetime = 15552000; public function getcampaignparamsarray() { $request = mage::app()->getrequest(); $campaignparams = array(

Return an Array of Strings from an ASP.NET Web Service to an Android client using SOAP -

i want return array of strings android client , populate listview. using soap library (org.ksoap2.*) invoke asp.net web service. here code web service: 1. asp web service imports ... imports system.web.services imports system.web.services.protocols imports ... <webservice(namespace:="...")>_ <webservice(conformsto:=...)> _ <global.microsoft.visualbasic.compilerservices.designergenerated()> _ public class enquiryws inherits system.web.services.webservice ' web method <webmethod()> _ public function getlist() string() 'hardcoded list return new string() { "item1", "item2", "item3" } end function i've tested web service accessing asmx, there no runtime errors. i've tested simple string, web service returned string android. this: ' web method <webmethod()> _ pu

how to make a note with implementation in a UML class-diagram in visual paradigm -

Image
i have been looking around ages, not find way link uml note operation of class or display provided implementation in specification of operation. idea illustrated in picture. i tried add implementation operation, don't manage make appear in diagram. tried making note , connecting method, leads unclear floating line-ends. if let me know how achieved visual paradigm or let me know impossible, nice. thanks in advance. i have no idea how or whether possible vp (i know sure can't enterprise architect pretty uml2.x compliant). hook link near position in appropriate compartment (ea has feature lock connector @ position of element). edit have looked superstructures 2.5: comment [class] description a comment textual annotation can attached set of elements. so want not uml compliant. comment can attached element. attributes/operations not uml elements.

javascript - FormValidation on modal bootstrap -

i have modal so <div id="mymodal" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h2 class="page-title"> add movie <small>note fields marked <span style="color:red">*</span> required</small> </h2> </div> <div class="modal-body"> <form class="form-horizontal" role="form" id="newmovie"> <div class="form-group"> <label class="control-label col-sm-4" for="prefix"> title <span style="color:r

Is there any ntpd that can be configured to listen to selected interfaces only? -

my situation is, configure many virtual network interfaces virtual machines , of networks have 2 or more addresses. don't need ntpd listen these interfaces, there seems no option restrict interfaces ntpd tries bind to. besides these "security" options in ntpd, system administrator, knows environment, best security option not listen @ interfaces. example more secure not listen external interfaces @ all, restrict access through ntp configuration. is there ntpd software known can configured listen selected interfaces (as network daemon should) ? there 2 easy ways this, both documented in official ntp documentation: use -i command line option ntpd invocation -i [address | interface name] open network address given, or addresses associated given interface name. option may appear multiple times. option implies not opening other addresses, except wildcard , local‐ host. option deprecated. please consider using configuratio

How to add sidebar at single.php in Wordpress -

i'm having problem when comes adding sidebar @ single.php. included <?php get_sidebar(); ?> but seems appear below , content(blog post) still @ middle of whole page. i've tried check of previous forum none of them helped me figure out. here's single.php <?php /** * template displaying single posts. * * @package tesseract */ get_header(); ?> <div id="primary" class="full-width-page"> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'single' ); ?> <?php tesseract_post_nav(); ?> <?php // if comments open or have @ least 1 comment, load comment template if ( comments_open() || get_comments_number() ) : comments_template(); endif; ?> <?php comments_template(); ?> &

jquery - PickMeUp date picker - disable array of dates -

i using pickmeup datepicker selecting multiple dates. able pass array of dates, disable these dates , display them in different colour. i have following code: $('.multiple').pickmeup('clear'); $('.multiple').pickmeup({ flat: true, mode: 'multiple' }); if knows how this, highly appreciate it. what need load dates array. can check array pickmeup 's object render event , check every date against dates array. if of dates coincide, return object disabled: true , user won't able select dates. additionally, return class disabled improve disabled dates' css colors. because pickmeup 's default color-scheme disabled dates black; makes hard see them. the following javascript/jquery achieves want: // creating 'sample' dates var datesarray = []; var d = new date(); (i = 2; < 7; i++) { var tempday = new date(); tempday.sethours(0,0,0,0); tempday.setdate(d.getdate()+i); datesarray.push(tempda

osx - To use XCode for Perl Scripts -

minimum script practicing conversion of terminal scripts perl , using them in xcode use strict; use warnings; ## conversion of one-liner script perl -mo=deparse # original command: perl -ne 'print unless /[0-5]/' input.txt > output.txt # got following command from: perl -mo=deparse -ne 'print unless /[0-5]/' # notice: -e syntax ok while (defined($_ = <argv>)) { print $_ unless /[0-5]/; } input.txt > output.txt i set settings described in answer running perl in xcode . however, unsure should have here in parameters. set nothing there. confused sentence: go arguments tab , ensure main script first argument. add more arguments , environment variables necessary. i run script , following 0_dyld_start message in osx yosemite 10.10.3, similar here in python dyld`_dyld_start: -> 0x7fff5fc01000 <+0>: popq %rdi 0x7fff5fc01001 <+1>: pushq $0x0 0x7fff5fc01003 <+3>: movq %rsp, %rbp 0x7fff5fc01

c# - Asp.net MVC Oauth session expiring quickly -

i learning open authentication in asp.net mvc app. login via facebook , google working fine on deployment session expiring quickly. due application pool recycle. in local system working fine. i faced same issue earlier form authentication, changing session state mode "state server" "in proc" worked it. how same open auth? i have set high values session timeout app.usecookieauthentication(new cookieauthenticationoptions { authenticationtype = defaultauthenticationtypes.applicationcookie, loginpath = new pathstring("/account/login"), provider = new cookieauthenticationprovider { onvalidateidentity = securitystampvalidator.onvalidateidentity<applicationusermanager, applicationuser>( validateinterval: timespan.fromminutes(30), regenerateidentity: (manager, user) => user.generateuseridentityasync(ma

android - Login using Facebook login button and start a new activity -

i want start new activity after facebook login. want application have facebook login button , after login enter in other activity, in tutorial after click on login button logout button appears , don't want logout button appear. code. using facebook-android-sdk 4.1.2 test new activity class.i want open after facebook login. textview info; private loginbutton loginbutton; private callbackmanager callbackmanager; string name; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); facebooksdk.sdkinitialize(getapplicationcontext()); callbackmanager = callbackmanager.factory.create(); setcontentview(r.layout.fb_button); info = (textview)findviewbyid(r.id.info); loginbutton = (loginbutton)findviewbyid(r.id.login_button); loginbutton.setreadpermissions(arrays.aslist("public_profile, email, user_birthday, user_friends")); loginbutton.registercallback(callbackmanager, new facebookcallback<loginresul

imap - imap_open showing 500 Internal Server Error in php -

i using following script access email php. $inbox = imap_open($hostname,$username,$password) or die('cannot connect email account: ' . imap_last_error()); its working in windows server perfectly. but in linux server showing following error "networkerror: 500 internal server error". any 1 have solution this?

regex - Indent and wrap consecutive matching lines with string -

i convert predictably-formatted file containing code snippets markdown. file looks this: my code snippets 2015-05-01 file contains useful code snippets every day usage in linux command line. sed sed 's/\(.*\)1/\12/g' # modify anystring1 anystring2 sed '/^ *#/d; /^ *$/d' # remove comments , blank lines sort sort -t. -k1,1n -k2,2n -k3,3n -k4,4n # sort ipv4 ip addresses ... lines starting sed or sort (lowercase - may have whitespace in front) should wrapped ``` (markdown starting / ending code markers), indented 4 spaces , have 1 blank line before , after section. consecutive lines sed or sort should wrapped inside same coding section. final markdown file should this: my code snippets 2015-05-01 file contains useful code snippets every day usage in linux command line. sed ``` sed 's/\(.*\)1/\12/g' # modify anystring1 anystring2 sed '/^ *#/d; /^ *$/d'

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -

when running map reduce job in mac terminal as: pawandeepsingh1$ hadoop jar maximumtemperature.jar exception in thread "main" java.io.ioexception: mkdirs failed create /var/folders/v1/lyx_f0rj615cy8s54_bk053h0000gp/t/hadoop-unjar3698429834837790177/meta-inf/license @ org.apache.hadoop.util.runjar.ensuredirectory(runjar.java:128) @ org.apache.hadoop.util.runjar.unjar(runjar.java:104) @ org.apache.hadoop.util.runjar.unjar(runjar.java:81) @ org.apache.hadoop.util.runjar.run(runjar.java:209) @ org.apache.hadoop.util.runjar.main(runjar.java:136) i have seen similar question says don't have permissions run job. can give me step wise solution. thank in advance you don't have permission on hdfs filesystem create dirs job. submitting cluster or running local testing environment. can su user has perms /var folders on hdfs? if aren't admin on cluster need have admin either add group ( hdfs, hadoop) have permissions on hdfs or give p

javascript - Equivalent of express app.get("/:users/:names") in yaml for PHP? -

you know how in node.js/express/mongodb stacks can whole app.get("/") { helloworld() } app.get("/:users/:names") { script() } is same idea app engine's app.yaml? or looking @ file in backwards way. file routing file equivalent, right? handlers: - url: /.* script: helloworld.php - url: /users/names/ script: getname.php so if app wants grab user-253's name, select user, , query name using info grabbed request? i use symfony read yaml files: http://symfony.com/doc/current/components/yaml/yaml_format.html the code looks this: $yamlfile = __dir__ . '/routes.yaml'; $routes = yaml::parse(file_get_contents($yamlfile)); // routes associative array , show urls. $handlers = $routes['handlers']; echo 'url: ' . $handlers[0]['url'] . "\n"; echo 'script: ' . $handlers[0]['script'] . "\n"; echo "\n"; echo 'url: ' . $hand

c# - Inserting Data to a particular section in crystal report VS2010 -

i developing marks card college consists of student name, student rollnum, subject name subject code , marks of respective subject scored student. have database has definition shown below : name |roll num |subjectcode |subjectname |marks std_name 1001 phy physics 65 std_name 1001 che chemistry 59 std_name 1001 math mathematics 69 from above table, want subjectcode, subjectname , marks datatable/dataset/datagrid , insert data particular section(section 1,section 2,..etc) in crystal report. how can achieve this? thank you. you should learn more how create crystal report dataset? inserting fields in section not big issue. need create dataset or datatable , reference crystal report. after designing report can pass dataset object crystal report data. you should learn each section , role. report header: section printed @ top of first page of report. can put here company name, addre

c - Thread pool where the tasks are relatively large -

i have created thread pool in c. each thread in pool performs same function. several producer threads put fresh data pool's queue using standard mutex/cond method. the fresh data relatively large, , amount of processing has performed can take quite awhile. whenever have seen implemented workers lock queue while either copy required data or perform requested task. in case either of these operations may take awhile, , during time other threads blocked accessing queue. how should go announcing particular thread has taken task data associated task still being used? practical add sort of 'in process' flag queue , let worker thread unlock queue while works? revise queuing structure what's queued pointer data processed. when thread needs grab job, grabs mutex, gets next pointer task performed, possibly zaps in-queue copy of pointer or otherwise makes sure other threads won't process processing, , releases mutex (or signals condition or whatever). ac

excel - Application.Screenupdating and Windows 7 -

sub test() application.screenupdating = false userform1.show end sub if run snippet of code on windows xp machine (either xl2003 or xl2010), 'trail' when drag form around screen - realize normal. however, if run same code on windows 7 (64 bit) machine, not leave trail, expect. has changed in windows 7 causes this? unfortunately, masks potential problem in applications developed on win7 machine, won't show until run on older os machine. i've done lot of searching on internet, far no mention of this.

list - How to print all the facts? -

i stuck problem... isat(keys, room3). isat(book, room3). isat(keys, room6). isat(keys, room4). currently, room3 have keys , book. want print keys , book. tried code , apparently prints one. (just keys) look :- isin(location), write('you in '), write(location), nl, items_inroom(location), nl. items_inroom(location) :- isin(location), isat(item, location), write('available item(s):'), write(item), nl. items_inroom(_) :- write('available item(s): none'), nl. items_inroom code trying print these facts. how can approach this? great! thank you. find items , display them. items_inroom(location) :- write('available item(s):'), findall(item, isat(item, location), items), show_items(items). show_items([]) :- write('none'), !. show_items(items) :- write(items). actually can implement show_items(items) in way want.

eclipse - java 7 install on mac broken/ incomplete? -

i installed java 7 (both jdk , jre) on mac (osx 10.10.3). java preferences shows installed version correctly (1.7.0_80) output of "java -version". seems path/ environment variables not updated since /system/library/frameworks/javavm.framework/versions still showing 1.6 , not 1.7. programs eclipse looking java 7 or later in path hence failing run. any suggestions ? it's in different location now: /library/java/javavirtualmachines/ . for instance, on machine: $ ls /system/library/frameworks/javavm.framework/versions 1.4 1.4.2 1.5 1.5.0 1.6 1.6.0 current currentjdk $ ls /library/java/javavirtualmachines/ jdk1.7.0_67.jdk jdk1.8.0_20.jdk jdk1.8.0_45.jdk

api - Is it possible to create a SpringMVC RESTful Enpoint With Several Unnamed Attributes As Path Params -

according restful api best practice research i've been doing, uri should uniquely identify resource or list of resources. because of this, create endpoints use arbitrary path key/value pairs like: get /customers/status/enrolled instead of this: get /customers?status=enrolled similarly, setup unlimited number of identity partitions this: get /customers/{attribute1name}/{attribute1value}/{attribute2name}/{attribute2value is possible springmvc create requestmapping arbitrary set of path key/value pairs , unlimited number of them?

Box api v2 upload file using php -

i have been working on box api. work file upload. here code: $path = 'https://upload.box.com/api/2.0/files/content'; $method = 'post'; $headers = array('authorization bearer ' . $accesstoken); $attributes = array('name'=>$file_name, 'parent'=>array('id'=>0)); $body = array('attributes'=>json_encode($attributes), 'file'=>'@'.realpath($filepath)); $result = $this->post($path, $method, $body, $headers); and pass of post function: function post($url,$method, $fields, $headers){ try { $ch = curl_init(); curl_setopt($ch,curlopt_url, $url); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_postfields, $fields); curl_setopt($ch, curlopt_followlocation, true); $response = curl_exec($ch); $responsecode = curl_getinfo($ch, curlinfo_http_code); if (false

Class alternative for jquery selectors -

i have code below <li class="active-always"><a href="#tab-03" data-toggle="tab">alabama</a></li> <li class="active-always"><a href="#tab-04" data-toggle="tab">alaska</a></li> <li class="active-always"><a href="#tab-05" data-toggle="tab">arizona</a></li> <li><a href="#tab-06" data-toggle="tab">california</a></li> <li><a href="#tab-07" data-toggle="tab">colorado</a></li> here selecting <li> elements doesnt have class active-always $('li:not(.active-always)').addclass('disabled') but not sure if doing correct. there must better solution. because using class names becomes confusing. forget purpose of kind of class names. and ask myself, css or js? is there simple alternative this? i know if add

ios - Using tags in Swift -

i have 15 uibuttons in controller. im trying clear 10 of them simple loop , looks getting kind of conflict. when hit button clear, following error: could not cast value of type '_uisizetrackingview' (0x18a023c) 'uibutton' (0x1899298). (lldb) for loop : for var = 0; < 9; i++ { button = view.viewwithtag(i) as! uibutton button.setimage(nil, forstate: .normal) } i have narrowed down issue item using tag 0. have looked @ items on view controller scene , can not seem find conflicts. see 1 button using tag = 0. i confrimed replacing 'i' in loop '0' , got same issue. when replaced '1' or '2', works fine single image. any way see object using tag 0? have clicked on them ( including main 'view') cant seem find anything. as there said @ranunez, default tag 0. don't agree advice use non-zero tags. my advice is, don't use tags @ all. if want use view in code, declare outlet , connect it.

How to evaluate Expression inside Expression in AngularJS -

i trying evaluate expression inside expression using angularjs.please let me know how it? problem: i have 2 objects department , facility , want display departments , facilities in accordions. so, able pass department object , facility object. problem arises.as department object has property department_name , facility has facility_name.i passed department_name , facility_name label attribute in directive , trying use in accordion html {{item.{{label}}}}.i don't think right. please let me know how can this. thanks in advance in html: <accordion-directive object="department" label="department_name"> </accordion-directive> <accordion-directive object="facility" label="facility_name"> </accordion-directive> in accordion html <accordion-group ng-repeat="item in object> <accordion-heading> {{item.{{label}}}} // departments should department[0].department_name // faci

Download folder through ftp server in rails -

i'm trying write code download folder ftp server. looked @ support on gems ftp downloading. far, see syncftp gem updated often. have other options ftp gem similar syncftp? if not, can show me how download whole folder ftp server connection. i'm able establish ftp connection , list of files it, don't know how download entire folder.

regex - Oracle query to find string not containing characters -

what oracle query return records field mytable.myname contains any characters other a-z a-z 0-9 -/\() you can use following: select * mytable regexp_like (myname, '^[^a-za-z0-9\/\\()-]+$'); you can same i modifier: select * mytable regexp_like (myname, '^[^a-z0-9\/\\()-]+$', 'i'); explanation: ^ start of string [^___ ] negative character set (which match character other characters specified inside it) + match previous group more once $ end of string

How to iterate multi dimensional array and calculate sum for each row in php? -

i have array retrieved data database , put in array : $query = "select * caseunder"; $result=mysql_query($query) or die('error, insert query failed'); $array[] = array(); $numrows=mysql_num_rows($result); while ($i < $numrows){ $allergies =mysql_result($result, $i, "allergies"); $vege = mysql_result($result,$i, "vege"); $age = mysql_result($result, $i, "age"); $bmi =mysql_result($result, $i, "bmi"); $solution = mysql_result($result,$i, "solution"); $bmi2 = $_post['weight'] / (($_post['height']/100)*($_post['height']/100)); if($_post['age']>18 && $_post['age']<35) $age2 = 'young '; if($_post['age']>40 && $_post['age']<50) $age2 = 'middle age '; if($_post['age']>60) $age2 = 'old men '; $array[] = array('age'=>

design patterns - Using a class to store constant values -

is there better approach storing values required per following example. im trying avoid possible errors when passing string factory method. but, there issues this? testable, there better way achieve same thing etc. abstract class types { const car = 'car'; const boat = 'boat'; const bike = 'bike'; } class vehiclefactory { public function make($type) { if ($type === types::car) { // create new car } if ($type === types::boat) { // create new boat } if ($type === types::bike) { // create new bike } } } class client { public function createacar() { $vehiclefactory = new vehiclefactory(); $car = $vehiclefactory->create(types::car) } } this looks language agnostic question going assume advice use enum instead of abstract class won't work. your approach of using constants represent type of object gets

python - Need to grab a 3x3 neighbourhood of an input cell from a 2d numpy array -

i trying define function return 3x3 neighbourhood of input cell. right have: def queen_neighbourhood(in_forest, in_row, in_col): neighbourhood = in_forest[in_row-1:in_row+1, in_col-1:in_col+1] return neighbourhood (in_forest input array). when run this, seems return 2x2 matrix, instead of 3x3. why this? seems me inputting row , column reference, , slicing out square starts 1 row behind input row, , ends 1 row ahead of it, , same columns. so example, given input array such: [ 01, 02, 03, 04, 05 06, 07, 08, 09, 10 11, 12, 13, 14, 15 16, 17, 18, 19, 20 21, 22, 23, 24, 25 ] and using row 2, col 3, want return matrix such: [ 02, 03, 04 07, 08, 09 12, 13, 14 ] when in_forest[in_row-1:in_row+1, in_col-1:in_col+2] saying "give me square in_row-1 inclusive in_row+1 exclusive , , in_col-1 inclusive in_col+2 exclusive . slices to, not including second index. simply use in_row-1:in_row+2 , in_col-1:in_col+2 instead slice including &

c# - Use linq to find index position, but take into account ties that depend on a value -

what best way sort value, find index of item rank, take account ties. index 5th place have 2 items 6th skipped , next iteration starts @ 7th. best way group , track index? return teamtournamentresults .orderbydescending(t => t.rankingpoints) .select((item, index) => new { item = item, index = index }) .select(q => new teamsummaryresultsmodel { divisionranking = q.index + 1, rankingpoints= q.item.rankingpoints, please, read comment question. have @ example: list<int> mi = new list<int>(){1,2,2,5,6,7,7,7,8,9,10,10}; var qry = mi .select(g=>new { number = g, rank = (from in mi i>g select i).count()+1 }); result: number rank 1 12 2 10 2 10 5 9 6 8 7 5 7 5 7 5 8 4 9 3 10 1 10 1 other useful resources: converting sql rank()

Android custom animation -

Image
i'm creating custom spinner need animate. spinner consists of 10 shapes draw using canvas , paths. each shape should animated separately , each shape drawn @ separate time. every new shape drawn while rest still going through animation cycle, animating 1 shape 10 , reverse 0. i have working drawing these shapes inside ondraw method. ondraw called every time invalidate() , invalidate() called recursive method postdelay() every 40ms desired animation. kinda works can see cpu use rising drastically , after 10-15 seconds whole thing grinds halt. going wrong.. possibly that's not right way of attempting animation @ all. i guess questions - think going wrong , why? right approach animating things on canvas? edit: edit2: looks drastic cpu usage coming reusing path objects. not sure why, forgoing reuse of objects , recreating them between ondraw methods has drastically increased performance. cpu usage still climbs 5-10% in 10-15 minutes of running spinner animation that

NameError: name 'one' is not defined python 3.4 error -

a=str(input("enter num start functionone")) if(a == '1'): one() elif (a == '2'): tow() def one(): print('good') def tow(): print('very good') error enter numper start functionone1 traceback (most recent call last): file "c:/users/hacker/desktop/complex program.py", line 3, in <module> one() nameerror: name 'one' not defined you need define functions before calling them: def one(): print('good') def tow(): print('very good') a=str(input("enter num start functionone")) if(a == '1'): one() elif (a == '2'): tow() if call function function defined below won't work because python doesn't know yet function call supposed do.

php - MySQL COUNT vs SELECT rows performance -

i have small table 3 columns , using php. table (id unsigned int(10), gameid unsigned int(10), userid unsigned int(10)) - id, gameid , userid indexed. at point (when player join game) system check if game have 100 players in it, if retrive rows , actions on them , in end rows deleted. select query: select * table gameid = 1 order id asc limit 100 count query: select count(*) rows table gameid = 1 limit 100 delete query: delete table gameid = 1 order id asc limit 100 my question performance , speed, better: approach 1 (3 queries) execute count query , check how many rows in table if rows >= 100 do: execute select query , process data execute delete query approach 2 (2 query) execute select query if count(rows) >= 100 do: process data execute delete query what approach better use? thanks microtime(true) php friend. if there index starting gameid , "approach 1" might faster, since can count(*) in index. on other

android - Cordova Error "You may not have the required environment..." -

i trying build first app android of cordova. when put cordova build console, error: you may not have required environment or os build project. error: cmd: command failed exit code 1... this post says necessary put in path: %systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot%\system32\windowspowershell\v1.0\ but still doesn't work http://i.stack.imgur.com/hxeio.png

html - Affect an element outside of another element's scope -

i'm looking technical explanation, not solution. if have, example, following structure of html: <div class="container"> <div class="box1"> <div class="square"></div> </div> <div class="box2"> <div class="circle"></div> </div> </div> why can't create css rule if hover on .square , change background color of .circle ? in other words, why can't affect element outside of element's scope? also, there time when can this? there future plans allow behavior? as point out, there no way select parent of element in css2/css3 spec. answer: its not in spec namely present performance considerations , way specificity works in css. it in neither of current css selectors specs: selectors level 3 spec css 2 selectors spec in meantime you'll have resort javascript if need select parent element. the selectors lev

ios - Swift | UICollectionView without storyboard shows incorrect data -

i building app has uicollectionview 3 items. each item takes complete width of screen , shows timer counts down next departure times our busses in each location. each item contains 1) departure address, 2) string "next shuttle leaves @ time ", , 3) timer counts down next departure time in 00:00:00 format. item 1 , 2 display expected, when item 3 departure address , string correct, timer shows time cell 1 instead of cell 3. i setting uicollectionview like: func setupcollectionview() { let layout: uicollectionviewflowlayout = uicollectionviewflowlayout() layout.sectioninset = uiedgeinsets(top: 0, left: 0, bottom: 0, right: 0) layout.itemsize = frame.size layout.minimumlinespacing = 0 layout.minimuminteritemspacing = 0 layout.scrolldirection = uicollectionviewscrolldirection.horizontal let collframe:cgrect = cgrectmake(0, 0, self.frame.width, self.frame.height) collectionview = uicollectionview(frame: collframe, collectionviewlayo

javascript - JSON parsing using .NET deserialize() with nested "list" -

edit: simplified classes { "name": "final five", "bio": null, "noplayers": "0", "roster": { "players0": { "playerid": "3516", "name": "gate", "role": "mid lane", "isstarter": 1 }, "players1": { "playerid": "3826", "name": "veritas", "role": "ad carry", "isstarter": 1 }, "players2": { "playerid": "4054", "name": "novel", "role": "support", "isstarter": 1 }, "players3": { "playerid": "4142", "name": "wizardry", "role": "top lane", "isstarter": 0 }, "players4": {

node.js - How to ensure Just My Code is stepped into when debugging Javascript in NODE environment? -

given: node.js console application (using visual studio) has downloaded several packages via npm. when npm downloads source code of packages , puts them node modules folder. problem: javascript code i'm writing needs debugging of single step see code paths. problem defines "just code" being used during "compile" of project. includes node modules wind on long goose chases often. is there way exclude single stepping node modules , in effect step "just code"...? the answer question vs2015 code debugger code must this. ntvs hasn't done yet, , msft team knows issue. when fix i'll post back.

java - Why Does My Surface View Class Stops Rendering When Main Activity is Busy? -

i implementing simple render view class android extending surfaceview. main activity class includes infinite while loop other operations. however, app shows black screen when main activity in infinite loop. far know, main activity , surface view classes have own separate threads, surface view class should keep rendering when main activity class busy. app works fine when prevent infinite loop setting 'running' boolean variable false in code. what might reason of surface view class stops rendering when main activity in infinite loop? my main activity , surface view classes follows: import android.app.activity; import android.os.bundle; import android.view.window; import android.view.windowmanager; public class mainactivity extends activity{ rendersurfaceview renderview; public boolean running = true; @override protected void oncreate(bundle savedinstancestate) { super.oncreate ( savedinstancestate ); requestwindowfeature(window.featu

c++ - Select elements from a list according to their properties -

i developing application aimed render huge number of shapes. each shape can assigned specific layer . i input data list of shapes, each shape have string property represents layer shape belongs. now, need develop method allows me select (draw) shapes belong given list of selected layers. in pseudo-code: void draw_if(sorted_list shapes, list<string> selected_layers) { each shape in shapes { if (shape.layer in selected_layers) shape.draw(); } } the point perform operation fast possible; therefore need choose right data structures , proper algorithm. the list of selected layers list of strings (1÷100 different layers), if needed performance reasons, converted other data types. the shapes sorted according z-order. basic intrusive solutions overlooked here in search of elaborate data structures , algorithms, fastest. assuming have no choice keep selection separate, if want fast solution, store boolean selection flag in each layer (co

ios - Countdown with several decimal slots, using NSTimer in Swift -

i want make app has timer starting @ 10.0000000 example, , want countdown here's code far: import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var labeltime: uilabel! var counter = 10.0000000 var labelvalue: double { { return nsnumberformatter().numberfromstring(labeltime.text!)!.doublevalue } set { labeltime.text = "\(newvalue)" } } override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. labelvalue = counter var timer = nstimer.scheduledtimerwithtimeinterval(0.0000001, target: self, selector: ("update"), userinfo: nil, repeats: true) } func update(){ labelvalue -= 0.0000001 } } what happens countdown slow, it's not working , take 1 hour 0 seconds, instead of 10 seconds. ideas? changes should make code? thanks timers not super-accurate, , res