Posts

Showing posts from September, 2012

java - How to avoid IllegalStateException when referring to request attributes outside of an actual web request -

i working on solution should if in middle of web request or else if not. what doing @autowired private httpservletrequest request; and trying access variable: request.getrequesturi() but getting java.lang.illegalstateexception: no thread-bound request found: referring request attributes outside of actual web request... i avoid exception , somehow ask httpservletrequest weather or not in web request or not. is there way it? example: additional info: @override public void trace(string msg) { if (loggerfactory.isregisteredurl(request.getrequesturi())){ loggerfactory.getcustomelogger(request.getrequesturi()).trace(msg); return; } nativelogger.trace(msg); } you should (not tested) use requestcontextholder.getrequestattributes() : return requestattributes bound thread. returns: requestattributes bound thread, or null if none bound so, if method returns null, current thread not handling request. if returns non-

PHP highlight search terms in MySQL -

i have search code: <?php //members $sql="select * members "; $sql.="forename '%".$_get["s"]."%' or "; $sql.="surname '%".$_get["s"]."%' "; $rs=mysql_query($sql,$conn); if(mysql_num_rows($rs) > 0) { echo '<table width="100%" border="0" cellspacing="5" cellpadding="5"> <tr> <td colspan="3"><h3>members</h3></td> </tr> <tr> <td><strong>member name</strong></td> <td><strong>d.o.b</strong></td> <td><strong>age</strong></td> </tr>'; while($result=mysql_fetch_array($rs)) { //work out age of each member $sql2="select timestampdiff(year,concat(dob_year, '-', dob_month, '-', dob_day),curdate()) years, (timestampdiff(m

Debugging C program (int declaration) -

i'm still learning assembly , c, now, i'm trying understand how compiler works. have here simple code: int sub() { return 0xbeef; } main() { int a=10; sub(); } now know how cpu works, jumping frames , subroutines etc. don't understand program "store" local variables. in case in main's frame? here main frame on debugger: 0x080483f6 <+0>: push %ebp 0x080483f7 <+1>: mov %esp,%ebp 0x080483f9 <+3>: sub $0x10,%esp => 0x080483fc <+6>: movl $0xa,-0x4(%ebp) 0x08048403 <+13>: call 0x80483ec <sub> 0x08048408 <+18>: leave 0x08048409 <+19>: ret i have in "int a=10;" break point that's why the offset 6 have arrow. so, main's function starts others pushing ebp bla bla bla, , don't understand this: 0x080483f9 <+3>: sub $0x10,%esp => 0x080483fc <+6>: movl $0xa,-0x4(%ebp) why doing sub in esp?

Is there a way to use AllegroGraph with a Lisp other than ACL? -

i'm far reading documentation, , says in order use lisp client have use acl. acl, express edition has 30 day expiration date. since i'm far considering commercial use, i'm not buy in observable future. did try other lisp? @ permitted license? (my guess "yes", because, example, python client doesn't require special purchases of course.) sure, actually. allegrograph supports superset of sesame 2.0 http protocol graph stores. key documentation should have @ is: http://www.franz.com/agraph/support/documentation/current/http-protocol.html as example, request list of repositories in root catalog, http interaction follows: /repositories http/1.1 accept: application/json http/1.1 200 ok content-type: application/json; charset=utf-8 [{"uri": "<http://localhost:10035/repositories/test>", "id": "\"test\"", "title": "\"test\"", "r

basic Haskell : searching through multiple lists for the same elements -

i've been battling problem while. i'm trying create "organisation" list of gyms. these gyms list of people. each person has id number, age , amount of credit. i want findid function search through organisation search through list of gyms find users inputted id , return total of credit. however, feel i'm overcomplcating problem , struggling now. newtype id = id int deriving (show) newtype age = age int deriving (show) newtype credit = credit int deriving (show) newtype person = person (id, age, weight) deriving (show) type gym = [person] type organisation = [gym] getage :: person -> int getage (person(a,age b,c)) = b getid :: person -> int getid (person(id a,b,c)) = getcredit :: person -> int getcredit (person(a,b,credit c)) = c p = person ( id 123, age 65, credit 12000) q = person ( id 321, age 64, credit 0) e = person ( id 453, age 30, credit 3000) r = person ( id 123, age 65, credit 2310) s = person ( id 364, age 32, credit 32340) t = pe

