Posts

performance - Do I create a duplicate function with slightly different algorithm, or use a slower, more general function? -

i've been advocate of dry principle: in other words, write code once , once. have function filters out data "latest unique report". in algorithm, function assumes incoming data sorted, making efficient. however, function potentially has handle data not sorted. better practice: having 1 general solution slower, or having 2 different functions, 1 being more efficient? edit: should make note while performance nice thing have, not critical application internal tool. the way put it sounds make function sorts data, , puts filtering function. so function filterdata(object data) { ... } function sortandfilterdata(object data) { // sorting ... // filtering filterdata(data); }

jsf 2 - JSF Unknown System Events -

i working on jsf 2.0 project, , learning benefits of using system events. however, book i'm referencing 'core java server faces 3rd edition' lists total of 14 system event types can used in f:event tag's type attribute. of them work expect, e.g. "prerendercomponent" on uicomponent tag, or "prerenderview" on uiviewroot tag. but, besides two, , select few others, none of other events mentioned in book work. example, can't postrestorestate type of event work on uicomponent. instead, when jsf tries render page, classnotfound exception, presumably system event class supposed handle postrestorestate events, or whatever event i'm trying listen for. why don't these other event types work? there other library need, or there other way of implementing system event listener need use. below example of 1 such tag failing: <h:commandlink action="editplant" value="#{appmessages.usersn...

Cakephp select list of numbers with corresponding values -

i have select list generate : echo $this->form->input('number_of_vehicles', array('empty' => 'select...', 'type' => 'select', 'options' => range(1, 10, 1))); now generates nice numbered select list 1 10, incremented 1...great. option value starts @ 0 eg. <select name="data[contact][number_of_vehicles]" id="contactnumberofvehicles"> <option value="">select...</option> <option value="0">1</option> <option value="1">2</option> <option value="2">3</option> <option value="3">4</option> <option value="4">5</option> <option value="5">6</option> <option value="6">7</option> <option value="7">8</option> <option value="8">9</option> <option value="9">10</option...

c# - Creating an island for separate gravity control on XNA using Farseer Physics Engine 3.0 -

i started using farseer engine , far it's been pretty easy understand , implement in aps. wondering if there way put control different "world" can manipulate gravity of object allow other objects stay @ default world gravity. know how accomplish or know of resources might me? thanks, tom the idea change gravity specific objects bit unusual, gravity global constant in physics simulation (unless using space stuff). don't know farseer engine assume gravity works same in other physics engines. usually in physics manipulate 1 object's 'gravity' lower it's weight/mass (and air friction?). or give slight upward force (a negative gravity).

android - How do I dump my sqlite db back into my assets folder -

i have succeeded in generating sqlite3 database in android app initial sqlite3 file in assets folder. helpful have similar routine dump modified database folder a) verify updates/inserts/deletes working correctly , b) possible way pass bulk revisions process. does have utility this? i don't think if can that. if want save data inserted, can keep database in /database folder, in order database not rewritten (think of this: when start app, code again writes database asset folder /database folder, have old data again) this file filedb = new file("data/data/[package-name]/databases/"+database_name); if( !filedb.exist()) { //if database file not exist, means database not copied asset folder /database folder, copying, } with test have prevented database in /database folder rewriten database have in asset folder. verify if inserting/deleting/updateing working fine, pull out database file emulator , open sqlite browser. don't forget put in assets ;) ...

c# - DateTimeOffset display after daylight savings change -

i have question datetimeoffset , daylight savings time. explain question lets assume right date , time is: 11/6/2010 10:15:00 if run code: datetimeoffset mytime = datetimeoffset.now; console.writeline("local time: " + mytime.tolocaltime().datetime); then result: local time: 11/6/2010 10:15:00 am meaning event happened @ 10:15 in morning (my time zone mountain daylight time (-6 offset)). so, save datetimeoffset sql server 2008 db (as datetimeoffset). next day want display user. daylight savings has expired. if run above writeline saved off value (from previous day) display? the offset stored in database -6. daylight savings over, current offset -7. understand documentation , first convert time utc time (so takes 10:15 , adds 6 hours (4:15 pm). subtract current offset of local time (4:15 pm - 7 = 9:15 am). so if math right, when display event, show occurred @ 9:15 rather 10:15 am. this not good. want store time zone information, need tim...

grails - call to .save() on domain class fails with no signature of method .save() in unit test -

i'm using grails 1.3.2 in netbeans. have simple unit test fails error: no signature of method: com.maxrecall.maxrequire.domain.release.save() applicable argument types: (java.util.linkedhashmap) values: [[flush:true]] possible solutions: wait(), any(), wait(long), iscase(java.lang.object), use([ljava.lang.object;), sleep(long) the relevant code is: release rel = new release() ... rel.save(flush:true) the same code works in bootstrap.groovy. have tried various variations on .save() (.save , without parameters. it's unit test, there's no spring, hibernate, etc. have mock behavior want. if you're testing persistence, need convert test integration test, since testing persistence unit tests tests mocking framework. integration test uses @ minimum in-memory database, although can switch test instance of mysql/oracle/etc. if you're testing controllers or other users of domain classes , want them work can focus on testing current class, u...