Posts

Showing posts from February, 2012

ember.js - How can I look up models in the console with Ember Data 1.0.0-beta.1? -

app.user.find() this.store.find(), how there console? you have possibility lookup through container, app.__container__.lookup('store:main').find('user') obviously, debugging, , maybe testing purpose. must never use in production code, because it's call global scope, bad practice in general. or think, if install ember-extension chrome ( https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi?hl=fr ), show model used in current route.

<Python, openCV> How I can use cv2.ellipse? -

opencv2 python have 2 function [function 1] python: cv2.ellipse(img, center, axes, angle, startangle, endangle, color[, thickness[, linetype[, shift]]]) → none [function 2] python: cv2.ellipse(img, box, color[, thickness[, linetype]]) → none i want use [function 1] but when use code cv2.ellipse(resultimage, circle, size, angle, 0, 360, color, 2, cv2.cv_aa, 0) it raise typeerror: ellipse() takes @ 5 arguments (10 given) could me? the fact python doesn't support multiple dispatch default doesn't here: having 2 functions same name different parameters not pythonic. question is: how cv2 guess version we'd call ? couldn't find explicit doc on that. anyhow, after experiencing same issue opencv 3.0.0-beta , python 3.4.2, i finally found out in case 1 of circle's point float , , although running official samples code 8 parameters, reason cv2 defaulted 5-args function. using int fixed problem, error message pretty misle

javascript - Validate checkbox with JS -

i'm searching while , can't found works me. this checkbox: <input type="checkbox" class="main_account_form_checkbox" id="terms" name="terms" /> i need validate checkbox, not know i'm doing wrong. steps in js file i'm working on: field: var terms = $('#terms'); on blur: terms.blur(validateterms); checking: form.submit(function(){ if(validateterms()) return true else return false; }); and function: function validateterms(){ if(terms.val().checked(false)){ alert("error!"); } } why can't verify checkbox? other fields works except this. can me please? don't check .val() , use is(":checked") if (terms.is(":checked")) //is checked

recursion - Scheme: recursive zeno function -

