Posts

Showing posts from August, 2010

Oracle sql fiding shipping delay -

can know how write sql statement in listing shipping city , state order has longest shipping delay. not sure need use function max in where i'm assuming data structure flat, in: create table orders ( ... shipping_city varchar2(100), shipping_state varchar2(100), shipping_delay number(7), ... ); you can write: select max(shipping_city) keep (dense_rank last order shipping_delay), max(shipping_state) keep (dense_rank last order shipping_delay) orders

swing - How to create a missing java class? -

i have application 3 classes ( mainclass , classa , classb ). mainclass runs no problem, when try run classa or classb , following stacktrace message: error: not find or load main class mypackage.classa or error: not find or load main class mypackage.classb when looked in build folder, mainclass.class file there, there no classa.class or classb.class files, sure causing problem. i tried creating classes scratch didn't fix problem, , tried performing clean , build keeps on failing hasn't helped either. how can create missing class files correct problem? the files in build folder are: in build folder there's mainclass$1 - 10.class , mainclass.form , mainclass.class , classa$1 - 10.class , classa.form , classb$1 - 10.class , classb.form

javascript - Slide content based on the speed of the mouse -

i have carousel type item: http://codepen.io/r3plica/pen/xopzqk?editors=1111 what trying now, change it's behaviour. drag know speed of mouse , try mimic scroll speed. when let go of mouse want slider continue sliding slow down on period of time. first step trying actual speed of mouse, did this: var eventhandler = function (e) { var event = _options.event; var timestamp = new date().gettime(); var touches = event.touches = e.originalevent !== undefined ? e.originalevent.touches : null; if (e.type === 'mousedown') { // assign timer our event event.timer = $timeout(function () { // if have not enabled event if (!event.enabled) { // set our startx , time event.startx = touches ? touches[0].pagex : e.clientx; event.timestamp = timestamp; //console.log(event); // enable our drag event.enabled = true;

money rails - How could I remove duplicated sections in Ruby DSL -

