Posts

java - Last square of 8x8 grid not drawn, using two nested FOR loops -

i'm having trouble understanding why code isn't working. should display checkerboard grid 8x8, but last square doesn't drawn ! idea why? i searched see if had been asked before, , didn't find anything. in advance! code: /* * file:checkerboard.java * ---------------------- */ import acm.graphics.*; import acm.program.*; public class checkerboard extends graphicsprogram { int row, column, x, y; public void run() { // checkerboard (row = 0; row < 8; row++) { (column = 0; column < 8; column++) { // x, y, x width, y width add(new grect(x, y, 50, 50)); x = column * 50; y = row * 50; } } } } btw: book i'm reading asks use 2 nested loops ( "the art , science of java" , chapter 4, exercise 11, cs-106a) you need set x , y before drawing rectangle. otherwise, last rectangle not going display: for (row = 0; row <...

What design pattern is this code in Javascript? -

this question has answer here: why write “.call(this)” @ end of javascript anonymous function? [duplicate] 4 answers what kind of design pattern , significance of using closure? (function(){ // code here }).call(this); edit then difference between above code , following this keyword still refer same object in both ways. (function(){ // code here })(); thats invoked function expression. more info here: http://benalman.com/news/2010/11/immediately-invoked-function-expression/ the purpose run code while protecting scope (so variables declared within don't leak out global scope. update call sets value of this function being applied on. without it, value set window object, there set outer scope.

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

in javascript code, download bunch of links of images, , draw them canvas in grid theme. number of links there are, , set width , height of canvas accordingly, there 200 images per row. height based on total number images. problem noticing based on height use, images show on canvas. example, if set height 12 rows, see images, if set on that, no images show up. when setting in 1 row, images show in firefox 23. ie9 , chrome29 shows nothing. does know if there wrong here, or stable way drawing lots of images large canvas? thanks. function onprofilesuccessmethod(sender, args) { alert("request arrived"); var listenumerator, piccount, item, picobj, path, office, ctx, x, y, imageobj; listenumerator = listitems.getenumerator(); piccount = listitems.get_count(); var w = 125; var h = 150; var rl = 200; var canvas = document.createelement('canvas'); canvas.id = "picgallery"; canvas.width = w * rl; canvas....

mysql - Rails refuses to insert one field into the database -

basically grab id of element table , insert another. vuln_id = activerecord::base.connection.execute("select blah ...") pid = vuln_id.first puts "==============================" puts pid # echos id puts "==============================" if pid.empty? puts "pid empty" end rd = report.new(:plugin_id => pid, :report_id => report_id) rd.save() in rails console, when report.dbaction(params) it runs model , here output (0.3ms) select statement..... ============================== 186 ============================== (3.0ms) begin sql (0.3ms) insert `report_data` (`created_at`, `report_id`, `updated_at`) values ('2013-07-10 22:03:59', 6, '2013-07-10 22:03:59') (33.9ms) commit it inserts report_id doesnt insert pid value database, though exists. why this? quick edit: plugin_id exists in table. triple checked. here rest of model file looks like class report < activerecord::base ...

javascript - Count length of each class -

i have below code in this fiddle . html <span class="myname">john smith</span> <span class="myname">john smith</span> <span class="myname">john smith</span> <span class="myname">john smith</span> <span class="myname">john smith</span> <span class="myname">john smith</span> javascript $('.myname').each(function(){ var text = $(this).html().split(' '), len = text.length, test = $(this).val().length, result = []; console.log('outside: ' + test); for( var = 0; < len; i++ ) { result[i] = '<span class="name-'+[i]+'" >' + text[i] + '</span>'; console.log('inside: ' + test); } $(this).html(result.join(' ')); console.log('after...

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -

i have have cloudera cdh3u4 cluster setup. have secondarynamenode daemon running on 1 of nodes. i have ensure user has root access node on cluster (for example, datanode not have other daemons running) should not able start instance of secondarynamenode daemon on node (thereby having 2 secondarynamenodes on cluster) how can achieve this? thanks in advance. add property hdfs-site.xml namedfs.secondary.http.address valuesecondarynamenode-host address or ip:50090

gruntjs - Grunt usemin task to replace resources -

using gruntjs , possible replace resources in html file remote path (or perhaps anypath)? i'm particularly interested in doing usemin plugin. possible sample functionality: before <!-- build:js //cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.3/angular.js --> <script src="/lib/angular.js"></script> <!-- endbuild --> after <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.3/angular.js"></script> this idea similar usemin plugin skips concatenation of enclosed resources new file of specified name. in other words, replaces enclosed html single resource of specified path. i wrote grunt-dom-munger because found usemin specific. can use grunt-dom-munger alter html see fit , read script tags , send concat/uglify/etc. grunt-dom-munger

ios - Interactive UITableViewController in container -

working on , ios app have set of: rootviewcontroller hooked uitableviewcontroller via [self addchildviewcontroller:tablevc]; with tablevc.view subview of rootviewcontrollers view. rootvc has uipangesturerecognizer used animate pan left showing table. this works fine , table great static view, when try fire - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath by tapping on cell, never called. have checked if taps being accidentally registered gesture recogniser aren't. do need somehow tell rootvc when tableview on screen send taps child uitableviewcontroller? thanks rdelmar helping me solve advice on using cliptobounds property of uitableview's superview. this showed uiviews being revealed through panning werent responding touches out of bounds of superview. i solved adding view 'spanview' appropriate dimensions envelope subviews. after responded touches expected. the hiearchy ended being: ...

escaping - Is it properly quoted when I using '*' or '**/*' in bash? -

find -name '*.jpg' -print0 | xargs -0 qiv qiv **/*.jpg both safely escaped , delivered qiv ? yes. in first case, find expanding wildcard internally, , delivering results xargs expects them. in second, shell expanding them , passing each match separate argument. both correct (assuming shell support ** , , command line length maximum isn't exceeded).

Oracle ODP.net Managed vs Unmanaged Driver -

Image
are there performance benchmarks between managed , unmanaged oracle odp.net drivers? (i.e. there advantage moving managed driver other architectural/deployment simplicity) i share results. think small lack of performance worth compared easiness of deployment. note: seg means seconds. sorry that. of course simple test, , there several topics not covered connection pool, stability, reliability , on... it important mention, scenarios executed 100 times. time quantities average of 100 executions.

javascript - Programmatically apply media query without changing iframe size -

i have small iframe houses larger content page. iframe has overflow: scroll can scroll around , see entire content page, however, content page css has media queries getting triggered because of iframe's small size, though actual page larger. is there way either manually pick when apply these query styles or trick iframe thinking it's full width of content without changing size? the option i've thought of break media queries separate files , programmatically change additional link's href point @ them needed, seems kind of messy. thanks in advance

css - bootstrap nav pull-right makes header zoom off screen -

upon zooming in mobile header zoomed in section of header class nav pull-right gets cut off screen. how can fix this? perhap fixing header size width of screen? <nav> <ul class="nav pull-right"> <div class="signinform" <% if request.path == root_path && current_user.nil? %> style="padding-top: 18px;" <% end %>> <%= form_for(:session, url: sessions_path, :html => { :class => "form-inline"}) |f| %> <input id="session_email" name="session[email]" type="text" class="input-medium" placeholder="email"> <input id="session_password" name="session[password]" type="password" class="input-medium" placeholder="password"> <button type="submit" class="btn btn-small btn-primary">sign in</button> ...

winforms - Windows Form not changing underlying Entity Data -

Image
can see simple mistake can't? i opening form allow assigning job numbers invoices not have any. this code in applications main form handles this: dim unknownjobs = pur in context.purchases pur.senttomyob = false andalso pur.job.jobnumber = string.empty select pur if unknownjobs.any frmjobs2.jobsbindingsource.datasource = (from j in context.jobs1 order j.jobnumber select j).tolist frmjobs2.purchasesbindingsource.datasource = unknownjobs progress.hide() if frmjobs2.showdialog = windows.forms.dialogresult.ok context.savechanges() end if end if this form gets opened relevant column details displayed the code behind simple , consists of: public class formjobs2 ''' <summary> ''' ok clicked ''' </summary> ''' <param nam...

javascript - Determin Type of Input - jQuery -

i needing determine type of element, possibly identified id property of it. for example, in following form... <form id='my-form'> <input type='text' id='title' /> <textarea id='comment'></textarea> </form> i have way identify $('#title') text box. after searches, tried thing this, returns undefined . $('#title').type but thing seems work, don't know why... $('#my-form :input').each( function() { alert(this.type); } ); the above give text , textarea guess. when use first, gives undefined. given id of element, how can find type of it. thank in advance. input normal tag, should use: $('#my-form input').each( function() { alert(this.type); }); this return undefined: $('#title').type because $("#title") jquery object , type property of html element. can html element jquery object this: $('#title').get(0).type ...

How to append two image tags in div tag using jQuery -

iam trying place 2 image tags different images/src values init, in end 2 image tags have been appended same src value instead of different. may know s wrong append: $("<div/>", { "id": 'card'+i, "class": blockarr[k], html: $("<img src='"+key+"'/><img src='_ls-global/layout-images/layout2.png'/>") }).appendto("#gtable"); any ideas ? thanks you can supply plain html in case: demo $("<div/>", { id: 'card'+i, class: blockarr[k], html: "<img src='"+key+"'/><img src='_ls-global/layout-images/layout2.png'/>" }).appendto("#gtable");

jquery - Closing dialogs in multipage template -

trying work out how close dialog , return calling page (where page div within multipage template). the dialog defaults first page div (back button) or # (x button) - need close , remain on referring page/div. tried this: $('#dialog').live('pagehide', function (e) { $.mobile.changepage("#full-map"); }); but still flick #index before transitioning #full-map. there can intercept close function itself? i trigger dialog so, on clicking google map marker: google.maps.event.addlistener(marker, 'click', function () { $.mobile.changepage("#dialog", { transition: "pop", reverse: false, changehash: false, }); }); you missing role:dialog? full api here $.mobile.changepage( "#mydialog", { role: "dialog" } ); i think keep site scrolling main page, can add button , close dialog javascript instead of relying on default dialog close button. $( "#mydialog...

javascript - Execution order of multiple setTimeout() functions with same interval -

consider following javascript code: function(){ settimeout(function() { $("#output").append(" 1 "); }, 1000); settimeout(function() { $("#output").append(" 2 "); }, 1000); } you can see example on jsfiddle . can sure value of #output "one two" , in order? usually, handle problem this: function(){ settimeout(function() { $("#output").append(" 1 "); $("#output").append(" 2 "); }, 1000)); } but can not way because messages server tells me function execute (in example append "one" or append "two" ), have execute small delay. i tested code in internet explorer 9, firefox 14, chrome 20 , opera 12, , output "one two" , can sure case? the spec here . my interpretation of settimeout step 8 in section 7.3 execution order is supposed guaranteed. however, investigated issue because when windo...

php - Error using composer in Windows -

i need use composer in windows installed xampp, php 5.4.7. everytime run $ php composer.phar install i keep getting error: [composer\downloader\transportexception] " https://packagist.org/packages.json " file not downloaded: failed open stream: system detected invalid pointer address in attempting use pointer argument in call. what issue ? please.

syntax error - Importing a file with LESS won't see the @filename var -

i'm trying load .less file main theme, filestructure: main.less themes/pink.less themes/yellow.less themes/blue.less i'm using mixin retrieve selected theme: .theme(@filename){ @import 'themes/@{filename}.less'; } .theme('pink'); it doesn't work , error: syntaxerror: variable @filename undefined .theme('pink'); i'm used same background images without getting errors, i'm wrong? unfortunately less.js throws error describe imports .less files (it works fine imports .css files), if define variable in in mixin parameter/attribute, works if define variable directly inside (localy) or outside mixin (globaly). example, should work: @filename: 'pink'; .theme(){ @import 'themes/@{filename}.less'; } .theme(); here link discussion plan of implementing has been discussed while ago , , seems longterm goal have version working well, hasn't happened yet ^_^ however, if want load theme accordin...

sql - Selecting a column from table including the default value -

i wonder if can have query gives me values of column including default value column. doable? i dont want use union or joins. for example, have table emp create table emp (emp_name varchar2(20) default 'xxx'); and insert emp(emp_name) values('a'); insert emp(emp_name) values('b'); and when query like select emp_name emp; i want result a b xxx business logic: table emp master table list of employees. in ui screen have oraganization task eg: org_task have ui screen 2 columns, task_name, assinged_employee , assined_employee column not nullable various other reasons. so, when want create new task, enter task, description in column , need choose employee drop down in assined_employee column. in case if task cannot assigned @ point of time of employees, want drop down have default value called tbd. the source dropdown query selects employee names emp table. want append tbd values in dropdown it's not possible using simple sel...