perl - handle tests using TAP::Harness, how to print output when test exits -

i trying whole day find out answer, didn't find anything. wrote tests using test::more (test1.t, test2.t, test3.t ...). , wrote main perl script (main.pl) handles tests using tap::harness , print output in junit format using formatter_class => 'tap::formatter::junit . in tests use bail_out function. problem when test bailed out, main script exits , there no output @ all. if, example test3.t bailed_out, need see results test1.t , test2.t. how can that? i can't use exit or die instead of bail_out because don't want other tests continue. (if test3.t bail_out don't want test4.t run.) can please me? need see results tests running before bailed out test. thanks. according test::more docs: bail_out($reason); indicates harness things going badly testing should terminate. includes running of additional test scripts. so explains why suite aborts. you might want consider die_on_fail test::most , or skip_all , depending on reason bai

java - Check duplicates of numbers input by user -

i'm doing program user input 5 numbers , in end numbers printed out working fine. can't work boolean function check duplicates. should check duplicates user write them in, e.g. if number 1 5 , second numbers 5, should error until write in different number. meaning if user input duplicate should not saved in array. assignment, i'm asking hint or two. this program written based on pseudo-code given me, , therefore have use boolean check duplicates public boolean duplicate( int number ) class. i've tried getting head around , tried myself, i'm doing stupid mistake. e.g.: if(int != mynumbers[i]) checkduplicates = false else checkduplicates = true; return checkduplicates; duplicatestest class: public class duplicatestest { public final static int amount = 5; public static void main(string[] args) { duplicates d = new duplicates(amount); d.inputnumber(); d.duplicate(amount); d.printinputnumbers();

php - Implode on multiarray -

i have array: $array = array( 0 => array('first' => 'aaa', 'second' => 'bbb'), 1 => array('first' => 'erw', 'second' => 'wer'), 2 => array('first' => 'aaawe', 'second' => '345'), 3 => array('first' => 'aa345a', 'second' => 'dfgdfg'), ); and values implode: $first = implode(';', $array['first']); $second = implode(';', $array['second']); but of course not working. how best way this? with php 5.5 there exists function array_column() : http://php.net/array_column $first = implode(';', array_column($array, 'first')); // same $second p.s.: backwards compability check https://github.com/ramsey/array_column out as requested, "simple" (php 5.3 compatible): $first = array_reduce

mysql - Inserting the same fields from multiple tables (in a more efficient way) -

i'm looking avoid rewriting same queries below (for each unique table): insert dbo.databasenew (field1 , field 2) select field 1, field 2 olddatabase.dbo.[table 1] description 'something'; insert dbo.databasenew (field1 , field 2) select field 1, field 2 olddatabase.dbo.[table 2] description 'something'; i've tried combining queries below, doesn't work: insert dbo.databasenew (field1 , field 2) select field 1, field 2 olddatabase.dbo.[table 1], olddatabase.dbo.[table 2] description 'something'; any help? sorry noob question. thanks! you use union operator insert dbo.databasenew (field1 , field2) ( select field1, field2 olddatabase.dbo.[table 1] description 'something' union select field1, field2 olddatabase.dbo.[table 2] description 'something' );

Android custom CursorAdapter with AsyncTask -

i'm trying build list image taken device , text. turns out taking images phone phone's camera task takes while i'm trying make fast possible user experience won't slower. got looks images loaded in 1 imageview , images spread other imageviews (i'm not sure implementation of viewholder technique , custom cursoradapter correct). public class mycustomcurseradapter extends cursoradapter { static class viewholder { public textview nametext; public imageview imagethumbnail; } cursor cursor; public mycustomcurseradapter(context context, cursor c, int flags) { super(context, c, flags); // todo auto-generated constructor stub } @override public void bindview(view view, context arg1, cursor cursor) { viewholder holder = (viewholder)view.gettag(); int pathcol = cursor.getcolumnindex(newpicsqlitehelper.column_path); string imageinsd = cursor.getstring(pathcol); file imgfile = new file(imageinsd); if(imgfile.

php - Using an Array to verify login and password -

i can array of user file when access db. missing how use array verify input user. array contains piece of data need capture , use on later page? here code generates array , part of foreach trying work. on right track? $sql = "select * users;"; $result = mysql_query($sql, $dbc); //run query if ($result) { $html .= '<h2>result found </h2>'.php_eol; //grab arrays result for($i = 0; $i < mysql_num_rows($result); $i++) { $array = mysql_fetch_array($result, mysql_assoc); print_r($array); foreach ('username' $inputusername){ echo 'password'; } } } else { $html .= '<h2>error: '.mysql_error().' </h2>'; } so, instead of fetching users in database iterating on 1 one check passwords, can tell mysql "give me password of user has username of exampleuser" this: $username = "exampleuser"; $sql = "select `password` u

c# - IE8 prompts download json response -

i've been trying out jquery form plugin , works wonderfully. oh, except ie8. it's ie8. anyways, on success response callback, ie8 prompts me download response instead of calling success function. here javascript code looks like $("#form1").ajaxform({ url: "http://localhost:4887/api/file/post", type: "post", success: function (data) { //response stuff here } }); i've tried specifying datatype ajax form, woe me, didn't work the thing returning server string. once again, ie8 prompts me download string instead of calling success function. after research, understand might have modify http headers? shed light on this? or give way of going this? update here brief @ c# controller public class filecontroller : apicontroller { public jsonresult post() { httppostedfi

osx - Titanium Studio - Can't start Android App in Emulator -

i have built application titanium studio. ios simulator works perfectly. can't build app in android emulator. have android sdk v.22 , using titanium 3.1.3. could tell me must do? i log: [info] titanium sdk version: 3.1.3 (09/18/13 12:00 222f4d1) [info] waiting android emulator become available [error] timed out waiting android.process.acore [info] fastdev server running, deploying in fastdev mode [info] copying commonjs modules... [info] copying project resources.. [error] exception occured while building android project: [error] traceback (most recent call last): [error] file "/users/timstrakerjahn/library/application support/titanium/mobilesdk/osx/3.1.3.ga/android/builder.py", line 2598, in <module> [error] builder.build_and_run(false, avd_id, debugger_host=debugger_host, profiler_host=profiler_host) [error] file "/users/timstrakerjahn/library/application support/titanium/mobilesdk/osx/3.1.3.ga/android/builder.py", line 2245,

backbone.js - Collection renders fine when loaded from remote Url, but not when loaded from localStorage (initialize vs. onRender) -

i'm using layout's 'initialize' method instantiate collection, fetch() data url on collection, , instantiate new collectionview passing through collection it's fetched data. collectionview later gets 'shown' in region. it works perfectly. i wanted switch on using localstorage retrieve data, instead of remote url. saved data retrieved remote url localstorage. updated collection 'localstorage: new backbone.localstorage('entries')'. retrieves data localstorage. but. none of regions in layout rendered (i've tried calling this.render() in various places no luck). if replace 'initialize' method 'onrender' in layout responsible instantiating everything, renders (regardless of whether came remote url or localstorage). why if use layout's 'initialize' method fetch data in collection localstorage, nothing gets rendered; whereas rendered if data fetched remote url? why both work when using 'onrender

java - GLSL shaders, gl_ModelViewMatrix not correct? -

so trying make shader changed color of crystal little bit on time, , went fine until noticed didn't darker further away went light source ( default opengl lights now! ). tried tone down color values distance away light didn't work. later on discovered ( setting color red if x position of vertex in world coordinates greater value ), vertex.x value around 0. though should 87.0. void main() { vec3 vertexposition = vec3(gl_modelviewmatrix * vertexpos); vec3 surfacenormal = (gl_normalmatrix * normals).xyz; vec3 lightdirection = normalize(gl_lightsource[0].position.xyz - vertexposition); float diffuseli = max(0.0, dot(surfacenormal, lightdirection)); vec4 texture = texture2d(texturesample, gl_texcoord[0]); if(vertexposition.x > 0)gl_fragcolor.rgba = vec4(1, 0, 0, 1); /*and on....*/ } as far know gl_modelviewmatrix * gl_vertex should give world coordinates of vertex. stupid or what? ( tried same if statement light position correct! )

Can't solve this java.lang.UnsupportedClassVersionError -

this question has answer here: how fix java.lang.unsupportedclassversionerror: unsupported major.minor version 41 answers i'am trying execute java program mvn, there's little problem can't solve. maven says: java.lang.unsupportedclassversionerror: main/csvcrawler : unsupported major.minor version 51.0 so java version not compatible stuff used in program. can't figure how update java, don't understand update... :-) some other info: java version "1.6.0_27" javac 1.7.0_25 can give me hint do? suggestions! unsupported major.minor version 51.0 this indicates compiling class using 1.7 compiler , targeting 1.7 vm. when run on 1.6 vm, that's way of saying "hey, have no idea format is" because came out after 1.6 vm did. to fix, either upgrade vm (you running 1.6.0_27) 1.7, or tell compiler (you running 1.7.0_2

html - Send a message and upload a file in PHP -

this question has answer here: how upload & save files desired name 6 answers i have form allows users send me message on email, want when user fills form , chooses file file gets uploaded server , message gets sent me. did message part couldn't file uploaded. here code: index page: <form action="mail.php" method="post" enctype='multipart/form-data'> <input type="text" class="feedback-input" id="firstname" name="firstname" placeholder="first name" size="30" required=""> <br/> <input type="text" class="feedback-input" id="lastname" name="lastname" placeholder="last name" size="30" required=""> <br/> <input type="email" class="feedback-

java - What is the best way to build a interface for bacnet system? -

i tried build interface bacnet system, , thought web app, desktop app, , movil app, written in java idea. don't know how build bridge between bacnet network , app. there bacnet stack java on sourceforge: http://sourceforge.net/projects/bacnet4j/

php - Making page that user is viewing stay on page rather than redirecting to home page -

using php, how able accomplish this? ex: 1.) there total of let's 5 pages (a, b, c, d, e) user can view (either logged in or out) 2.) user x viewing page (c) , not logged in 3.) user x logs in on page (c) , logged same page (c) he/she viewing rather being redirected home page i know how make user redirected home page when user logs in on page, not desire , users not want - user can log in on whatever page viewing , stays on page them rather being redirected. this have user login , redirected with, have no idea how make work users being able stay on whatever page user viewing when login. php header("location: index.php"); is there more needed allow users stay on same page viewing when login? or there simple solution can't seem find using 1 line of code above? i've read tons of tutorials/blogs/forums, etc...but couldn't find definite answer anywhere. did come across 'php_self' have no idea how implement @ , php.net doesn't

c++ - Registry of different types of data -

i want keep kind of container type maps 1 value of type. want std::map<std::typeindex, t> t depends on type index with. std::map doesn't nice way of doing because types rigid. simplest solution can use doing this? if map type-erased container boost::any , can @ least recover type if know is: std::map<std::typeindex, boost::any> m; m[typeid(foo)] = foo(1, true, 'x'); foo & x = boost::any_cast<foo&>(m[typeid(foo)]);

crazy C++ compiler error messages about a copy constructor from MinGW32 -

i'm beginning c++ student , i'm using jgrasp , have installed mingw32 because turn our assignments remotely linux machine helps ensure it'll work simulating linux environment in windows or something. mingw32 installed "base package" , manually selected c++ compiler option. in jgrasp went settings>>path/classpath>>workspace , added new path directory c:\mingw\mingw32\bin it'll know g++ compiler is. i these crazy error messages upon compiling in jgrasp can't make sense of. think has header because of iostream. #include <string.h> #include <iostream> #include <iomanip> #include <fstream> using namespace std; here compiler error messages: ios:42:0, c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38, c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39, lab1.cpp:6: c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\ios_base.h: in copy constructor 'std::bas

c++ - How to pass a vector of objects to another class then call a function from within a member of an object in that vector? -

how pass vector via function call pointer vector in class , call function or element via receiving class; , how call function in receiving class remotely? in example, object0 object type containing function called. object0 created in object1 member of vector. then vector passed object2, wherein called external object; here arbitrarily chosen within object1; main() way of booting app up, , welcome suggestions on improving it. #include <vector> class object0 { protected: int a; void function() { std::cout << "function called" << std::endl; } }; class object2 { public: std::vector<object0> *object0vec; void knowvector(std::vector<object0> *_object0vec) { object0vec = _object0vec; } }; class object1 { public: object2* _object2; object1() { _object2 = new object2; } void init() { std::vector<object0> object0vec; object0vec.push_ba

ruby - Why do I get false in both cases? -

i trying check if 2 integers in array in sum equal n. however, false first case, though think should true. def sum_to_n?(array, n) in array s = n - return true if array.include? s return false if != n - end end puts sum_to_n?([1,2,3,4,5], 9) puts sum_to_n?([1,2,3,4,5], 12) you can in not many lines :-) ary = [1,2,3,4,5] n=9 ary.combination(2).detect { |a, b| + b == n }

mongodb - MongoError: can't find any special indices: 2d (needs index), 2dsphere (needs index) -

i attempting use mongodb's geospatial indexing querying latitude , longitude points around point using mongodb's find method. keep getting error: mongoerror: can't find special indices: 2d (needs index), 2dsphere (needs index) i'm not sure documentation after googling hour. can't find explanations. here schema created using mongoose: var mongoose = require('mongoose'); var schema = mongoose.schema; var eventschema = new schema ({ name: string, description: string, location: {type: [string], index: '2dsphere'}, time: date, photo: buffer, activity: string }); mongoose.model('event', eventschema); i use find method find other event documents around point user provides. var maxdistance = 0.09; var lonlat = {$geometry: {type: 'point', coordinates: [34.09,124.34] }}; event.find({ 'geo': { $near: lonlat, $maxdistance: maxdistance } }).exec(function(err, events) { if(err) { throw

How to populate a vector upon construction of object in C++? -

i trying create class has member of type std::vector , want vector filled number 2 when instance of class created: #include <vector> using namespace std; class primes{ private: vector <int> myvec; myvec.push_back(2); }; but compiler gives me: error: ‘myvec’ not name type class primes{ private: vector <int> myvec; myvec.push_back(2); // <-- can not placed here }; compiler expects there declaration / definition of member or method (member function). can not place there code such myvec.push_back(2); . must placed inside body of method: class primes { private: std::vector<int> myvec; public: void addprime(int num) { myvec.push_back(num); } }; or in case want construct instance of primes vector contain number 2: class primes { public: primes() : myvec(std::vector<int>(1, 2)) { } private: std::vector<int> myvec; }; or if need populate vector more of them: int

c++ - Segmentation fault (core dumped) error occurred -

i keep getting segmentation fault (core dumped) error. program runs fine first line of code though, don't know why messes on second line. line of code causes problem xxml->setelementdata(selementname, scontent) one. or direction of problem appreciated! #incude <iostream> void parseelement(istream & input, string sprefix, vector<xmlserializable*> & vvector, map<string, function<xmlserializable*()>>& mmap) { xmlserializable * xxml; string selementname; getline(input, selementname, '>'); if( selementname.back() == '/' ) { cout << sprefix << "empty element: " << selementname << endl; return; } else { cout << sprefix << "element - " << selementname << endl; if (selementname == "item") { function<xmlserializable*()> pfuncitem = mmap["item"]; xxml = pfuncitem(); vvector.push_back(xxml)

android - How to connect a countdowntimer to a button -

i'm working android studio. i'm creating app has countdowntimer , button. when run application, timer automatically runs , if want click button there textview counts how many times press button. want timer starts when press button ,the countdown continue running , stops @ time "0:000" stops counting of clicks. can me? (if helps put code) @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); txtcount = (textview)findviewbyid(r.id.textview1); txtcount.settext(string.valueof(count)); btncount = (button)findviewbyid(r.id.button1); final textview textviewtimer = (textview)findviewbyid(r.id.textview2); btncount.setonclicklistener(new view.onclicklistener() { public void onclick(view arg0) { count++; txtcount.settext(string.valueof(count)); } }); new countdowntimer(10000, 1) { public void ontick(long

go - Acessing unexported function `nat.string` -

i want convert big.int simple base32. not standard base32 stuff rfc 4648 implemented base32 nor zbase32 nor crockford want simple normal 5-bits per character 0-9a-v character set. i aware of base32 package , not want - builds result in standard base 32 number padding , stuff don't want. use , tear off trailing "=" characters , hack remains seems brutal solution. there big.setstring(string, base) can parse base32 number in string form there no reverse - looking for, big.getstring(base) java biginteger.tostring(int base) . there is, however, nat.string exactly want. how can gain access it? is there way manually extend big implement big.getstring(base) trivially calls nat.string correct charset ? is there way can reach unexported big.nat big uses , call nat.string ? is there else can do? p.s. i'd interested in using nat.trailingzerobits - had write own because didn't realise done. you can't access unexported functions @

javascript - Masonry grid sizer issue -

i've been @ whole day , i'm losing live @ point because of this.. trying create system recent posts fit onto 1 page. behold! succeeded. well, sort of. have ran issue using masonry, while trying create that. when using '.grid-sizer', having set in css , applied in html, doesn't work @ all. for example: .grid-sizer { width: 49.62%; } and html: <div id="msonrycontainer" class="js-masonry" data-masonry-options='{ "columnwidth": ".grid-sizer", "itemselector": ".post" }'> <div class="grid-sizer"></div> <div id="content"> now love of god, bloody thing doesn't work, every other option works, sizing of grid doesn't. unless set div values pixels, opposed percentage, since trying make responsive layout, doesn't work. at point hope pretty lost, had resort posting here. just in case wanna know how mess looks: ht

python - Best way to add a "+" and "-"? -

what best way display either + in front, float? lets if user inputs number "10". want have "+" appear in front of since positive number. if negative number leave is. would have use if statement , convert string , add in + sign? or there easier way? use format() function : >>> format(10, '+f') '+10.000000' >>> format(-10, '+f') '-10.000000' >>> format(3.14159, '+.3f') '+3.142' see format specification mini-language specific formatting options; prepending number format + makes include plus positive numbers, - negative. last example formats number use 3 decimals, example. if need remove negative sign, you'd have explicitly using .lstrip() : >>> format(10, '+f').lstrip('-') '+10.000000' >>> format(-10, '+f').lstrip('-') '10.000000' but that'd quite confusing specification read, in opinion. :-)

Get total memory allocated by a Java process (without profiler)? -

is there jvm option print out total memory allocated during run without running through instrumented profiler? i'm not expert on how memory allocator within java works, surely keeping track of total bytes allocated should possible no overhead. i can't run in profiler since application needs handle tens of thousands of messages per second (much more @ peak) many hours; overhead of profiler make unfeasible. thanks afaik, there no such jvm option. you enable gc logging , try to infer memory allocation statistics space sizes. reports when gc runs ... not @ application start , end. i wonder why there wouldn't jvm option this. frankly, because not useful. knowing how memory allocated during run not understand how tune application.

windows runtime - WinRT - how to tell if device is on battery or wall powered? -

say want tailor application throttle throughput when running on battery power, go full bore when it's plugged wall socket. is there event plug detect when these things happen when internet connection detected? apparently there's trigger can plug in to. fires off when device plugged in.

html - How to align the header menu from left? i see a unexpected margin on left. Help please -

http://cooking.comyr.com/ i creating header menu using css. can see on above url. html code <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>let's foodie | homemade restaurant style food</title> <link href="style/main_css.css" rel="stylesheet" type="text/css" /> </head> <div id="header"> <ul> <li><a href="#" title="home"><span>home</span></a></li> <li><a href="#" title="recipes"><span>recipes</span></a></li> <li><a href="#" title="recipe finder&qu

The code won't recognize my if statement (Python) -

the code wont recognize if statement. when run code, enter following number: -10. however, returns else statement, when should return if statement. doing wrong? def distance_from_zero(d): if type(d)== int or type(d)==float: return abs(d) else: return "not integer or float!" x = raw_input("enter number: ") print distance_from_zero(d) raw_input returns string. if type number 9, doesn't return integer 9 , returns string "9" . therefore test type(d)== int or type(d)==float never true. you def distance_from_zero(d): try: return abs(int(d)) except valueerror: pass try: return abs(float(d)) except valueerror: pass return "not integer or float!" x = raw_input("enter number: ") print distance_from_zero(x) this makes use of design philosophy popular in python called "duck typing", in which, rather test see object'

c# - Kendo UI Grid paging issue in ASP.NET MVC -

in kendo ui grid, set page size attribute 3 - pagesize(3): @(html.kendo().grid<kendo.mvc.examples.models.discount>() .name("discountgrid") .columns(c=> { c.bound(d => d.id); c.bound(d => d.category); c.bound(d => d.percentage); c.bound(d => d.merchandise); c.command(cm => { cm.edit(); cm.destroy(); }); }) .pageable() .toolbar(toolbar => toolbar.create()) .editable(editable => editable.mode(grideditmode.incell)) .datasource(datasource => datasource .ajax() .pagesize(3) .serveroperation(false) .model(model => model.id(d => d.id)) .create(update => update.action("editinginline_create", "grid")) .update(update => update.action("editinginline_update", "grid")) .destroy(update => update.action("editinginline_destroy", "grid")) ) ) after a

json - How do you get Ember Data to recognize that the server is returning IDs for hasMany relationships? -

my server returns json responses this: { 'book': { 'id': 252, 'name': 'the hobbit', 'tag_ids': [1, 2, 3, 5, 6, 7] } } i'm using ember data's ds.restserializer , i've extended include keyforrelationship function recognizes keys ending in "_ids" hasmany relationships. thus, above code should match fine model code, looks this: app.book = ds.model.extend({ name: ds.attr('string'), tags: ds.hasmany('tag') }); the problem whenever create new book , server returns json response, ember data's store gets wrong. fails convert ids actual tag instances. instead, tags property on model literally set array of ids. any ideas? you should consider using ds.activemodeladapter instead of ds.restadapter . see https://stackoverflow.com/a/19209194/1345947

Oracle SQL comparing dates -

sql> select * porder ; oid bill odate ------ ---------- --------- 10 200 06-oct-13 4 39878 05-oct-13 5 430000 05-oct-13 11 427 06-oct-13 12 700 06-oct-13 14 11000 06-oct-13 15 35608 06-oct-13 13 14985 06-oct-13 8 33000 06-oct-13 9 600 06-oct-13 16 200 06-oct-13 oid bill odate ------ ---------- --------- 1 200 04-oct-13 2 35490 04-oct-13 3 1060 04-oct-13 6 595 05-oct-13 7 799 05-oct-13 16 rows selected. sql> select * porder odate='04-oct-2013'; no rows selected please help...why isn't query working..?? in oracle, date has time component. client may or may not display time component, still there when try equality comparison. want compare dates dates rather strings use current session's nls_date_format doing implicit conversions making them rather fragile

How to determine a string PARTIALLY contains another string ? (preferrable Java) -

i'm doing java project needs determine whether string contains string following below logic: a parent string "this parent string" contais "isstr" should return true. because characters of "isstr" can found in parent string preserving substring order. contains should case-insensitive. is there kindly me how write logic in simple , efficient way, or library appreciated! public static void main(string[] args) { string parentstr = "this parent string", childstr = "isstr"; //turn both lowcase. parentstr.tolowercase(); childstr.tolowercase(); integer childstrindex = 0; //run on parent string , if found match keep comparing next //character in child string. (int index = 0 ; index < parentstr.length(); index++) { character currchar = parentstr.charat(index); if (childstr.length() <= childstrindex) break; if (currchar.equals(childstr.charat(childstrinde

c# - Getting the field a MemberRef metadata token refers to -

Image
fair warning, may tad esoteric , tricky. given memberref (more explanation below) extracted cil stream, how figure out field, if any, points (and fieldinfo it)? here's i've figured out far according ecma 335 standard , memberref metadata token lookup in table point either field metadata token or method metadata token. metadata token beginning 0x0a memberref. i hadn't encountered 1 of these before, don't seem uncommon. able 1 generated using following anonymous type in method: new { = new datetime(1234, 5, 6, 7, 8, 9, datetimekind.utc), b = (datetime?)null } when grab method body via reflection (get propertyinfo , getmethod , methodbody , get il ) a 's method is: [2, 123, 79, 0, 0, 10, 42] which converts to: ldarg.0 ldfld 0x0a00004f ret if reflect in , backing field (relying on name similarity choose <a>i__field , nothing algorithmic) see metadatatoken 0x04000056 . note tokens generated may vary between compilations.

ruby on rails 3 - RubyMine bundle/bundler configuration error -

i on windows , using rubymine develop app. 2-year old found banging on keyboard when had stepped away sec. did environment can't figure out. i'm getting following error when try run bundle install or bundle update : c:\railsinstaller\ruby1.9.3\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=argv.shift) c:\railsinstaller\ruby1.9.3\bin/bundle update c:/railsinstaller/ruby1.9.3/bin/bundle:23:in `load': cannot load such file -- c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.4.0.rc.1/bin/bundle (loaderror) c:/railsinstaller/ruby1.9.3/bin/bundle:23:in `<top (required)>' -e:1:in `load' -e:1:in `<main>' process finished exit code 1 my gemfile looks this: source 'https://rubygems.org' gem 'rails', '3.2.11' # bundle edge rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'jquery-rails' gem 'bcrypt-ruby', '~> 3.0.0' gem '