Posts

javascript - Image onload event not firing in firefox -

i'm creating image preloader. works fine in browsers except firefox (testing firefox 10.0). input array of images called image_list . these images appended dynamically body of document , load callback attached, calls function update_progress . code follows: $(image_list).each(function() { var x = $('<img />') .load(function() {update_progress(percent_loaded += step);}) .attr('src', this) .appendto('body') .css('display', 'none'); .each(function() { if(this.complete) update_progress(percent_loaded += step); }); }); in firefox, load callback , update_progress never called. yet exact same code works fine in chrome , other browsers i've tested. there way detect when image has loaded in firefox? i first check see whether image has height, checking height property. if (the_image.height > 0) { // image loaded (possibly cached) } if have cached ...

objective c - NSMenu update title -

i have created nsmenu dynamically created , lists hdd's attached computer. each of these submenu contains nsmenuitem created title "calculating size...". on thread enumerating through specific folders return string replace title. i have setup correctly if have 1 of these submenu's selected when enumeration finishes doesn't reflect change in title until either highlight item or select different submenu , come back. what correct way of achieving update?

web services - Postgres Java Webservice response issue -

i have webservice use execute postgres queries. problem response anytype{} nothing in it. checked server , seems there no errors in log files. webservice @suppresswarnings("unused") public string getinfo() { connection con = null; preparedstatement st = null; resultset rs = null; string url = "jdbc:postgresql://127.0.0.1:5432/uptondb"; string user = "*******"; string password = "******"; string query = ""; string response = ""; int size = 0; initialcontext cxt = null; try { cxt = new initialcontext(); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } datasource ds; try { ds = (datasource) cxt.lookup( "java:comp/env/jdbc/postgres" ); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } try{ try { c...

javascript - how to make setTimeout refer to context of object? -

var myobj = { name:"mike", go:function(){ console.log(this.name); } } myobj.go() //logs out mike settimeout(this.myobj.go,200) //logs out (emptystring) define variable reffering object before: var _this = this; settimeout(function() {_this.myobj.go();}, 200);

javascript - Centering DIV Horizontally & Vertically on Page Load -

how can center div both horizontally , vertically when page loads? i using following solution: html: <div class="container"> <div class="visitorselect"> <a href="/visitorlog/boeing"> <div class="tile double icon bg-color-blue"> <div class="tile-content"> <i class="icon-plane"></i> </div> <div class="brand"> <span class="name">employee</span> </div> </div> </a> <a href="/visitorlog/guest"> <div class="tile double icon bg-color-orange"> <div class="tile-content"> <i class="icon-group"></i> </div> <div class="brand"> <span class="name">guest</span> </div> <...

ios - AVAssetExportSession ignoring videoComposition rotation & stripping metadata -

i attempting rotate video prior upload on ios device because other platforms (such android) not interpret rotation information in ios-recorded videos and, result, play them improperly rotated. i have looked @ following stack posts have not had success apply of them case: ios rotate every frame of video rotating video w/ avmutablevideocompositionlayerinstruction avmutablevideocomposition rotated video captured in portrait mode ios avfoundation: setting orientation of video i coped apple avsimpleeditor project sample, unfortunately ever happens is, upon creating avassetexportsession , calling exportasynchronouslywithcompletionhandler, no rotation performed, , what's worse, rotation metadata stripped out of resulting file. here code runs export: avassetexportsession *exportsession = [[avassetexportsession alloc] initwithasset:[_mutablecomposition copy] presetname:avassetexportpresetpassthrough]; exportsession.outputurl = outputurl; exportsession.outputfiletype = ...

java - Scanner not working correctly in Mac OSX terminal -

i have hacky ant command user can run stuff. command prompts user input. in intellij, when testing, works correctly. when run ant target terminal, weird behavior. here code: scanner userin = new scanner(system.in); printwriter writer = new printwriter(system.out); writer.println(error + " if continue load, data may in corrupted state. continue? (y/n): "); writer.flush(); string userresponse = userin.next(); while (!(userresponse.equalsignorecase("y") || userresponse.equalsignorecase("n") || userresponse.equalsignorecase("yes") || userresponse.equalsignorecase("no"))) { writer.println("invalid input. please specify if continue load. (y/n): "); writer.flush(); userresponse = userin.next(); } return userresponse.equalsignorecase("y") || userresponse.equalsignorecase("yes"); when running ant command terminal, error message displayed when use...

DART string constant set to timestamp as at compilation -

how can string constant automatically set datestamp @ compile time? something like: const string compile_datestamp = eval_static(datetime.now().tostring()); ... string s = "this program compiled $compile_datestamp"; where s e.g. "this program compiled 1971-02-03 04:05:06" thanks question! there's no required compile step in dart. (we have optional dart-to-javascript compiler, or dart-to-dart processor tree shaking.) dart's vm accepts input text files. similar ruby or python, runs text-based scripts. as others have mentioned, job sort of build step.

if statement - IF function; struggling with format of 3 times greater section -

excel 2002: write if function cell j8 assigns text "ok" if value in cell l9 3 times greater value in cell m6; otherwise, have if function assign text "not ok" cell j8. be: =if(l9*3>m6, "ok", "not ok") that be =if(l9>=m6*3,"ok", "not ok") further examples: a b c formula ------------------------------------------------- 1 2 no ok if(b2 >= a2*3,"ok", "not ok") 2 6 ok if(b3 >= a3*3,"ok", "not ok") 3 8 no ok if(b4 >= a4*3,"ok", "not ok")

ruby - guard/guard-sass not compiling changes -

i'm having problems guard , guard-sass compiling updated .sass files. i've install them both, pointed guard-sass configuration @ input , output directories whenever save changes .css file isn't getting updated. initially thought might permissions things odd thing i've set :all_on_start => true words doubt can that. here guardfile stands: guard 'sass', :input => 'assets/sass', :output => 'static/css', :all_on_start => true i've tried (just incase avoiding long notation made difference): guard 'sass', :all_on_start => true, :output => 'static/css' watch %r{^assets/sass/(.+\.s[ac]ss)$} end here when start guard debug ( guard start -d - incase debug show i'm missing): tavocado:data tavocado$ guard start -d 22:39:49 - debug - command execution: emacsclient --eval '1' 2> /dev/null || echo 'n/a' 22:39:49 - info - guard uses terminaltitle send notifications...

c# - How to test a selected item of a ComboBox is equal to my string? -

i started learning c# week ago. have little experience objective c. give me hard time asking such beginner question. well, user able select combo box. created combobox visually in xaml. contents of combo box strings. however, when user selects string of choice, store value int can calculations. errors have been can't convert object string , many other conversation errors. int x; string selvalue = (string)combobox1.selectedvalue; if ((selvalue=="green")||(selvalue=="blue")) { x= 5; } would best create function accepts object , returns int, if please tell ? you should have string green selectedtext , value int 5 selectedvalue, way can drop code & int x = (int)combobox1.selectedvalue, give 5. need google winform combobox databinding, you'll see can bind diferent properties text & value.

check facebook login with javascript -

i created facebook api script: fb.api('/me/likes/112234512170409',function(response) { if( response.data ) { if( !isempty(response.data) ) alert('you fan!'); else alert('not fan!'); } else { alert('error!'); alert("error: " + response.error.message); } }); but error messages: error: active acces token must used to... here full code: http://pastebin.com/zfs6rgpj did wrong? since script in body , not head, , execute code want instead of defining within function call later on, running api request (line #37 of code) on document load, before logged in (hence, no valid token). wrap api call function can call later, e.g. var callmelater = function { fb.api('/me/likes/112234512170409',function(response) { ... }; and call callmelater(); after you've logged in. if haven't checked out, perhaps steps 4 , 5 may helpful in http://devel...

How to bind a jQuery event to dynamic content with AngularJS -

basically in controller, i'm doing $http.get() load html set "current view". issue can't figure out how rebind the jquery event new dynamic content. right now, i've resorted somethign this: $http.get('/someurl', {}).success(function(data){ $scope.detailedview = data; // here comes rebinding settimeout(function(){ // use jquery bind new content }, 1500); }); i've been looking solution, , related i've found points using directive. i've looked this, not know how directive used this. note without timeout, bindings run before dynamic content in dom. i've tried finding similar hooking after $apply run have not found similar. first should see if doing jquery can't done using angular. here's simplistic version of directive can used: <div ng-repeat="item in items" my-directive>item {{$index+1}}</div> app.directive('mydirective', function ($timeout) { return function (...

r - Defining a distribution for survival::survreg() -

i try fit survreg model using gamma distribution. following ?survreg.distributions defined custom distribution this: gamma <- list(name = 'gamma', parms = c(2,2), init = function(x, weights, ...){ c(median(x), mad(x)) }, density = function(x, parms){ shape <- parms[1] scale <- parms[2] cbind(pgamma(x, shape=shape, scale=scale), 1-pgamma(x, shape=shape, scale=scale), dgamma(x, shape=shape, scale=scale), (shape-1)/x - 1/scale, (shape-1)*(shape-2)/x^2 - 2*(shape-1)/(x*scale) + 1/scale^2) }, quantile = function(p, parms) { qgamma(p, shape=parms[1], scale=parms[2]) }, deviance = function(...) stop('deviance residuals not defined') ) however can't run: require(survival) survreg(surv(log(time), status) ~ ph.ecog + sex, lung, dist=gamma) #error...

c# - Finding everywhere an enum is converted to string -

i'm trying find everywhere in solution specific enum converted string, whether or not tostring() explicitly called. (these being replaced conversion using enum descriptions improve obfuscation.) example: i'd find code such string str = "value: " + someenum.somevalue; i've tried replacing enum wrapper class containing implicit conversions enum type , overriding tostring() in wrapper class, when try searching uses of tostring() override gives me list of places in solution tostring() called on (and called explicitly). search done resharper in visual studio. is there way find these enum-to-string conversions? going through entire solution manually doesn't sound fun. the trick in roslyn use semanticmodel.gettypeinfo() , check convertedtype find these sort of implicit conversions. a complete example: using system; using system.collections.generic; using system.linq; using system.text; using roslyn.compilers; using roslyn.compilers.csharp;...

clicking link in javascript -

i have anchor tag on pages. <a id='signout' href='//somelocation'>signout</a> and have javascript file available pages. there function called , attached 'click' , 'touch' , 'key press' handler trying click link. like document.addeventlistener('click' function(e){ var signoff = document.getelementbyid('signout'); location = signoff.href; } this should click anchor tag whenever there click event not working. some syntax corrections got working me: document.addeventlistener('click', function(e) { var signoff = document.getelementbyid('signout'); location = signoff.href; }); http://jsfiddle.net/jjgej/

php - Cannot receive any SMS messages when I register/ inquire via SMS Globe Labs API -

i developing sms based registration system , far i'm @ stage of testing system. of sudden, not able receive messages server when tried register via sms must receive confirmation messages. here's did when using php nusoap. register.php <?php // allow user register via sms. error_reporting( e_all ); // load nusoap libraries. these slower built in php5 require_once('nusoap.php'); // create client , define url endpoint $soapclient = new nusoap_client('http://www.mnccyf.info/soap_book.php?wsdl'); // set character encoding, utf-8 standard. $soapclient->soap_defencoding = 'utf-8'; $soapclient->call('sendsms', array( 'uname' => '48dwi5', 'upin' => '159597', 'msisdn' => '09152886810', 'messagestring' => 'registered successfully', 'display' => '1', 'udh' => '', 'mwi' =>...

SQL- Subquery with aggregate functions (SQL Server) -

my set thus: have 3 tables- students (studentid, firstname, lastname etc.), studentsemesters(studentid,semid etc.), , semesters(semid, year) my requirement to, details each student last semester. logically implies semester highest year number. cannot seem query right. simplicity 'year' integer (e.g. 2000, 1998). below current query have been stuck @ time: select dbo.student.lastname + ' , ' + dbo.student.firstname student, dbo.student.defence1date, dbo.student.defence2date, count(studentsemesters_1.semid) semestercount, dbo.student.entrysemester + ' - ' + (select dbo.studentsemesters.semid dbo.studentsemesters inner join dbo.listsemesters on dbo.studentsemesters.semid = dbo.listsemesters.semid (dbo.student.studentcode = dbo.studentsemesters.studentcode) group dbo.studentsemesters.semid, dbo.listsemesters.year having (dbo.lists...

php URL structure /page.php vs /page -

this question has answer here: how remove file extension website address? 11 answers i have build few sites website. end .php. problem if want view page have type in website.com/page.php instead of website.com/page how make happen of main pages? there quick way of doing or have set forwarding of /pages /page.php? in cases achieved using mvc framework , routing. works in way don't access single .php file single web page show user. every request goes through 1 file , have router define routes , define action controller route invoke, , there choose view file show user. hard explain in few sentances. anyway using mvc nice url-s www.example.com/controller/action/param now if want remove .php extension files can put in .htaccess file: rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ $1.php ...

scala - how to set main class in SBT 0.13 project -

could guys please explain me how set main class in sbt project ? i'm trying use version 0.13. my directory structure simple (unlike sbt's documentation). in root folder have build.sbt following content name := "sbt_test" version := "1.0" scalaversion := "2.10.1-local" autoscalalibrary := false scalahome := some(file("/program files (x86)/scala/")) mainclass := some("hi") librarydependencies ++= seq( "org.scalatest" % "scalatest_2.10" % "2.0.m5b" % "test" ) eclipsekeys.withsource := true and have subfolder project single file hi.scala contains following code object hi { def main(args: array[string]) = println("hi!") } i'm able compile calling sbt compile sbt run returns the system cannot find file c:\work\externals\sbt\bin\sbtconfig.txt. [info] loading project definition c:\work\test_projects\sbt_test\project [info] set current project sbt_tes...