Posts

java - Are there dangers to throwing a runtime exception forcibly into a thread with Thread.stop(Throwable)? -

i writing large, multithreaded application, many differing roles threads (e.g. event processing, metrics, networking). currently, if there inconsistency cannot handled, manifest exception. since there's no way recover of them, i've been rethrowing runtime exception of type applicationdeathexception . any classes need handle shutdown call catch block exception, , rethrow in order propagate stack). i considering killing off other threads in same manner calling thread#stop(throwable) upon them. fine sudden termination, , can catch exception should there need shutdown logic. have exception propagate stack, performing shutdown logic whereever needed, , killing thread in end. there hidden dangers i'm missing approach? thread.stop has been deprecated since unsafe (see javadoc). instead have each thread monitor boolean flag of sort (see java: how stop thread? , countless other threads on so). in situations typically implement sort of thread pool manager respon...

javascript - toggling image classes for inactive/active states -

i'm still coming against resistance here js- have row of thumbnails. first starts active class,the others have inactive classes. on click, want thumb clicked switch active , previous go inactive. want hover effect inactive classes. right now, can add active class, cant figure out how toggle prev active class jquery(document).ready(function($) { $(".groomsmen_thumbs, .bridesmaid_thumbs").click(function(){ if ( $(this).find(".toplevel").hasclass("inactivethumb") ) { $('img', this).toggleclass("activethumb inactivethumb"); } }), $('.groomsmen_thumbs, .bridesmaid_thumbs') .on("mouseenter", function() { $(this).find(".inactivethumb.toplevel").animate({"opacity": "1"}, "fast"); }) .on("mouseleave", function() { $(this).find(".inactivethumb.toplevel").animate({"opacity": "0"}, "fast"); }) }); links this <li><a hr...

bash - How to test existence of a program in crontab? -

i made bash script test if utility named 'myutility' exists: #!/bin/bash #if hash myutility >/dev/null 2>&1; if hash myutility 2>/dev/null; echo "branch true" exit 0 else echo "branch false" exit 1 fi on command line, $ ./test.sh branch true -- seems work. if add crontab: $ crontab -l ## test * * * * * /users/meng/bin/test.sh > "/users/meng/log.txt" i got $ more /users/meng/log.txt branch false so, somehow when script run crontab, hash myutility >/dev/null 2>&1 part not work. idea? knowing when, , why, cronjobs fail can difficult. solution use wrapper script archive successful cron job runs time , send email admin staff when fails. both successful , failed runs leave trace file disk can read understand job did , when. @ failure trace sent admin staff, not need login server initial idea should done if anything. notice when things fail best read notification email bottom to...

python - How to modify an inherited list in the __init__ method of a subclass? -

is possible change in init function of class? lets have class called "deck" which, when initialized, creates list of 52 card objects. now want make class called "even" inherits "deck" class , creates deck of card objects eliminates cards number 2 (so spades, hearts, etc) inherited "deck". i have been having lot of trouble because when try modify inherited list, regardless of try, python return error, 'nonetype' being main root of problem. here code "even" class init: def __init__(self): x = deck.__init__(self) card in x: if card.rank() == 2: x.pop(card) return x it worth noting card class has method rank() return rank of card int. regardless of things have tried, there wrong it. "'nonetype' object not iterable" or "subscripable" , when check type() of x nonetype. have done lot of searching around nothing making sense me nonetype or should fix it. if r...

css - Minifying only a part of .LESS file -

when working .less preprocessor files, there gui tools such winless, etc. or in grunt, minify section of outputted css file? for eg. in final .css, want main code remain neatly formatted reset code or normalize include minified. e.g. https://github.com/tryghost/casper/blob/master/assets/css/screen.css in file, either can minify , have min.css users use, want know if there automated option minify part of it, e.g. normalize reset section.

php - PDO Login Script Always Re-Directing To Header Page -

Image
<?php include "config.php"; class users extends config { public function login($username, $password) { try { $this->db->begintransaction(); $stmt = $this->db->prepare("select `username`, `password` `users` `username` = ? , `password` = ? limit 1"); $stmt->execute(array($username, $password)); if($stmt->rowcount == 1) { while($row = $stmt->fetch(pdo::fetch_assoc)) { header("location: index.php?p=loggedin"); exit(); } } else { header("location: index.php?p=false"); exit(); } $this->db->commit(); } catch(pdoexception $ex) { $this->db->rollback(); echo $ex->getmessage(); } } } ...

Time period in Excel 2010 -

a simple question, quick googling did not prove fruitful. basically, have column called "uniqueid", unique identifier people in dataset. uniqueids have multiple records, because there 1 record per year person stayed @ university. i'd create "time period" variable, first year, t= 1, second year t=2, third year t=3 etc. each unique id. the following faster if spreadsheet sorted unique id; =if(a2=a1,b1+1,1) (assumes above formula in column b , data begins on row 2) and, of course, copied down rows described above. you find in spreadsheet containing many rows countif slow since looking through ever-increasing range sizes.