Posts

Showing posts from March, 2014

c# - Best way to use LINQ to fill in gaps in my data -

yesterday posted question below on how use linq transform object several levels using 'group' flat structure: linq groupby on object several levels this kindly answered cédric bignon. reason wanted transformation populate componentart's silverlight xychart component userdata variable. however, i've found out there known bug component when displaying in stacked bar format. if there's gaps in data not display properly, need ensure users have value distinct values of category. in original question, i've put i'd userdata populated with, i'd need ensure [user = "bob", category = "international", spend = 0.00] present in results. i've achieved using following code after linq statement have given me: // linq statement provided @cedric var userdata = spend in allspend userdatapoint in (from monthspend in spend.spend spenddetail in monthspend.detail group spenddetail

ibmsbt - load function declared in service objects doesn't execute -

trying communities list(and profile well) using javascript ibmsbt api passing object load function getmycommunities function has no result. function assigned load property doesn't executed. here code: var communityservice = new communityservice(); communityservice.getmycommunities({ load: function(communities) { var ul = document.getelementbyid("communities") (var i=0; i<communities.length; i++) { var community = communities[i]; var li = document.createelement("li"); ul.appendchild(li); li.setattribute("id", "community" + i); dom.settext("community" + i, community.gettitle()); } }, error: function(error) { console.error("error: "+error.message); } }); but when i'm using promises works charm. here is: var cp = communityservice.getmycommunities(); cp.then( function(communities){ v

java - JTable, RowFilter and RowFilter.Entry -

Image
please have issue rowfilter ( its comparisontype ) put regex(string), number, date together and, or, nor no idea how to handle null value and, or, nor if regex(string), number, date has same logics or there "small differencies" especially how compare date value some longer , detailed descriptions welcome in sscce see basic issues frame.add(new jbutton(new abstractaction("toggle filter") { import java.awt.borderlayout; import java.awt.event.actionevent; import java.util.calendar; import java.util.date; import javax.swing.*; import javax.swing.table.defaulttablemodel; import javax.swing.table.tablemodel; import javax.swing.table.tablerowsorter; public class jtablefilterdemo { private static tablerowsorter<tablemodel> sorter; private object[][] data = {{"a", 5, true, new date()}, {"b", 2, false, new date()}, {"c", 4, false, new date()}, {"d", 8, true, new date()}, {&q

Android Universal Image Loader Custom Image Decoder with CMYK support -

background we have swapped uil library, seems fantastic. unfortunately have support cmyk images (against our will) , have attempted modify existing imagedecoder called baseimagedecoder . the code can found here. http://pastebin.com/nqbsr0w3 we had existing asynctask http://pastebin.com/5aq6qrrd used imagemagick wrapper described in post ( convert image byte[] cmyk rgb? ). worked fine before in our setup. the problem the current decoder fails load cached image file system , results in decoding error. have looked through source code , believe using right functions. thought adding our level of decoding @ point in process ideal, image may have been resized , stored on file system. file cachedimagefile = imageloader.getinstance().getdisccache().get(decodinginfo.getimageuri()); if (!cachedimagefile.exists()) { log.v("app", "file not exist"); return null; } the abov

javascript - Clock initialized by server then run by client is late -

i want create clock time initialized server , continues client codes: //initializing server(asp.net): <% var now=system.datetime.now; %> var h=<%=now.hour %>; var m=<%=now.minute %>; var s=<%=now.second %>; //then client: function starttime() { s++; if (s == 60) { s = 0; m++; if (m == 60) { m = 0; h++; if (h == 24) h = 0; } } m = checktime(m); s = checktime(s); h = checktime(h); document.getelementbyid('clock').innerhtml = h + ":" + m + ":" + s; t = settimeout(function () { starttime() }, 1000); } function checktime(i) { if (i < 10) { if(i.tostring().length<2) = "0" + i; } return i; } window.load = starttime(); but clock become 5 seconds late each 10 minute. how can prevent delay? settimeout not precise enough exact timing. can off as 10ms when nothing else going on. on lon

php - If uncheck the check box delete row in my SQL table -

actually new php.. have task select records database checkboxes checked. when uncheck checkbox should delete particular record database.. my code <?php if(isset($_post['delete'])) { $test=$_post['test']; $qun1=$_post['question1']; //db connection $con=mysql_connect("localhost","root",""); mysql_select_db("dbname"); if($qun1!=0 && $test!=0) { foreach($qun1 $qunestion) { echo $question; //this testing $query=mysql_query("delete test_question test_questions_id='$test' , question_id in ('$question') " ) or die(mysql_error()); } if($query) { echo "success"; } else { echo "no"; } } } ?> my code working if use not in in place of

c - How to find the call stack when there is just a corrupt stack corefile? -

a coredump file corrupt stack, no usefull info. how can find call stack? stack shows : #0 0x04229c7a in ?? () #1 0x00921fa7 in ?? () #2 0xbfc17e04 in ?? () backtrace stopped: previous frame inner frame (corrupt stack?) and address of eip shows "cannot access memory"! thinks! displaying call stack requires correct instruction pointer (eip), stack pointer (esp) , valid stack contents. from output looks stack had been corrupted , previous function returned random address (eip=0x04229c7a). so, out of luck. try running program under valgrind.

uiviewcontroller - Pass NSNumber Value from ViewController to UIView -

from uiviewcontroller , have nsnumber value "discountpercentage". wanna send value uiview . code is, ssidpview *idp = [[ssidpview alloc] init]; idpview.discountpercentageis = discountpercentage; i have "discountpercentageis" nsnumber in "ssidpview.h" , @property(atomic,retain)nsnumber *discountpercentageis; and synthesized also. when try value in idpview nslog(@"its coming in idp:%@",self.discountpercentageis); its null. know simple , can me figure out did miss?. tried many solutions no use . thanks in advance geeks :)

ibm midrange - Search and extract data from AS400 using IBM Domino Lotus Notes workflow -

i doing lotus notes workflow needs connect erp system, as400 search , extract data workflow. idea can possibly that? thanks!! you can use decs on domino connect as400 using scripted activity (or configure sync). therefor need db2- driver installed on domino server. other possibility use lei (that costs bunch of money, can lot more). third possibility use lsxcon- classes , write agent data. a java- agent jdbc might possible (if as400 supports access using jdbc , have appropriate driver). all solutions either need code or money buy licences... if "one time" or "manual" task db2 driver can installed on client agent run manually or in local schedule (only working if client running).

algorithm - Motion Tracking using Sensor fusion -

currently using accelerometer, gyro , magnetometer motion tracking application.i have 9d sensor fusion functionality calculate orientations , gravity cancellation accelerometer data. how calculate position of object in 3 dimensions? kindly suggest algorithm give accuracy. extended kalman filter can give best results motion tracking if working on real time application. suggest refer book multi sensor data fusion matlab (crc press).

java - Sudoku game, serialization issue -

i creating sudoku game , trying provide options save, save as, , open games. using jfilechooser this. able save (or "save as") when try open saved file, error. new programming , i'm hoping spot issue , educate me on how read in contents of sudoku board when saving (as how deal re-creating sudoku board when open file). hear there easier way deal using inputstream/outputstream instead of reader/writer... here code inner class implements (i don't know if there's way post entire class without exceeding character limit text box.): // inner class provides jmenubar object @ top of // board class menuattop extends jmenubar implements actionlistener{ // sudokumain2 object dealing private sudokumain2 main; // "file" menu private jmenu filemenu; // "new game" option private jmenuitem newgame; // "open" option private jmenuitem open; // "save" option private jmenuitem save; //

python - How do I reliably check if an attribute is defined for an object? -

sometimes create objects x attribute defined, don't. class object(models.model): x = models.integerfield(blank=true, null=true) i want create subset of objects x not defined @ point in app: [o o in os if not hasattr(o,'x')] i've being playing around in shell, , don't results want. >>> o = object() >>> o.save() >>> o.id 1l >>> hasattr(o,'x') true is checking x == none sufficient? yes, checking x none sufficient. any instance of object have attribute x , regardless of whether set - it'll none if didn't set it.

VBA duplicate PDF file -

i need help. need vba function make copies of single pdf file. example file reference/name 1, need amount x of copies lets 1 10. in order avoid coping , paste 9 times , renaming them manually sure there must function job. basic vba appreciated. many first need add reference microsoft scripting runtime in vba editor. following work... public sub test() copyfile "c:\users\randrews\desktop\1.gif", "c:\users\randrews\desktop", 10 end sub public sub copyfile(originalpath string, destinationfolderpath, copies integer) dim fs new filesystemobject = 1 copies origname = fs.getfilename(originalpath) 'file name extention e.g. 1.gif orignumber = cint(left(origname, len(origname) - 4)) 'file name converted number - crash if file name contains non numeric chars destname = orignumber + & "." & fs.getextensionname(originalpath) 'new file name = original number + + file extension fs.copyfile originalpath, destinat

NHibernate Mapping doesn't work -

i created console application, database, model, xml-file , wrote code using system; using system.reflection; using nhibernate.cfg; using nhibernate.dialect; using nhibernate.driver; namespace nhibernatedemo { internal class program { static void main(string[] args) { try { var cfg = new configuration(); cfg.databaseintegration(x => { x.connectionstring = "server=.; database=nhibernatedemo; integrated security = sspi;"; x.driver<sqlclientdriver>(); x.dialect<mssql2008dialect>(); }); cfg.addassembly(assembly.getexecutingassembly()); var sessionfactory = cfg.buildsessionfactory(); using (var session = sessionfactory.opensession()) using (var tx = session.begintransaction()) { var customers = session.createcriteria<customer>()

visual studio 2010 - Implicit default constructor not generated VS2010 -

i'm getting linker error in vs2010 sp1 compiling , linking code below, saying cannot find symbol base::base(void). seems implicit default constructor not generated. if choose initialize b follows const base& b = *d; , works fine. if make d derived* works. if make dosomething not pure virtual virtual, works. is bug or doing wrong ? tried compiling code online here http://www.compileonline.com/compile_cpp11_online.php , works fine. struct base { virtual void dosomething() const = 0; }; struct derived : base { virtual void dosomething() const override { } }; int main() { base* d = new derived(); const auto& b = *d; return 0; } thank you the code fine wrt base , nothing prevent ctor being generated. looks bug in vs2010

java - Is it possible to close stage from other class method in javafx 2? -

is possible close stage other class method in javafx 2? i developing little application stacked problem. want close loaded login fxml gui other class method(timerscheduler) after period of time. know weird close login stage after second have use of if possible. thank in advance! here sample of code: **main.java** @override public void start(stage primarystage) throws ioexception { // load stage fxml anchorpane page = (anchorpane) fxmlloader.load(getclass().getresource("/fxml/fxmllogin.fxml")); scene scene = new scene(page); primarystage.setscene(scene); primarystage.setresizable(false); primarystage.settitle("admin login"); primarystage.show(); // run timer execute task timer timer = new timer(); timerscheduler dotask = new timerscheduler(timer); int firstsart = 1000; int period = 1000; timer.schedule(dotask,firstsart,period); } **timerscheduler.java** public class timerscheduler extends timertask{

php - How to filter array values -

i have array this, need filter string keys array don't know how it, new php please me. array ( [0] => array ( [id] => 2 [0] => 2 [status] => 0 [1] => 0 [user] => 86 [2] => 86 [project] => 0 [3] => 0 [task] => 36 [4] => 36 [day] => 06/30/2013 [5] => 06/30/2013 ) ) i want make array bellow array ( [0] => array ( [id] => 2 [status] => 0 [user] => 86 [project] => 0 [task] => 36 [day] => 06/30/2013 ) ) can 1 please tell me how it? this may not best way but: foreach($array $key => $value) { if(is_string($key)) { $new_array[$key] = $value; } } where $array is array. this rebuild array $new_array using elements have string key.

xml - XSD attribute restriciton and value -

this seems simple haven't found answer yet. have xml using attribute , value together: <businessidentifier businessidentifiertype="customer number">d123456788</businessidentifier> which should validate against schema: <xs:simpletype name="businessidentifiertypes"> <xs:restriction base="xs:string"> <xs:enumeration value="plan number"/> <xs:enumeration value="customer number"/> <xs:enumeration value="scheme number"/> <xs:enumeration value="agency code"/> </xs:restriction> </xs:simpletype> <xs:element name="businessidentifier"> <xs:complextype> <xs:attribute name="businessidentifiertype" type="businessidentifiertypes" use="required"/> </xs:complextype> </xs:element> i can see i'm missing

bind - Adobe Flex - Display a Visual Element from HostComponent in MXML -

i have got skinnablecomponent: public class contentview extends skinnablecomponent { [bindable] public var titlebar:ivisualelement; public function contentview(pcontentxml:xml) { this.setstyle("skinclass", contentviewskin ); } } and want display titlebar in mxml skin file. <?xml version="1.0" encoding="utf-8"?> <s:skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:metadata> [hostcomponent("emm.app2go.viewer.component.contentview")] </fx:metadata> <s:datagroup width="100%" > <s:dataprovider> <s:arraylist source="{hostcomponent.titlebar}" /> </s:dataprovider> </s:datagroup> as can see managed datagroup kind of ugly, , thinking easier way like <fx:object source="hostcomponent.titlebar" /> or that. i hope ca

Chrome with the same version of Webkit as Safari -

i testing web application in safari 5.1.7 on windows (the latest version available). shows specific bug want verify in chrome using same version of webkit safari 5.1.7. how can find out chrome version need download? from wikipedia page safari versions know safari version 5.1.7 uses webkit in version 534.57.2, can't seem able translate version corresponding chrome version. i found post: which version of webkit in given chrome release? , doesn't quite because gives version of webkit in given chrome release, not version of chrome contains given webkit version. what in case @ list of chrome user agents , match closest webkit version, it's tricky because you'll never full match. for sake of specific questions, close safari 5.1.7's webkit engine you'd want copy of last chrome 12 version. technically webkit 534.57.2 somewhere between chrome 13.0.766.0 , chrome 13.0.782.1. given it's hard find old copies of chrome. finding old specific version o

c# - ISO8583 message header in Trx library -

i used trx iso 8583 library. library sends message length in hex. need send 4 bytes of ascii chars message header. how that? to change message header should change nboframelengthsink class in trx=>communication=>sinks=>nboframelengthsink.cs change in public void send(pipelinecontext context) function below code buffer.write(true, _bytesinheader == 2 ? new[] {(byte) (length >> 8), (byte) length} : new[] {(byte) (length >> 24), (byte) (length >> 16), (byte) (length >> 8), (byte) (length)}); to string ls_length; ls_length = length.tostring("####").padleft(4,'0'); byte[] ascii = system.text.encoding.ascii.getbytes(ls_length); buffer.write(true, _bytesinheader == 2 ? new[] { (byte)(length >> 8), (byte)length } : ascii); and in function public bool receive(pipelinecontext context) code context.expectedbytes = ( header[0] << 24 ) | ( header[1] << 16 ) | ( hea

c# - How to Disable restore box of windows form when it is in maximized condition? -

how can disable restore button in control box of windows form in c#. need make form in maximized condition when loads. possible? maximize box property false, restore box shown automatically on screen. so comment this: // define border style of form dialog box. form1.formborderstyle = formborderstyle.fixeddialog; // set maximizebox false remove maximize box. form1.maximizebox = false; // set minimizebox false remove minimize box. form1.minimizebox = false; this msdn to maximize form this: form1.windowstate = formwindowstate.maximized; again can found on msdn

namespaces - When I use "http://www.w3.org/2003/05/soap-envelope/" in switch mediator synapse is getting updated. If I use <switch ..soap-envelope", it does not -

when use, " < switch xmlns:soapenv= " http://www.w3.org/2003/05/soap-envelope/ " in switch mediator synapse getting updated. if use "< switch xmlns:soapenv= " http://www.w3.org/2003/05/soap-envelope ", not. why synapse not getting updated when not have / (slash) after soap-envelope when providing in switch? this works in other places in proxy, fault mediator etc. if use different namespace rather soapenv still works without / slash. pls explain reason behavior. thanks

.htaccess - htaccess simple URL editing -

i try edit htaccess file , iam not familiar it. default no htacces file: http://mydomain.com/html/ http://mydomain.com/html/somefolder/morefolder/ and want get: http://mydomain.com/ http://mydomain.com/html/somefolder/morefolder/ my current .htacces file looks like: options +followsymlinks rewriteengine on rewriterule ^html/(.*)$ http://mydomain.com/$1 i think simple line of code missing don't it.

java - Populating ListView Items from SQL Lite -

i need again. have listview in activity , need populate items database.. suggestions or tutorials problem? thanks in advance. waiting replies... these links useful example create listview sqlite database in android development link1 , link2 , link3

php - eregi to pregmatch not working -

how change not alphanumeric? (on google see want alphanumeric) code : /* check if username not alphanumeric */ else if(!preg_match("/^[a-za-z0-9,]+$/", $subuser)){ $form->seterror($field, "* username not alphanumeric"); } it keeps saying * username not alphanumeric this old part when had eregi /* check if username not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->seterror($field, "* username not alphanumeric"); } easist way regex use ^ inside [] character class negate it: if(preg_match('/[^a-z0-9]/i', $subuser)) { //contains @ least 1 non alpha-num character. } however, php supplies built-in function this: ctype_alnum() if(!ctype_alnum($subuser)) { .... }

date - extract month from mysql -

how can extract month sql query in mysql. date format follows: dd/mm/yyyy. month(datecol) = $month // not work. however if change date format yyyy-mm-dd works, not option. you can parse date in format sql date value str_to_date . example: select month(str_to_date('25/07/2013', '%d/%m/%y'));

content management system - override translation with silverstripe 3.x (3.1 from GitHub) -

i have folder structure mysite & themes life in 1 folder called app. try override translations app/lang/de.yml. in general app is... after: 'framework/*','cms/*' ...but seams i18n order having it's own rueleset i'm not able make them work or understand :-( i went smtg following in app/lang/_i18n.yml. after or before both not override translation. --- name: customi18n after: 'defaulti18n' --- i18n: module_priority: - app i think don't have specify order of translation files your're overriding default. placed translation files in /mysite/lang/ (de.yml,en.yml) , gave them following structure , flushed config via ?flush=all de: your.translation.key: 'foo bar'

javascript - Kendo grid custom sort -

i'm using template display link in grid column. field of column bound json object has property 'label' , property 'link'. it renders correctly filtering column impossible because kendo doesn't know how filter object. sorting doesn't work anymore on grid because of same reason. is there easy way implement custom filter , client side sorting logic column? i believe if set field property field want use filtering/sorting, , use template display column or formatted result, should give want. depending if you're using mvc helpers or javascript or else provide sample you.

kendo ui - Pop Up Edit Form for a grid: how can I know which is the currently selected row -

i have grid has edit set popup. in grid model, have defined field level validation uniqueness below. how can know select row can avoid comparing field value same row's value? model: { id: "id", fields: { id: { nullable: false, editable: false, hidden : true }, "timestamp": { type: "date", validation: { // validation rules required: true, // field required unique: function (input) { if (!input.is("[name=timestamp]")) { return true; } input.attr("data-unique-msg", '${msg.unique_time}' ); var data = grid.datasource.data(); //how can know row selected? maybe little tricky s

C# get the HTTP Headers of a GET request without body -

i've got bit of odd problem. i'm trying headers of webpage without body being sent through. request happen often, i'm doing checking last-modified, etag, , content-length headers changes. page i'm checking large, don't want download body. i know there specific head request can used in c#, when using server sends different headers standard request. head request doesn't contain of headers i'm looking for. anyone out there got ideas? without using head request not possible .better refer link .

Sharepoint 2013 testing in visual studio Update 1 -

a sharepoint application released in 3 4 months. @ time of release frequency of downloads application pretty high. need test whether server or web service application provided can bear load or not. here question. have wsdl file of web service , nothing else. how should test imposing virtual load of 20000 users in visual studio 2012 update 1. application developed in sharepoint 2013. thanks in advance! for web service load test suggest soap ui . open source (look soapui not soapui pro) , extremely easy use. can create tests , load / stress tests against wsdl , execute them once implementation there.

javascript - Android: Delivering your own ads through webview -

i trying create own sort of (mini) ad network cross-promote our own apps. not want use admob or other sdk because under impression not work more under 3.0 android sdks, app must run on android 2.3 after explaining this, wrote html page , uploaded our server (snippets taken web): <html> <head> <script src="banners.js"> <style> html { position: relative; min-width: 320px; min-height: 50px; height: 100%; } </style> </script> </head> <body style='margin:0;padding:0;' onload = "javascript:rotatebanner();javascript:setinterval('rotatebanner()',20000);"> <a href= "http://www.bigfoot.com/~java4free" onmouseover = "javascript:pause()" onmouseout = "javascript:resume()"> <img style="margin-left:auto;margin-right:auto" src = "first1.jpg"></a> </body> </html> the javascript be: <!-- //hide non-javascript b

is this possible with facebook api? -

i new fb apps, before reading docs need make sure possible. can make every time user updates status, , has granted application access, automatically send message application update database status, or maybe call function? you think of "passing message" ;) thanks! select message status uid=me() (put user id here) i don't how go being notified second happens every time, if routinely query of relevant statuses.

javascript - Jquery: get birthday value from page and substitute with age value -

i have jsp having table users info , there's column representing user's birthday in format yyyy-mm-dd . want substitute birth dates actual age of user. have simple js function getage it: function getage(datestring) { var today = new date(); var birthdate = new date(datestring); var age = today.getfullyear() - birthdate.getfullyear(); var m = today.getmonth() - birthdate.getmonth(); if (m < 0 || (m === 0 && today.getdate() < birthdate.getdate())) { age--; } return age; } i've tried run after page initializing in way: $().ready(function({ $(".age").html(getage($(this).html())); })); where .age class of "age" column. that's way expected work: $(".age") - finds cell class="age" $(".age").html(getage($(this).html())); - substitues html in found cell value returned getage() function argument getage current value in cell. shows nothing =( if use

jdbc - How is a Log4j2 JDBCAppender used to insert into a date column? -

i trying use log4j2's jdbcappender insert value oracle date column. know how use iseventtimestamp, need insert date threadcontext. i'm guessing i'm not formatting date correctly, can't find documentation on how correctly format. how i'm formatting date: threadcontext.put("date_value", new date().tostring()); this log4j2 jdbcappender column element i'm using: <column name="date_column" pattern="%x{date_value}" /> this error i'm getting: 2013-07-25 08:17:18,145 error failed insert record log event in manager [jdbcmanager{ description=xxxxxxxxx, buffersize=5, connectionsource=drivermanager{ url=jdbc:oracle:thin:@//xxxxxxxxx, username=xxxxxxxxx, passwordhash=xxxxxxxxx }, tablename=xxxxxxxxx, columns=[ { name=date_column, layout=%x{date_value}, literal=null, timestamp=false } ] }]. java.sql.sqldataexception: ora-01858: non-numeric character found numeric expected @ oracle.jdbc.driver.t4cttioer.processerror(

Rewinding ZipInputStream - Android -

i trying read zip archive zipinputstream . cycle through entries without problem so: try { while((ze = zis.getnextentry()) != null) { log.v(this.tostring(), "name = " + name); } } catch (ioexception e) { // todo auto-generated catch block //e.printstacktrace(); log.e(this.tostring(), "ioexception in creating zipentry."); } when try use zis variable read same zip file in function, in same manner described above, line ze = zis.getnextentry() returns null . understandable because end of stream has been reached. my question(s): 1. how "rewind" stream? 2. there alternate creating temporary zipinputstream , using in next function required read zip file again? there no way rewind zipinputstream in java. the alternative restructure code have read stream once. advantageous (depending on context of situation), not require unzippin

python - Running tests in Google App Engine package? -

i have question concerning way in python imports modules , creates objects within packages, i'm using flask on google app engine think problem more general. my app has following structure: app/ application/ __init__.py flaskr.py models.py mainconfig.py etc... tests/ tests.py configtest.py apptest.py run.py i using google app engine launcher , works okay of time. when want run app use dev_appserver.py. appserver requires path app argument, when gets it imports stuff google app engine folder , executes app. i'm happy that. the problem i'm having concerns tests, importantly have problem way tests load configuration @ runtime . have separate configuration tests, don't want them use mainconfig.py, should use configtests.py. unfortunately @ moment each time run tests tests using default app configuration , not own specific options - example insert data app database, , not testing database have hardcoded

uitableview - iOS 7 - can I change the delete button background colour in the UITableViewCell? -

Image
so i've been studying while , looks though big job change default view editing table row. i want change background colour more in line app in ios 7. can done without subclassing? you use this: https://www.cocoacontrols.com/controls/swtableviewcell

node.js - Returning objects from mongoose model -

i have following code in user.js class: exports.finduser = function(namein){ user.find({ name: namein }); )}; how can make 'return' users found? telling me using "return" not best practice on node? think need use callbacks but, how? this code using call function: var user = require("../models/user.js"); user.finduser(req.params.name, function(users) { console.log(users); }); in finduser don't seem providing place callback go. mongoose query returns document(s or error) callback handled. if wanted modify finduser fit how seem using it: exports.finduser = function(namein,callback){ user.find({name: namein}, function(err,user) { if (err) throw err; callback(user) }); )}; the results of mongoose's query (successful or not) handed function in arguments of query (as callback), in line asynchronous nature of node. other accepted methods of handling node's non-blocking i/o events , streams , metho

maven - Run Main Class in Spring In Action 3 -

i imported spring in action 3 . how have modify pom.xml run main class instead of or additional junit test? added following plugin parent pom.xml, not executed. <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>exec-maven-plugin</artifactid> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainclass>com.springinaction.knights.knightmain</mainclass> </configuration> </plugin> you need bind execution of plugin test phase, example <executions> <execution> <id>run-class-as-part-of-tests</id>

c - How to handle data structures with indices larger than 32 bits? -

i have large index of size 80-bits , corresponding data stored in data structure on need search. can use 80-bit index in hash table?? or there better alternative data structure take constant time lookup (search)? edit: i think question not clear.... here setup --- have millions of files produce cryptographic hash trapdoor of size 80-bits (to represent file securely) , each 80-bit trapdoor stored data in data structure hash table. since domain of 80-bit trapdoor larger range of hash table, there collisions sure. need unique <80-bit trapdoor,data> pairs stored in data structure. how can achieve using hash table? or if there other alternative ds? edit 2 : let's created hash table , there occurred collision when adding keys (say x & y in order) because hash function generated same index ( i ) keys. using collision resolution techniques (eg. double hashing), y inserted in different location j not i . understand till point. if want search based on key y, hash ta

android - Can't open a local PDF in webview using file:// -

i need display pdf file located in app dir in webwiev without using google docs. this code webview: public void openpdf() { webview webview = new webview(this); setcontentview(webview); webview.getsettings().setjavascriptenabled(true); webview.loadurl("file://mnt/data/data/com.example.android/files/docs/test.pdf");; } i blank webview instead of below code works public void openpdf() { webview webview = new webview(this); setcontentview(webview); webview.getsettings().setjavascriptenabled(true); webview.loadurl("file://mnt/data/data/com.example.android/files/docs/test.html"); } i tested directly in web browser file://mnt/data/data/com.example.android/files/docs/test.pdf , test.html , worked both. installed pdf reader. 07-25 17:09:07.967: w/webcore(11347): java.lang.throwable: eventhub.removemessages(int = 107) not supported before webviewcore set up. 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.webviewcore$e