my current config format seems redundant. how convert next expected config format? my expected config is: moneyrails.configure |config| register_currency("twd", 100) register_currency("usd", 100) .... end my current config is: moneyrails.configure |config| config.register_currency = { :priority => 1, :iso_code => "twd", :name => "twd", :symbol => "nt$ ", :symbol_first => true, :subunit => "subcent", :subunit_to_unit => 100, :thousands_separator => ",", :decimal_mark => "." } config.register_currency = { :priority => 1, :iso_code => "usd", :name => "usd", :symbol => "$ ", :symbol_first => true, :subunit

python - Animated Line Graph gets ValueError: x and y must have same first dimension at runtime -

i trying create animated line graph of half lives, text files referenced this: decay1.txt : 2000 1000 500 250 125 63 31 16 8 4 0 decay2.txt reverse of decay1.txt . any appreciated, believe how pulling data arrays create y axis. data enter when prompted 2000 10. import numpy np import matplotlib.pyplot plt import matplotlib.animation animation fig = plt.figure() totalnumber_of_nuclei = int(input("enter total number of nuclei"))#user input totalnumber of nuclei(max y) totaltime = int(input("enter total time simulation"))#user input totaltime (max x) timescale = np.arange(0., (totaltime+1.) ,1.)#time between plots - distance on x between plots ax = plt.axes(xlim=(0, totaltime), ylim=(0, totalnumber_of_nuclei)) def animate(i): pulldata1 = open("decay1.txt","r").read() pulldata2 = open("decay2.txt","r").read() dataarray1 = pulldata1.split("\n") dataarray2 = pulldata2.split("\n")

c# - Why does waiting once on multiple calls to HttpClient.GetStringAsync() take as long as waiting individually on each call? -

using system.net.http; using microsoft.visualstudio.testtools.unittesting; using system.threading.tasks; using system.diagnostics; [testclass] public class unittest1 { [testmethod] public async task exceutemultiplerequestsinparallel() { stopwatch sw = new stopwatch(); sw.start(); httpclient client = new httpclient(); task<string> ms = client.getstringasync("http://www.microsoft.com"); task<string> msdn = client.getstringasync("http://msdn.microsoft.com"); task<string> blogs = client.getstringasync("http://blogs.msdn.com"); await task.whenall(ms, msdn, blogs); sw.stop(); var result = sw.elapsed.tostring(); } [testmethod] public async task excecutemultiplerequests() { stopwatch sw = new stopwatch(); httpclient client = new httpclient(); string ms = await client.getstringasync("http://www.microsoft.c

php - Looped SQL queries with 2 variables -

i have table (tags) 3 fields, activityid, placeid, tagid (and 4th, id pkey). want search through table using 2 arrays, 1 of places , 1 of tags. each match want return activityid. want used activityid list in table (activity) each of same array of placeids. started put loops see lots of things saying not that. thinking need use temp table might not required. i'm struggling loops anyway rather struggle make poor practice anyway thought i'd post general idea see if point me in right direction... code not working shows general idea..edit... i'm looking resolve loop in first section, second section need leave loop $places = array("london","madrid","paris","rome"); $tags = array("shopping","sight","bar","club"); $num_places = count($places); $num_tags = count($tags); /* want remove loop section */ $counterp = 0; while($counterp <= ($num_places)) { $countert = 0; while($countert <=

java - How to terminate a particular blocking thread -

scenario: have limited number of independent tasks given few threads finish tasks. main thread should wait threads finish tasks. while works of time, 1 of threads can't finish tasks , main thread waits indefinitely. how possible kill blocked thread? here sample code explains scenario. client class public class threadstop { public static void main(string[] args){ list<thread> threadlist = getmythreadlist(); (thread thread : threadlist) { thread.start(); } system.out.println("waiting child threads die"); (thread thread : threadlist) { try { thread.join(); system.out.println(thread.getname() + " finished job"); } catch (interruptedexception e) { system.out.println("interrupted exception thrown : " + thread.getname()); } } system.out.println("all child threads finished job")

java - Spring MVC - SEVERE: Exception starting filter Spring OpenEntityManagerInViewFilter -

i did reverse engineering using spring roo exsisting mysql db, creates necessity files, , did mvn clean install, executes , no testing error, when run mvn tomcat:run shows error following e:\java\maven\testing\ui\admin>mvn tomcat:run [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building admin 0.1.0.build-snapshot [info] ------------------------------------------------------------------------ [info] [info] >>> tomcat-maven-plugin:1.1:run (default-cli) > compile @ admin >>> [info] [info] --- aspectj-maven-plugin:1.2:compile (default) @ admin --- [info] [info] --- maven-resources-plugin:2.6:resources (default-resources) @ admin --- [info] using 'utf-8' encoding copy filtered resources. [info] copying 1 resource [info] [info] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ admin --- [info] no sources compile [info] [info] <<< tomcat-maven-plugin:1.1:run (

javascript - jQuery function after an AJAX Content load -

when reload page ajax php, can't seem jquery function affects each item in enlarge class. html: <!doctype html> <html> <head> <meta charset="utf-8"> <title>gallery</title> <link rel="stylesheet" href="css/gallery.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"> </script> <script src="js/enlarge.js"></script> <script> function showimage(str) { if (str.length == 0) { document.getelementbyid("image").innerhtml = ""; return; } else { var xmlhttp = new xmlhttprequest(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 &&

javascript - ng-model not being updated outside of the scope -

i binding ng-model input, value of variable it's bound not being updated outside of div directive declared: <div input-field ng-if="starttypes.selected.value == 'localdate' || starttypes.selected.value == 'localdatetime'"> <input id="date" type="text" ng-model="date" input-date> <label for="date">date</label> date inner scope: {{date}} </div> date outer scope: {{date}} when selecting new date, ony inner date updated. outer 1 remains old value (which might either undefined or not depending if declared in controller, doesn't matter). i using angular-materialize , not sure if source of issue doesn't make sense because specific framework angular work css framework materializecss . this component using. edit: i have tried declaring date in controller $scope.date = new date() , indeed current date loaded in date picker. when date selected , model chang

Registration Error php, mysql, no data in database -

this question has answer here: reference - error mean in php? 30 answers i've been stuck couple days connecting registration looking through forums etc. no error seems populate on page, when take @ phpmyadmin doesn't show registration info inserted in db. register.php <?php session_start(); if(isset($_session['user'])!="") { header("location: home.php"); } $servername = "correctly inserted info"; $username = "correctly inserted info"; $password = "correctly inserted info"; $dbname = "correctly inserted info"; $conn = new mysqli($servername, $username, $password, $dbname); if(isset($_post['btn-signup'])) { $fname = mysql_real_escape_string($_post['fullname']); $uname = mysql_real_escape_string($_post['username']); $email = mysql_real_escape_string

python - Django RegexValidator fails on empty string -

i have added custom validation username field, my regex is, ^[a-za-z0-9_]{1,15}$ need validate a-z, 0-9 , _ (underscores) of length 1-15. def validate_username(value): valid_username = r'^[a-za-z0-9_]{1,15}$' validator = regexvalidator(regex=valid_username, message='a-z0-9 [1-15].', code='invalid name') validator(value) return value which validated on save() , def save(self, **kwargs): if self.username: self.username = validate_username(self.username) super(abstractbaseuser, self).save(**kwargs) this works on django shell, >>> django.core.validators import regexvalidator >>> valid_username = r'^[a-za-z0-9_]{1,15}$' >>> validator = regexvalidator(regex=valid_username, message='alphanumerics , underscores allowed [1-15].', code='invalid name') >>> validator('') traceback (most recent call last): file "<inpu

node.js - How to return value of db calls from a asynchronous function -

i looking answer , found this . in jquery there when function. using guidelines synchronize asynchronous calls using async.js in node here code. async.foreach(dateindateformat, function(item, callback) { console.log(moment(item.startdate).todate()); var result = trip.aggregate([{ "$unwind": "$trips" }, { "$match": { "trips.starttime": { "$gte": moment(item.startdate).todate(), "$lte": moment(item.enddate).todate() } } }, { "$group": { "_id": { "date": { "$dayofmonth": "$trips.starttime" } }, "distance": { "$sum": "$trips.distance" } }

java - Close Scanner when entering "0" -

i writting program user enters string input , program finds number of words , number of int numbers. scanner should close when user enters "0". my code import java.util.scanner; public class runme { public static void main(string[] args) { scanner in = new scanner(system.in); string input = in.nextline(); counter numbers = new counter(); counter words = new counter(); scanner s = new scanner(input).usedelimiter("\\s"); while(s.nextint() != 0) { if(s.hasnextint()) { numbers.add(); } else { words.add(); } } s.close(); in.close(); system.out.println("number of numbers : " + numbers.value()); system.out.println("number of words : " + words.value()); } } and class counter public class counter { private int value; public int add() { value++; return value; } public int value() {

javascript - Inject functionality into other Node.js module -

i have node.js application (using sequelize orm) try separate different modules can reused. means need remove dependencies between them, i'm struggling @ 1 point: there's module called "account", should have (almost) 0 dependencies on other modules. provides basic account functionality. then there other modules, have dependency on account module (which ok). at moment, account module has dependency on other modules, i'd resolve. now, when account gets created, other modules must create objects in database. should happen in same transaction , without account module knowing other modules. currently, looks following: accountcontroller.prototype.createaccount = function (data) { // validation checks etc. omited return db.sequelize.transaction(function (t) { return q.promise(function (resolve, reject, notify) { _createhash(pw, 10) .then(function (hash) { data.passwordhash = hash; return _crea

Creating Directory in Android API 22(Lollipop) and 23(Marshmallow) -

i developing android application require files(images) saved on devices in order access them later. need create directory(folder) , put stuffs(images) in have code running on api 19(kitkat) not work on lollipop , latest marshmallow. codes string stored = null; file sdcard = environment.getexternalstoragedirectory() ; file folder = new file(sdcard.getabsolutefile() , "propertyimages"); log.i("folder name",folder.tostring()); if (folder.exists()){ log.w("folder exist","folder exists"); }else{ log.w("folder not exist","folder not exist"); } if (folder.mkdir()){ log.w("folder created","folder created"); }else{ log.w("folder not created","folder not created"); } file file = new file(folder.getabsolutefile(), filename + ".jpg") ; if (file.exists()) return stored ; try { fi

gruntjs - The easiest way to use autoprefixer? -

what want have tool can watch , auto prefix css. using pleeease.io , straightforward beginners me, after install through npm, need create option file(.pleeeaserc), pleeease watch afterwards, can focus on css, every time make change css file, gets processed , output. unfortunately seems author has stopped maintaining it, when npm install pleeease on new server got lots of errors , installation failed. i guess time me learn how directly use autoprefixer, believe pleeease integrates 1 of dependencies. however, find learning curve little me: use autoprefixer, need learn postcss; , postcss runs grunt or gulp; use task runners, need know npm , node.js. know these useful tools can save lots of time, them can more autoprefixing. make deep dive them later under current pressure need shortcut pleeease autoprefixer , running, without having digest documents , articles postcss. hope can [postcss|autoprefixer|something else] watch under scss folder , every time make change ,