the following function sums 1/2^n until reaches 0 . can tell me whether or not need else statement, , how arrange parenthesis there no compile errors? (define (zeno n) (if (= n 0) (+ 0) (else ((+ (/ 1 (expt 2 n ))) ((zeno(- n 1))))))) i have hat, tea, , nothing while @ work. know time is. [dons code-review hat] firstly, if had properly indented code, read (define (zeno n) (if (= n 0) (+ 0) (else ((+ (/ 1 (expt 2 n))) ((zeno (- n 1))))))) if in scheme not if / then / else construct of c-like languages. it's ternary operator . in other words, else makes no sense in context. (define (zeno n) (if (= n 0) (+ 0) ((+ (/ 1 (expt 2 n))) ((zeno (- n 1))))))) you don't need use + return number; numbers self-evaluating. (define (zeno n) (if (= n 0) 0 ((+ (/ 1 (expt 2 n))) ((zeno (- n 1))))))) when have expression (foo bar

python - sending more commands to pexpect child after spawn -

i learning how use pexpect. goal getting list of directories, recreate directory in folder using pexpect. however, how send multiple of commands pexpect child in python loop? child.sendline() doesnt work me =[. have been respawning child, doesnt seem proper way of doing it. import pexpect child = pexpect.spawn("""bash -c "ls ~ -l | egrep '^d'""") child.expect(pexpect.eof) templist = child.before templist = templist.strip() templist = templist.split('\r\n') listofnewfolders = [] folder in templist: listofnewfolders.append(folder.split(' ')[-1]) folder in listofnewfolders: child.sendline("""bash -c 'mkdir {0}'""".format("~/newfolder/%s" % folder)) if bash -c , bash run command specify, , exit. send multiple commands, you'll need this: p = pexpect.spawn('bash') p.expect(prompt_regex) p.sendline('ls') # instance p.expect(prompt_regex) pri

.net - strings.formatnumber is limiting to 15 characters? -

we have .net visual basic project uses function strings.formatnumber used because of flexibility, namely number of decimal places allowed dynamic variable. have come across nasty bug in function seems round 15 digits so ? strings.formatnumber("123456789012345.66", 2,microsoft.visualbasic.tristate.true,microsoft.visualbasic.tristate.false,microsoft.visualbasic.tristate.false) results 123456789012345.00 ? strings.formatnumber("12345678901234.66", 2,microsoft.visualbasic.tristate.true,microsoft.visualbasic.tristate.false,microsoft.visualbasic.tristate.false) results 12345678901234.60 ? strings.formatnumber("1234567890123.66", 2,microsoft.visualbasic.tristate.true,microsoft.visualbasic.tristate.false,microsoft.visualbasic.tristate.false) results 1234567890123.66 ? strings.formatnumber("1234567890123456666.66", 2,microsoft.visualbasic.tristate.true,microsoft.visualbasic.tristate.false,microsoft.visualbasic.tristate.false) results 1234

javascript - hide function jquery does not work -

i have code display error when function valid_name not true , hide error when valid_name become true when blur; error display in div hidden. error appears doesn't disappear. function valid_name() { if (($("#name").length > 5) && ($("#name").length < 20)) { return true; } else { return false; } } $(document).ready(function() { $('#name').on('blur', function() { if (!valid_name()) $("#name_erors").text("invalid name").show(); if (valid_name()) $("#name_erors").hide(); }); }); i think $("#name").length should $("#name").val().length cause $('#name').length count element found, count character within need use $("#name").val().length so function should be function valid_name() { if (($("#name").val().length > 5) && ($("#name").

iphone - Is its ok to have multiple implementations per target in XCode? -

i have header file defines class interface: // myclass.h - included in targets // @interface myclass + (void) dothing; @end and have 2 different implementation files - 1 per target. // myclass+targeta.m - included in targeta // @implementation myclass + (void) dothing { nslog(@"targeta"); } @end // myclass+targetb.m - included in targetb // @implementation myclass + (void) dothing { nslog(@"targetb"); } @end are there issues approach? is there better or simpler way customise behaviour of each target? the method myclass themeing appearance of app. there several methods on myclass , several targets yes work fine, , have taken similar approach, except have used conditional compilation, 1 target exposing private functionality , target exposing public functionality, targets sharing same set of source files. however results of both our approaches same.

css - Centering a set of divs? -

i trying center js/jquery/ajax app screen here, such no matter size user's screen is, remain centered. right left-aligned: http://www.funtrivia.com/html5/indexc.cfm?qid=361927 no matter try, not center. when manage center outermost div, of inner stuff gets messed up. your html built wrong. seems positioned absolute , has left/top defined. not body tag has width: 790px; this can solved css. try removing positioning styles markup , set #game margin: 0 auto (the centering trick)

Mongo C# Driver and ObjectID JSON String Format -

is possible force jsonwritersettings output objectid { "id" : "522100a417b86c8254fd4a06" } instead of { "_id" : { "$oid" : "522100a417b86c8254fd4a06" } i know write own parser, sake of code maintenance, find away possibly override mongo jsonwritersettings . if possible, classes/interfaces should override? if you're ok using mongodb c# attributes or mapper, can this: public class order { [bsonid] [bsonrepresentation(bsontype.objectid)] public string id { get; set; } } that way, can refer type string (including serialization), when mongodb serializes it, etc., it's internally treated objectid. here's using class map technique: bsonclassmap.registerclassmap<order>(cm => { cm.automap(); cm.setidmember(cm.getmembermap(c => c.id); cm.getmembermap(c => c.id) .setrepresentation(bsontype.objectid); });

Excel Drop Down Created from c# project Bind change Event -

i have c# project creates excel workbook , worksheet , populates sheet data. i able add dropdown on fly , load data when cell double clicked. drop down used dropdowns provided excel dll (microsoft.office.interop.excel) in c# ex excel.dropdowns xldropdowns excel.dropdown xldropdown my issue how bind event dropdown selectedchange or change can see value selected in c# function. i have seen people talk macros, if neccessary how can pick value in macro function , return c#.

angularjs - Iterating objects or arrays inside ng-repeat -

the json i'm passing view has objects , arrays inside of it. example: { name: "test", projects: [ { name: "project1", tasks: "task1" } ] } using ng-repeat, can (key, value) in items , given you'd expect, each key , stringified version of object or array. is there 'best practice' iterating on objects , arrays inside ng-repeat? just following answer, able figure out. simpler realized. used ng-repeat items arrays. <div class="container" ng-repeat="item in items"> <table class="table table-striped table-bordered table-condensed"> <tr> <th class="span3">name</th> <td>{{ item.name }}</td> </tr> <tr> <th class="span3">accounts</th> <td> <ul ng-repeat="account in item.accounts"> <li>username: {{ account.username }}

sql - SUM total by Year -

i working on hr project receives export our sap system weekly. delivers weekly totals input general ledger specific account. company code g/l fiscal year local currency amount in lc 0020 4544000 2012 usd 575.00 0020 4544000 2012 usd 252.70 0020 4544000 2012 usd 89.75 0020 4544000 2012 usd 44.00 null null 2012 total null 86,422.58 0020 4544000 2013 usd 2,000.00 0020 4544000 2013 usd -2,000.00 0020 4544000 2013 usd 35.00 0020 4544000 2013 usd 35.00 null null 2013 total null 110,979.23 null 0004544000 total null 197,401.81 grand total null null null 197,401.81 (i removed several rows save space) what need sum of year. fiscal year a

jQuery image swap using animate, swaps image after fade back in -

i'm trying image fade out on hover, swap image src, fade in. i'm animating opacity fadein/out functions set element display:none , don't want happen. here's code: $('.imgswap').on({ 'mouseenter': function(){ var $nextimg = $(this).data('imagesource'); if ($nextimg != $('#floorplan').attr('src')) { $('#floorplan').animate({"opacity": "0"}, "fast",function () { $('#floorplan').attr('src',$nextimg).animate({"opacity": "1"}, "fast"); }); } } }); can see why second animate function not firing off after setting source? update: after further testing, , trying 1 of comments below, turns out animate firing after src has been set, if new image hasn't loaded in yet, old image stays visible until new 1 available. so... think need sort of 'loader' fires animate({"opacity": "1&quo

jquery - Rails & FilePicker gem - how to obtain metadata of uploaded files? -

i using filepicker gem , saving files amazon s3 bucket. save metadata of uploaded files database, stuck how - in documentation gem written: accessing filepicker file onchange: when dialog finishes uploading file, javascript code in onchange field run special 'event' variable. variable has fpfiles (or if not multiple, fpfile) attribute information files (jquery users: under event.originalevent). but still fighting way how implement fetching these data jquery - ask thing? upload s3 bucket working well, don't know how pull metadata of uploaded files. thank time i think there similar question in accepted answer too: using filepicker-rails gem, how can show users confirmation avatar has been succesfully uploaded? basecally can register onchange event on file input field, first parameter of called function event object holding meta data.

php - Google plus button is not showing up -

i have used code on website +1 <!-- place tag want +1 button render. --> <div class="g-plusone" data-size="tall"></div> <!-- place tag after last +1 button tag. --> <script type="text/javascript"> (function() { var po = document.createelement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(po, s); })(); </script> but shows on on pages without queries - example shows on index.php doesn't show on index.php?id=1 facebook , twitter buttons works fine. how can fix ? update i've found way how fix it. problem button showing changed style button moved top, left ( -1000px ). this so

r - Creating a "Lagged" Data Frame -

i have following data frame , want shift first 2 columns down. basically, want see 'lagged' data frame. there seems lot on how single column (see here ), nothing select of columns. my data = d1 <- data.frame(month = c("jan", "feb", "mar", "apr", "may", "june"), conv = c(1, 3, 6, 2, 3, 8), month = c("jan", "feb", "mar", "apr", "may", "june"), visit = c( 1, 2, 4, 8, 16, 32), click = c(64, 62, 36, 5, 6, 3)) d1 desired output = d2 <- data.frame(month = c("jan", "feb", "mar", "apr", "may", "june"), conv = c(1, 3, 6, 2, 3, 8), month = c(na, "jan", "feb", "mar", "apr", "may"), visit = c( na, 1, 2, 4, 8, 16),

python - Plotting using basemap and descartes doesn't show PolygonPatch -

Image
i can plot shapely buffered points so: import matplotlib.pyplot plt matplotlib.collections import patchcollection mpl_toolkits.basemap import basemap shapely.geometry import point descartes import polygonpatch fig = plt.figure() ax = fig.add_subplot(111) minx, miny, maxx, maxy = [-6.108398, 49.61071, 1.669922, 58.972667] w, h = maxx - minx, maxy - miny x, y = (-0.117588, 51.513230) correct = point(x, y).buffer(0.5) ax.add_patch(polygonpatch(correct, fc='#cc00cc', ec='#555555', alpha=0.5, zorder=5)) ax.set_xlim(minx - 0.2 * w, maxx + 0.2 * w) ax.set_ylim(miny - 0.2 * h, maxy + 0.2 * h) ax.set_aspect(1) ax.add_patch(patch) plt.show() this results in following plot: however, if try plot these points using basemap, don't appear: bounds = [-6.108398, 49.61071, 1.669922, 58.972667] minx, miny, maxx, maxy = bounds w, h = maxx - minx, maxy - miny fig = plt.figure() ax = fig.add_subplot(111) m = basemap( projection='merc', ellps = 'wgs84

spring mvc - java.lang.ClassNotFoundException: org.springframework.security.access.expression.SecurityExpressionHandler when using <security:authorize > tag -

i'm using spring security first time spring mvc , tiles. ok authentication using users/roles database, when add <security:authorize> tag make adaptation according user authenticated in views i'm getting error : java.lang.classnotfoundexception: org.springframework.security.access.expression.securityexpressionhandler org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1714) org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1559) java.lang.class.getdeclaredmethods0(native method) java.lang.class.privategetdeclaredmethods(unknown source) java.lang.class.getdeclaredmethods(unknown source) org.apache.catalina.util.introspection.getdeclaredmethods(introspection.java:127) org.apache.jasper.runtime.taghandlerpool.get(taghandlerpool.java:121) org.apache.jsp.web_002dinf.pages.jsp.indexadmin2_jsp._jspx_meth_security_005fauthorize_005f0(indexadmin2_jsp.java:262) org.apache.jsp.web_002dinf

c# - Superfluous Code Contracts suggestions -

i have following method: static bool textequals(string text, char[] array, int start, int length) { contract.requires(text != null); contract.requires(text.length != length || text.length == 0 || (array != null && start >= 0 && start < array.length)); if (text.length != length) { return false; } (var = 0; < text.length; ++i) { if (text[i] != array[start + i]) { return false; } } return true; } however, code contracts suggesting add following: contracts.requires(text.length == 0 || array != null || start < array.length); contracts.requires(text.length == 0 || start < 0 || start < array.length); i not seeing added benefit of these 2 additional requirements. path(s) covered existing requirements not cover? in particular, not see case array == null && start < array.length , allowed first suggestion. is th

uiviewcontroller - iOS - sharing data amongst ViewControllers -

i have 2 viewcontrollers purpose of landscape orientation my first vc (portraitvc) has multiple uitextfields (about 30 of them) i'm using nsnotifications observe when interface orientation changes , when pushes viewcontroller on screen (specific landscape) my question is, possible share uitexfields amongst both vc's if enter in portrait when go landscape mode don't lose text entered on textfield: , should work other way around too you're or guide appreciated i can think of couple ways handle this. first, reconsider choice use 2 different vcs handle orientation changes. how hard update ui on first vc appropriate in portrait? second, abstract data out struct or class can pass , forth between 2 vcs @interface mydatastorage : nsobject { nsstring* text1; nsstring* text2; nsstring* text3; nsstring* text4; } lastly, create protocol keep 2 vcs in sync: @protocol vcsync : nsobject { - (void)updatetextbox1:(nsstring*)contents; - (vo

.htaccess - Apache redirect is failing for Laravel -

i have mod_rewrite enabled on apache2 , allowoverride all in default file. apache (after restarting) still can't seem redirect when given pretty url laravel. works (returns: users!) : localhost/laratest/public/index.php/users doesn't work (404) : localhost/laratest/public/users my .htaccess: (i've tried 1 suggested in documentation no avail) <ifmodule mod_rewrite.c> options -multiviews rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] </ifmodule> laravel routes.php: route::get('/', function() { return view::make('hello'); }); route::get('users', function() { return 'users!'; }); i using default lamp stack , configuration in ubuntu. ideas why isn't working? have set rewritebase /laratest/public ? options +followsymlinks -indexes rewriteengine on rewritebase /laratest/public rewritecond %{request_fil

What happens when bigquery upload job fails after loaded a portion of the JSON file? -

as title mentioned, happens when start bigquery upload job and, let's say, after loading 50% of rows in json file job failed. bigquery rollback of load job or left 50% of data loaded? i appending data daily single table , keeping duplicate-free important. using http rest api bigquery appends data atomically. never half of data in table if load fails. if job completes successfully, of data show @ once. there 2 additional tricks can use prevent duplicates: specify job id load job. imagine pull network cable mid way through starting job... how know whether succeeded? specifying job id lets job later if job creation request fails. perform loads temporary table, , specify write_truncate writedisposition. means can run import jobs idempotently temporary table, , if don't know whether job succeeded, run one, , overwrite data. once have load job completes successfully, run table copy job writedisposition write_append append new data main table.

Selenium / Python - Selecting via css selector -

issue: can not select css selector specific element. need verify registered user can change password successfully. have tried different attributes of class call it. result exception error in method when trying first 2 examples. final try calls first class instance , resets password fields (fail). tried: driver.find_element_by_css_selector("value.update").click() driver.find_element_by_css_selector("type.submit").click() driver.find_element_by_css_selector("input.test_button4").click() objective: i need select items share same class. can see below, class shared. form id="changepw_form" name="changepw" action="#" method="post"> <div class="field3"> <div class="field3"> <div class="field3"> <input class="test_button4" type="reset" value="reset" style"font-size:21px"=""> <input class="test_bu

graphics - How to have an appropriately sized text within image? -

let's have image dimensions of x-by-y. going import latex document , make width 8.6 centimeters. how should make sure text on image looks similar default 12 pt in final document? this not programming question anyway: open image > image size dialog, uncheck "resample" checkbox (to make sure pixel dimensions of image not modified), , set width of image 8.6 cm. when add text, set font size 12 pt.

basic strings and variables python -

write function, called introduction(name, school) takes, input, name (as string) , school, , returns following text: “hello. name name. have wanted go school.” this code def introduction("name","school"): return ("hello. name ") + str(name) + (". have wanted go the") + str(school) + (".") i'm getting error: traceback (most recent call last): file "none", line 5, in <module> invalid syntax: none, line 5, pos 23 def introduction("name","school"): should be def introduction(name,school): the names provide formal parameters of function variables values of actual parameters assigned to. including literal value (like string) wouldn't make sense. when call or invoke function, provide real value (like literal string) def introduction(name,school): return ("hello. name ") + str(name) + (". have wanted go the") + str(school) + (".&quo

jqGrid is stretching row height to fit grid height -

it appears when jqgrid has few rows, increases height of rows fill available space. there way disable behavior? probably use height: "auto" or height: "100%" option of jqgrid. can use numeric value specify height of grid in pixel. way default value of height parameter 150 (see the documentation ).

django - Phantom ForeignKey to similar model representing a DB view -

i'm trying 'phantom' foreignkey reference model view on backend. view assembles data includes data originating table(so share primary key). here's simplified version of we've had setup(view more complex model, chosen design way). class vspouse(models.model): person_id = models.integerfield(primary_key=true) ... class person(models.model): person_id = models.autofield(primary_key=true) spouse = models.foreignkey(vspouse, db_column = 'person_id', to_field='person_id', null=true) ... now, since tables designed on backend before models, have never used syncdb . because of that, we've never noticed problem , things work expected. however, we're starting develop django tests, , when begins build test db, see following: $ python2 manage.py test misc --traceback creating test database alias 'default'... destroying old test database 'default'... traceback (most recent call last): file "/usr/

ios - Parse Issue: Module 'not found' -

in xcode, keep getting strange error. using github library: https://github.com/tapsquare/tslibraryimport and using example code in mediapicker delegate method so: - (void)mediapicker: (mpmediapickercontroller *)mediapicker didpickmediaitems:(mpmediaitemcollection *)mediaitemcollection { (mpmediaitem *item in mediaitemcollection.items) { nsurl* asseturl = [item valueforproperty:mpmediaitempropertyasseturl]; nsurl* destinationurl = nil; //file url location you'd import asset to. tslibraryimport *import = [[tslibraryimport alloc] init]; [import importasset:asseturl tourl:destinationurl completionblock:^(tslibraryimport *theimport) { }]; } [mediapicker dismissviewcontrolleranimated:yes completion:nil]; } on importasset line, keep getting error: parse issue: module 'importasset' not found. now have dragged in tslibraryimport.h/.m in , made sure .m in compile sources still shows error. does know why happening? do

merge - Hibernate calling setter method -

when change value in inputtext field(which populated db) , merge, hibernate doing not understanding. let's input text field populated string "new york". when go change "boston", order getter , setter methods being called in: property get: new york property get: new york property set: boston property set: new york it not change value boston , keeps value new york. input text field references field db. here setter , getters: @column(name = "city", length = 32) public string getcity() { system.out.println("property get: " + city); return this.city; } public void setcity(string city) { system.out.println("property set: " + city); this.city = city; } any idea why happening?

javascript - how to add tinymce listbox values in windowmanager -

i open windowmanager , add textfield , listbox: editor.windowmanager.open({ title: 'insert caption', body: [ {type: 'textbox', name: 'text', label: 'text', 'multiline': 'true', 'minwidth': 450, 'minheight': 100}, {type: 'listbox', name: 'align', label: 'align', 'values': ['pull-left','pull-right']} ], the listbox displayed, not values. in documentation ( http://www.tinymce.com/wiki.php/api4:class.tinymce.ui.listbox ) states: "array values add list box." what doing wrong? i found out while searching in official tinymce plugins. how it's done: {type: 'listbox', name: 'align', label: 'align', 'values': [ {text: 'left', value: 'left'}, {text: 'right', value: 'right'}, {text: 'center', value: 'center'}

python - South unable to create new field because field does not exist -

i'm trying use south add new urlfield model, like: class document(models.model): text = models.textfield() reference_page = models.urlfield(blank=true, null=true) source_page = models.urlfield(blank=true, null=true) # new field however, when run python manage.py schemamigration myapp --auto error: databaseerror: column myapp_document.source_page not exist line 1: ...ext", "myapp_document"."reference_page", "myapp_doc... i'm using postgresql db backend. initialized app south , have run migrations it. i've made sure django , south installs date. why giving me error now? edit: oddly, if manually created column in database, schemamigration call succeeds, of course migrate call fails until manually remove column. bizarre. i have been dealing issue couple months. link shared montiniz in comment on other answer had 0-voted answer resolved issue! i'm posting here else.. build community of knowledge , that.

backbone.js - Backbone repeated templates with different types -

i trying figure out best way structure following using backbone views , templates. have collection of "messages", messages may of different types, each it's own view. so, underlying collection might like: { { id: 1, name="message one", type="customer-message" }, { id: 2, name="message two", type="support-message" }, { id: 3, name="attachment one", type="attachment" } } and resulting page output like: <ul> <li class="message customer-message"></li> <li class="message support-message"></li> <li class="message attachment"></li> </ul> such each different li class have entirely different structure/content. what i'm trying figure out how set templates , views a) handle nesting , b) handle fact inner template differs depending on type. <script type="text/template" id="chat-template">

eclipse - Why is there a java.lang.NullPointerException when referencing Image from a different class? -

i creating clone of breakout pc, earlier tonight found there nullpointerexception being thrown , shown in console. oddly, method run() told catch exceptions occour , show stacktrace , ignore them, time freezes game @ start, int log, keypresses still tracked, nothing happens in-game. obviously, game didn't abort, not repaint. it seems coming 1 line of code: if (by >= bricks[0].y && <= bricks[0].y + bricks[0].img.getheight(null) && bx >= bricks[0].x && bx <= bricks[0].x + bricks[0].img.getwidth(null)) { here log , stacktrace (the entire thing): game starting, menu boot. menu loaded, jframe visible. running thread. play clicked, start game initialization. creating jframe. jframe created , visible. starting game thread initialize user variables. initialized user variables. initialization complete, start game. java.lang.execption in line 86/87, class game. stacktrace: java.lang.nullpointerexception @ game.move(game.java:195) @ ga

Why Won't Any C# JSON Class Generators Process this JSON Object? -

i've tried 3 different json class generators, error when try generate c# class following json output: { "status": "request_status", "language": "document_language", "url": "requested_url", "text": "document_text", "entities": [ "entity": { "type": "detected_type", "relevance": "detected_relevance", "count": "detected_count", "text": "detected_entity" "disambiguated": { "name": "disambiguated_entity", "subtype": "entity_subtype", "website": "website", "geo": "latitude longitude", "dbpedia": "linked_data_dbpedia", "yago": "linked_data_yago", "

php - i want to get data from another website and display it on mine but with my style.css -

so school has annoying way view rooster. have bypass 5 links rooster. this link class (it updates weekly without changing link) https://webuntis.a12.nl/webuntis/?school=roc%20a12#timetable?type=1&departmentid=0&id=2147 i want display content page on website own stylesheet. i don't mean this: <?php $homepage = file_get_contents('http://www.example.com/'); echo $homepage; ?> or iframe.... i think can better done using jquery , ajax. can jquery load target page, use selectors strip out need, attach document tree. should able style anyway like.

java - Trouble laying out ImageViews programmatically in RelativeLayout -

i'm trying add 5 or imageviews relativelayout, each new 1 being right of previous one. however, (apparently) of them stacked on each other, if align_parent_left. relevant code snippet: imageview[] foo = new imageview[levels]; (int = 0; < levels; i++) { foo[i] = new imageview(context); layoutfoo.addview(foo[i]); foo[i].setid(10 + i); if (i == 0) { relativelayout.layoutparams fooparams = (relativelayout.layoutparams) foo[i].getlayoutparams(); fooparams.addrule(relativelayout.align_parent_left); foo[i].setlayoutparams(fooparams); } else { relativelayout.layoutparams fooparams = (relativelayout.layoutparams) foo[i].getlayoutparams(); fooparams.addrule(relativelayout.right_of, foo[i-1].getid()); foo[i].setlayoutparams(fooparams); } } any hints i'm doing wrong? shouldn't matter imageviews don't have width (because haven't assigned bitmap them) yet, right? edit: problem turned out not

php - Undefined Index If I Do Not Check Checkbox -

i seem have bizarre happening here. if check checkbox on form php script runs perfectly. if don't check box php reports undefined index on variable. that's using iis localhost, checking things. on web published identical script works no matter what. well, virtually identical. have locally added variable 'test' post-ed php , compared hard coded value. that's all. here's html checkbox: <tr> <td>publish comment?</td> <td><input name="publishok" value="no" type="checkbox"> check box spanstyle="font-weight: bold;">not</span> publish</td> </tr> <tr> and here's php variable, 'publishok' : $ip = $_server["remote_addr"]; $publishok = $_post['publishok']; $test = $_post['test']; if ($test != 'park') die ("wrong input. sorry. go back, try again"); i suspected editor pspad adding spurious (and invisible

php - Display specific data from external website -

let's external website: title header banner content1 content2 footer now want know how copy specific part of external website , paste on own this: my title header banner content external content2 footer i want html code can make own stylesheet external content2 i hope clear enough. i've tried using phps file_get_html() its not entirely clear on attempting do. remember can see html , javascript on else's web site. if want make static copy of web page including cascading style sheets (css) , java scripts, open web page of interest on browser (i'm thinking firefox) use browser tools 'save page as' , save local hard drive. save comes scripts , css files. you can @ static code, @ div classes , decide css elements hoping use site. recommend study on how css works (selector type element, selector type universal, selector type id declarations, , selector type class declarations) highly possible web site looking @ designed 'div class

how to set min-height of row of blocktable in rml -

how set min-height of row of blocktable in rml ? read rml-reference , can't find related content. found attr: rowheights , seems set fixed height, content flow out. wanna set base height,and when content increases height of row increases too. thanks in advance! i don't think that's possible v7 or lower (v8/trunk no idea). as you've stated right, rowheights sets fixed heights rows , without attribute have auto-sized heights.

swing - Java - Separate Listener Class throws NullPointerException -

apologize long post, wanted detailed possible there's better chance people understand i'm trying convey: ok, overview of problem i'm trying make program simulates cash register. (this "for-fun" project). way set is: cashregister: main class starts program, serves main window everything. public class cashregister extends jframe { ... } other classes: serve jpanels provide different components of main cashregister window. example: public class northpanel extends jpanel { ... } then in cashregister class: add(new northpanel(), borderlayout.north); etc. basically, have jtextfield in northpanel class called pricefield holds value of price user enters. have separate class (keypad) extends jpanel , serves number keypad in center of main window. in cashregister: add(new northpanel(), borderlayout.north); add(new keypad()); // (default borderlayout center) one of problems have run created 1 class, eventhandler, serve listener class entire pr

javascript - Separate check box value to separate text area -

<script> var itemsadded = array(); function movenumbers(text) { var = itemsadded.indexof(text) if ( >= 0) { itemsadded.splice(i,1); } else { itemsadded.push(text); } document.getelementbyid("result1").value=itemsadded.join(" "); if ( >= 0) { } else{ itemsadded.push(text); } document.getelementbyid("result2").value=itemsadded.join(" "); } $(function() { (i=0;i<10;i++) { console.log(i); $("body").append("<input type='checkbox' name='add' value='" + + "' onclick='movenumbers(this.value)'/> checkbox" + + "<br/>"); } }); </script> <table width="95%" height="24" border="1" align="center"> <tr> <th><h2>selected image 5x7</h2></th> <tr> <td> <textarea rows="4" cols="70" name="add" id="result1" style=&qu

lastIndexOf in JSTL or JSP -

can figure lastindexof() function in jstl or jsp ? found method int indexof(java.lang.string, java.lang.string) in jstl. want use lastindexof() function. other way ?any suggestion appreciate.. how using fn:split , sum lengths ( fn:length ) of components excluding last one. it's better logic in backend, add additional properties object.

mysql - sql left join select all records from left table even if no records in rigth table -

i trying run following query : select ifnull(sum(item_actual_qty),0) + b.item_opening_balance closing transaction_inventory left join inventory_master b on b.item_code = a.item_code , b.company_code = a.company_code a.item_code = 2222 , a.company_code = '52889497-5b6b-403d-8f83-224e3c7759b4' , a.trans_type_name not in ('sales order','purchase order') , a.trans_date < '2010-04-01' ; how select records inventory_master if there not records in transaction_inventory ? giving null value b.item_opening_balance should give actual item opening balance master table. putting sub query select ifnull(sum(item_actual_qty),0) + (select item_opening_balance inventory_master item_code = a.item_code) closing transaction_inventory a.item_code = 2222 , a.company_code = '52889497-5b6b-403d-8f83-224e3c7759b4' , a.trans_type_name not in ('sales order','purchase order') , a.trans_date < '2010-04-01' re

url Canonicalization for wordpress site -

i have website drwagenberg.com can open on both urls http://www.drwagenberg.com/ http://drwagenberg.com/ tried different methods redirection in .htacess file here code .htacess file redirect 301 / http://www.drwagenberg.com/ # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{http_host} ^drwagenberg\.com$ [nc] rewriterule ^(.*)$ http://www.drwagenberg.com/$1 [l,r=301] </ifmodule> # end wordpress i want cannoniclize url http://drwagenberg.com/ whenever user type url automatically makes http://www.drwagenberg.com/ keep in mind website built in wrodpress. <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] </ifmodule> try this. , rid of top line redirect 301 / http://www.drwagenberg.com/

java - Contacts management implementation on Android -

i'm planning implement app able manage user's contacts, things the api defined w3c but i'm totally new android/java, not sure start. is there library or api can use? or suggestions? you can make use of android contacts provider api managing user's contacts. please refer this link , contacts contract .

c# - ASP.NET Web API Generate all parameters from model - help pages -

i'm busy creating web api (inside asp mvc4 application). using library suggested on asp.net site generating documentation ( http://www.asp.net/web-api/overview/creating-web-apis/creating-api-help-pages ). my problem if parameter model, can't specify properties model contains in generated pages. here example: model: public class testmodel { property string firstname {get;set;} property string surname {get; set;} property boolean active {get;set;} } action: /// <summary> /// test action /// </summary> /// <param name="model">this model</param> <-- works /// <param name="firstname">this first name </param> <-- doesn't work /// <param name ="model.surname">this surname</param> <-- doesn't work public httpresponsemessage post(my.namespace.models.testmodel model) { ... } only parameter model gets generated. i took @ xml document gets generated documentati

cookies - can't tracking google analytics in an iframe -

i have site commonly included other sites via iframe. not care analytics parent sites. want use google analytis within iframe track content. ie: domain1.com , domain2.com both include iframe pointing mydomain.com. i have google analytics inside iframed mydomain.com. in ie8 , ie9, running issue __utm gif doesn't fire. assumption because of third party cookie. however, not trying connect mydomain.com domain1.com or domain2.com. want know whats happening inside iframe. please help.

c# - Store property of button which launched action -

on form1 want store name of button called form can execute code depending upon button click button bt1=new button(); button bt2=new button(); private void b1_click(object sender, eventargs e) { form1 f1=new form1(); f1.show(); } private void b2_click(object sender, eventargs e) { form1 f1=new form1(); f1.show(); } add property or member in form1 called callername. set in constructor.

Multiple file upload in PHP - rename files -

i'm beginner in php , doing project in php. want upload images(maximum 4 image files only).i used following code upload images. <script type="text/javascript"> count=1; function add_file_field() { if(count<4) { var container=document.getelementbyid('file_container'); var file_field=document.createelement('input'); file_field.name='images[]'; file_field.type='file'; container.appendchild(file_field); var br_field=document.createelement('br'); container.appendchild(br_field); count++; } } </script> <div id="file_container"> <input name="images[]" type="file" id="file[]" /> <br /> </div> <br><a href="javascript:void(0);" onclick="add_file_field();">add</a> i used following code single file upload.it's working <?php if ((($_files["file"]["type"] == &quo

Python interactive shell running copy.py on current directory? -

i have script named copy.py on current directory following content: #!/usr/bin/env python3 print("ahoy, matey!") if run python interactive shell , action raise exception (e.g. referring non-existent variable), surprise, sentence "ahoy, matey!" got printed. when rename copy.py script else, e.g. script.py , no longer behaves that. question is, why interactive shell have call copy.py on error? behavior expected and/or documented somewhere? thanks! when python imports module, module search path order is: the directory containing input script (or current directory). pythonpath (a list of directory names, same syntax shell variable path). the installation-dependent default. now, when raising exception, python runs specific code. code tries import copy python module instead import module , print string in it. why shouldn't use names names of standard python modules.

How to create an ASP.net MVC Project with aspx engine as default -

i trying create new project asp.net mvc application (2.0) in ms visual studio 2008. it creating application razor default view engine. not asking choosing view engine, asking whether test project required or not please me on this mvc 2.0 doesn't have razor engine. razor engine exist in mvc3 on wards however on switching view engines topic might you http://dotnet.dzone.com/news/switching-aspx-razor-view

javascript - Cannon.JS make walls solid -

i making go of three.js , cannon.js, stuck being able make walls solid, or solid doesn't move , hold player back. http://www.trepaning.com/3js/sea3d/elviscollidewalls.html here code have far. insight appreciated. prefer figuring stuff out on own, 1 thing of making walls solid holding me @ moment, , appreciate info me on hump. if ( ! detector.webgl ) detector.addgetwebglmessage(); var initscene; var margin = 10; var marginside = 0; var width = window.innerwidth || ( 2 + 2 * marginside ); //var width = window.innerwidth/3 || ( 2 + 2 * marginside ); //var height = window.innerheight/3 || ( 2 + 2 * margin ); var height = window.innerheight || ( 2 + 2 * margin ); var screen_width = width -2 * marginside; var screen_height = height -2 * margin; var far = 10000; var day = 0; var stats, camera, scene, renderer; var mesh, geometry; var sunlight, pointlight, ambientlight, hemilight; var parameters var clock = new three.clock(); var inrender = true; var inresize = false; //