Posts

Showing posts from July, 2014

android - How to resolve: media scanning not yet finished -

i developing 2d action game on android platform. works on emulator, when test game on device (specially samsung galaxy ace s5830), hangs vibration. while examining device logs, found following 3 type of error messages frequent: 02-25 06:33:05.510: error/tethering(167): active iface (usb0) reported added, ignoring 02-25 06:29:30.120: error/libgps(296): dns_query_loop: gethostbyname failed. h_errno 2 02-25 06:20:40.687: error/mtp-launcher(922): media scanning not yet finished. out of above error messages, last 1 comes when game got hang on device. there no need internet connection & no apis accessing internet used in code. doubt error/mtp-launcher(922): media scanning not yet finished. error causing game hang vibration. i eagerly looking suggestions problem.

php - Managing nested sets of data -

i have been reading storing nested data , examples have come across far demonstrate on how 1 can create , manage hierarchy of nodes in database table when using nested set model.i wondering if table(parent) can have children tables(nodes).by table mean ordinary mysql table data of course. if use nested sets, don't see how distribute data between different tables in advantageous way. thing nested sets there no called parent , children elements. there nodes , every node can parent and/or child. draw line? store first 3 levels in 1 table , rest in another. doesn't sound me. nested sets not human readable when stored in flat database because of inherent structural difference between tables , hierarchies.

c++ -- how to implement a framework that supports plugins -

as know, eclipse framework supports plugins based application development. using c++ coding , learn how build framework support plugins development. 1 example notepad++ supports plugins. there book or resource can refer to. thank you this looks pretty overview of how 1 it: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2015.pdf beware proposal generic plugin framework c++ language. particular application, may not need described features.

amazon ec2 - How to generate the EC2 cerificate -

while setting ec2 access, seems need 2 files, private key , ec2 certificate. $ export ec2_private_key=~/.ec2/pk-hkzyktaig2ecmxyibh3hxv4zbzq55clo.pem $ export ec2_cert=~/.ec2/cert-hkzyktaig2ecmxyibh3hxv4zbzq55clo.pem however, did not find anywhere download or create key. from documentation: the command line tools need access private key , x.509 certificate generated after signing amazon ec2 service. i missed that, possible generate again when signed in on aws website go account -> security credentials -> x.509 certificates. you can generate, download, or upload certificates there.

c# - Can an exception during OnRelease cause a component to not be disposed correctly? -

i've got following code wiring nhibernate isession in autofac asp.net application : builder.registeradapter<isessionfactory, isession>(factory => factory.opensession()) .instanceperhttprequest() .onactivated(activatedargs => { var session = activatedargs.instance; session.begintransaction(); }) .onrelease(session => { if (session.transaction != null && session.transaction.isactive) { try { session.transaction.commit(); } catch(exception e) { session.transaction.rollback(); throw; } } }); will session disposed thrown exception in commit? correct usage of isession au...

Process Builder and Process in Java - how to execute a process with a timeout :? -

this question has answer here: java native process timeout 6 answers i need execute external batch file in java specific timeout. means if batch execution take longer specified timeout, need cancel execution. here sample code wrote: public static void main(string[] args) throws ioexception, interruptedexception { processbuilder p = new processbuilder("c:\\wait.bat", "25"); // batch file execution take 25 seconds. final long l = system.currenttimemillis(); system.out.println("starting..." + (system.currenttimemillis() - l)); final process command = p.start(); system.out.println("started..." + (system.currenttimemillis() - l)); timer t = new timer(); t.schedule(new timertask() { @override public void run() { command.destroy(); } }, 5000); // kill process...

eclipse - problem when updating sts or installing extensions -

i'm working sts 2.5.0 , when tried install gwt extension encountered following error: an error occurred while collecting items installed session context was:(profile=com.springsource.sts.ide, phase=org.eclipse.equinox.internal.p2.engine.phases.collect, operand=, action=). no repository found containing: osgi.bundle,oracle.database.driver.jdk14,10.2.0.1 then tried update sts newest version (2.5.2) , got same error. anyone happens know what's problem?? thanks i believe bundle belongs oracle enterprise pack eclipse (oepe), , not sts itself. try download , reinstall latest version of oepe oracle technology framework .

c# - Creating Object Instances Faster Than Reflection in Windows CE -

so after looking @ article describing how create object instances faster reflection got excited since in code have quite bit of reflection. unfortunately dynamicmethod , ilgenerator not supported in windows ce. edit : activator supported in windows ce i wondering if knew of way create object instances faster reflection in ce. if not, maybe explain why windows ce not support feature , if there work arounds feature in ce. if had code own dynamicmethod , ilgenerator classes might worth :) first, activator supported. take @ the docs here . that said, it's not fastest thing on planet, if intend create more 1 instance of given type. did in opennetcf.ioc framework after lots of testing of different way build object cache constructorinfo on per-type basis (specifically in objectfactory class ) , used object creation. yes, you've got use reflection ci first time, subsequent calls fast since you've got delegate.

wpf - GridViewColumn with no cells? -

is possible have 3 gridviewcolumn 2 celltemplate ? want first cell "occupy" 2 left columns ? is possible ? i don't think can directly, can create 2 regular columns, , make header of first 1 line in middle, it's 2 cells.

iphone - when I build and analyze, I got potential leak on at this point -

(bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { [self.window addsubview:rootcontroller.view]; [self.window makekeyandvisible]; [[controlfile alloc]scedule1]; return yes; } i got potential leak of object allocated on [[controlfile alloc]scedule1] when build & analyze [[controlfile alloc]scedule1]; this allocating instance of class controlfile , calling scedule1 on allocated object. (note it's not yet initialized; should have initialized first calling init ). object (which allocated) never referenced again. thus, have leaked it. you need this: id controlfile = [[controlfile alloc] init]; [controlfile scedule1]; [controlfile release]; this assumes controlfile class. if it's instance variable (as indicated lowercase text , lack of declaration in code), want this: controlfile = [[whateverthedeclaredclassofcontrolfileis alloc] init]; [controlfile scedule1]; // in ...

java - How to parse the string into map -

have string a=b&c=d&e=f, how parse map? i use split string text = "a=b&c=d&e=f"; map<string, string> map = new linkedhashmap<string, string>(); for(string keyvalue : text.split(" *& *")) { string[] pairs = keyvalue.split(" *= *", 2); map.put(pairs[0], pairs.length == 1 ? "" : pairs[1]); } edit allows padded spaces , value = or no value. e.g. a = minus- & c=equals= & e==f

click - jQuery fadeOut() and clicking issue -

this returner, part of php-driven cms. we want returner (if has class admin ) add div hide , little x button. returner should automatically fadeout() after 4 seconds, or fadeout() if user clicks on hide button. each of //here codes work on own, run delayed fadeout() , not clicked one! any great. thanks, nick. $(".success, .info, .warning, .error").each(function(){ if(!$(this).hasclass("admin")){ $(this).append('<div class="hide"></div>'); $(this).delay(4000).fadeout(); // here } }); $(".hide").click(function(){ $(this).parent().fadeout(); // here }); since .hide appended dynamically need use .live() (or delegate ) click handler function correctly. since using delay() try call .stop() on parent clear delay run fade out animation. $(".hide").live('click', function(){ $(this).parent().stop().fadeout(); // here }); example of on jsfiddle .

java - HTML Well-formedness parser -

heyy guys, need determine if given html document formed or not. need simple implementation using java core api classes i.e. no third party stuff jtidy or something. actually, needed algorithm scans list of tags. if finds open tag, , next tag isn't corresponding close tag, should open tag in turn should have close tag next tag, , if not should open tag , corresponding close tag next, , close tags of previous open tags in reverse order coming 1 after other on list. if list conforms order returns true or else false. i've written methods convert tag close tag. here skeleton code of i've started working on already. not neat, should give guys basic idea of i'm trying do. public boolean validatehtml(){ arraylist<string> tags = fetchtags(); //fetchtags returns [<html>, <head>, <title>, </title>, </head>, <body>, <h1>, </h1>, </body>, </html>] //i create arraylist store tags haven't ...

sql - Long Database name when attaching MDF file -

i'm attaching mdf file local sql server tests i'm running mstest , creating database long , annoying name looks this 7e7051d0dee46dee6531ef012dc110f4_ork\myproject.objects\testresults\myname_mycomputername 2011-03-01 15_46_50\out\database.mdf is there way specify how database named? not should same every test, want make these names more meaningful. ideas? thx in advance! i can't recall syntax attaching database (nor can generate on pc :(.), in ssms can use attach database dialog , select new database name, click "script" button generate sql, should able modify needs.

jquery - window.close() in success function -

i have typical ajax post type success function. have tried in many different ways close window on success. after message revealed , can read. $.ajax({ type:"post", url:"file.php", data:info, success:function(){ $('#load').empty(); $('#information').html('thank you!'); \\settimeout('window.close()',2000); \\ } }); return false; page opened "window.open()" try settimeout(function(){window.close();},2000); you can reference window: var wind = window.open();//then settimeout(function(){wind.close();},2000);

php - cakePHP: How to change the ID of a form element (using the form helper)? -

i've created form has loop display number of rows. have select on each row using form helper. ids creates same, there way add counter, or defining info id? i'm using $this->form->input('city_id') output select of cities city model. ids modelcityid . i'd modelcityid1, modelcityid2 , modelcityid3 , etc. possible? or there better way go displaying options in loop? thanks suggestions might have. here relevant part of code. while ($current_date != $departure_date) { $current_date = date("d-m-y", strtotime($current_date . " +1 day")); $output .= '<tr>'; $output .= '<td>'.$current_date.'</td>'; // irrelevant other columns $output .= '<td>'.$this->form->input('city_id', array('label' => '', 'empty' => true)).'</td>'; $output .= '</tr>'; } if ids same, name same well. that'll mess dat...

php - Tables in Tabbed Panes -

i have this. <div id="tabs"> <ul> <li><a href="#tabs-1">tab 1</a></li> <li><a href="#tabs-2">tab 2</a></li> <li><a href="#tabs-3">tab 3</a></li> </ul> <div id="tabs-1"> <p>tab 1 content</p> </div> <div id="tabs-2"> <p>tab 2 content</p> </div> <div id="tabs-3"> <p>tab 3 content</p> </div> </div> instead of content (tab 1 content...) in each of tabs, need tables. structure of tables in 3 tabs same, content changes mysql query. query results may have thousands of rows. how can go it? new javascript , php thanks what trying achieve basically: <div id="tabs"> <ul> <li><a href="#tabs-1">tab 1</a>...

java - XSLT to ICEFaces markup -

is possible apply xslt xml document , generate markup processed jsf/icefaces? i need xslt add <ice:commandbutton elements , such, since data elements render require related command buttons. do have tutorials xslt , icefaces? thank in advance. yes, possible. need create servlet filter runs before facesservlet kicks in , takes care xsl-generated facelet file present there facesservlet expects it. see this answer detailed kickoff example.

java ee - how to translate servlet to JSP? -

can me translate servlet jsp here's code: package inventory; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class displaydata extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html"); printwriter out = response.getwriter(); item item = (item) request.getattribute("invenitem"); if (item != null) { out.println("<html><title>inventory item</title>"); out.println("<body><h1>inventory item details:</h1>"); out.println("stock id : " + item.getstockid() + "<br/>"); out.println("name : " + item.getitemname() + "<br/>"); out.println("unit price: " + item.getunitprice() + "<br/>"); out.println(...

Full-Screen Android Layout with 2 Rows -

i'm complete beginner android development , i'm trying feel should simple doesn't seem (for me, anyway). awesome ascii art below demonstrates layout i'm trying achieve: --------------------- | | | | | | | | | | | main view | | | | | | | | | | | --------------------- ||btn a| |btn b|| --------------------- the whole layout should fill screen bottom row being docked bottom of screen (gravity?) , top row taking rest of screen , should fluid (i.e. if device orientation changed this: --------------------------- | | | | | main view | | | | | --------------------------- ||btn a| |btn b|| --------------------------- if working in html done table element, 2 t...

animation - Should I be using flash for this? -

i helping friend website non-profit organization. main page simple, using standards compliant, semantic xhtml , css. question revolves around feature wants include. she wants have section of site letters spell out organization's name across top. wants cycle through these letters, , "active" letter should highlight letter , change display in rest of box pertinent images/info. - imagine name of org example- box say: e x m p l e across top, , first "e" brighten or highlight, box fill text saying "e blah" link blah. after 5 or 10 seconds, fade out, "x" highlight, , box fills "x fooblah", etc..., repeat ad nauseum. i know in flash, i've been wary of using flash, contains nav elements (although not main site nav). how more experienced web developers here attack problem? should bite bullet , use flash, or other technologies? i'd love not alienate iphone/ipad users, can sniff flash player , display static image o...

java - /* (non-javadoc) meaning -

possible duplicate: does “/* (non-javadoc)” have well-understood meaning? what following statements mean? /* (non-javadoc) * * standard class loader method load class , resolve it. * * @see java.lang.classloader#loadclass(java.lang.string) */ @suppresswarnings("unchecked") i have seen message generated eclipse when programmer asks eclipse add javadoc comment code in location [edit: eclipse thinks] javadoc tool not use it. a common example implementation of method in interface implemented class (which in java 6 needs @override annotation). javadoc use javadoc placed on method in interface , not 1 provided in implementation. the rest of comment written person did not know this.

multithreading - Getting a reference to the current boost::thread/interrupting the main thread -

i trying reference main boost::thread of execution, can interrupt it. however, boost::thread doesn't seem supply way of doing this. i have searched on internet can't seem find answer question. did see old answers, seem relevant old boost code. closest 1 said using boost::thread t; (the default constructor) give me reference current thread. however, boost documentation seems that create reference not-a-thread . my main goal interrupt main thread, , not reference current boost::thread, seemed easiest way. my current solution create new thread main, , join() it. there way current thread object (or interrupt it) , not use workaround? thanks a default constructed boost::thread object used (in v1.34 , earlier) refer current thread, not longer. you cannot interrupt main thread in boost. workaround of starting new thread work, , joining main() best way.

email - php imap reading body message -

i writing simple php script reading emails. when extract mail body with: imap_body($mbox, $i); i have returned this: --0016e6db2b334d4d7904a883f4ec content-type: text/plain; charset=iso-8859-1 <the message arrived> --0016e6db2b334d4d7904a883f4ec content-type: text/html; charset=iso-8859-1 <the message arrived> --0016e6db2b334d4d7904a883f4ec-- how can extract only: ? using php_imap. thanks. if using imap, can use imap_body() function read body. php has ton of functions parsing email. http://www.php.net/manual/en/ref.imap.php check out fetch_body() function too. allow part of body. http://www.php.net/manual/en/function.imap-fetchbody.php for example: $message = imap_fetchbody($inbox,$email_number, 1.2);

JavaScript push to array -

how push new values following array? json = {"cool":"34.33","alsocool":"45454"} i tried json.push("coolness":"34.33"); , didn't work. it's not array. var json = {"cool":"34.33","alsocool":"45454"}; json.coolness = 34.33; or var json = {"cool":"34.33","alsocool":"45454"}; json['coolness'] = 34.33; you array, different syntax (and not want) var json = [{"cool":"34.33"},{"alsocool":"45454"}]; json.push({"coolness":"34.33"}); note variable name highly misleading, there no json here . name else.

user interface - How to extend a list to add a UI Component? -

how can extend spark list add ui component on it? i'm assuming want add ui component items within list itself, in case can use itemrenderers. there several good examples out there. i'm pasting fancy example flex examples (great site) below. myapplication.mxml: <?xml version="1.0" encoding="utf-8"?> <!-- http://blog.flexexamples.com/2010/01/27/creating-a-fancy-spark-list-control-item-renderer-in-flex-4/ --> <s:application name="spark_list_itemrenderer_test" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:local="*"> <fx:style> @namespace s "library://ns.adobe.com/flex/spark"; s|list { chromecolor: #333333; color: white; contentbackgroundcolor: black; fontsize: 24; ...

ruby on rails - RoR: defining a class inside a view helper file -

i have view helper file, app/helpers/analysis_helper.rb, toplevel methods i've been using in various view files. works fine. defined analysissummary class inside analysis_helper.rb package view-specific functionality. however, when try instantiate analysissummary in view file, error: uninitialized constant actionview::compiledtemplates::analysissummary perhaps rails telling me shouldn't defining class inside helper file? if so, suggest parking analysissummary? it's not controller, it's not model... thanks. why need class? why not collection of methods? that's helper is: collection of helpful methods. business logic not belong in helpers. can place code in module within helper file if want give more structure , organization, though. you can put classes in app/models without having activerecord class, should consider purpose of class before place there. if concerns rendering view, , not accessing data directly, belongs in view or view hel...

Django Model Charfield many Choices automatically create? -

i want add choices between year 1950 2020. how can that? a = 1950 while < 2020: b=a + 1 year_choices = ( ('b', 'b'), ) class sezonlar(models.model): sezon = models.charfield(max_length=4, choices=year_choices) the requirement choices field just: an iterable (e.g., list or tuple) of 2-tuples use choices field. so can construct using list comprehension so: year_choices = [(str(yr), str(yr)) yr in range(1950, 2020)]

asp.net mvc - MVC custom validation determine if edit or insert -

i have viewmodel want perform more custom validation on. i have made viewmodel inherit ivalidatable , have validation in: public ienumerable<validationresult> validate(validationcontext validationcontext) { ... } this works fine want validation creates , not edits. i'm thinking way of doing how determining within method whether edit or create. is there way of doing or thinking aboout whole thing incorrectly? use separate view model create , insert actions. if validation rules different, think worth use separate models anyway. public class insertmyobjectviewmodel : ivalidatable { [required] public string name { get; set; } // note lack of required attribute here public string address { get; set; } public ienumerable<validationresult> validate(validationcontext validationcontext) { ... } } and separate edit public class updatemyobjectviewmodel : ivalidatable { [required] public string name { ge...

collections - Comparing java maps via hashing -

i want compare 2 java map s simple hash. each object on different computer, sending hash on network cheaper sending whole object compare. for example have 2 hashmap s of exampleclass map<string,exampleclass> one=new ...; map<string,exampleclass> other=new ...; i don't need sure elements equal , it's enough me trust in hash. i iterate @ each side , create "homemade hash", send network compare example int or something. it great if "hash" calculated every time object added or deleted collection, saving me iterate whole object. have encapsulate every add/delete of map . there java library this? if classes implement hashcode() (does not use "default" memory address hashcode ) can use map's hashcode() . the caveat here if exampleclass not implement hashcode() , equal items might have different hashes on 2 different machines, result in different hashes maps. to clarify: map implements hashcode() d...

java - How to create a calendar object based on current time plus some seconds -

i wondering if can new calendar object based on current time plus given timespan, 5 minutes. calendar c = calendar.getinstance(); //gives u calendar current time c.add(calendar.minute, 5); //add 5 minutes calendar

indexing - how should I think about search engine indices? -

i using elastic search , not understand index is. example, if have 3 models (a backpack, shoe , glove), put each model in own index or index attributes of each model: ie index shoe's laces, sole, etc? i trying understand if slow search across indices. example, if index each attribute of models , have say, 20 indices, when run search needs @ data in of indices, slower having single index , looking @ 20 attributes stored in index? in elasticsearch, index consists of 1 or more primary shards, shard lucene instance. each primary shard can have 0 or more replicas, existence gives high availability , increased search performance. a single shard can hold lot of data. however, multiple shards easier distribute workload across multiple processors , multiple servers. that said, need balance. right number of shards depends on data , context. shards aren't free, while useful have thousands of shards if you're running 100 node cluster, don't want on single no...

javascript - Which version of firefox will support Web SQL? -

i'm developing app needs offline storage sql. i try: if (window.opendatabase) { window.db = window.opendatabase("app", "", "my app db name", 1024*1024); } this works great on chrome doesn't work on firefox 3.6 what version of firefox support opendatabase? mozilla have said never implement according thread: html5 indexeddb, web sql database , browser wars

c++ - in-memory cache design using OO concept -

what in-memory cache? not find information on web. in fact, asked design in-memory cache based on oo concept using c++, not know how start. suggestions appreciated. this depends on context generally, in-memory cache stores value can retrieved later, instead of creating new object. used in conjunction databases – or application construction / retrieval of object expensive . for simple memory cache, imagine following dummy class (which violates tons of best practices, don’t copy it!): class integer { int value; public: integer(int value) : value(value) { sleep(1000); // simulates expensive constructor } }; now imagine need create instances of class: integer one(1); integer two(2); // etc. … later (in method) perhaps need create a new instance of 2: integer two(2); this expensive. if recycle old value? using constructors, isn’t possible using factory methods can easily: class integer { int value; static std::map<int, intege...

datetime - Why some dates give worse performance than other in MS SQL Server -

i have query in ms sql server asking name , date-related information, depending on 2 dates, start- , enddate. the problem is, i´m not getting same performance. whenever request between dates; 2010-07-01 00:00:00.000 , 2011-07-21 23:59:59.999 the performance excellent. result within mseconds. when request between these dates, example, 2011-07-01 00:00:00.000 , 2011-07-21 23:59:59.999 the performance is.. less good, taking between 20-28 seconds each query. note how dates giving performance more year between, while latter 20 days. is there particular reason (maybe related how datetime work) this? edit: query, select ename, sum(case date when 0 1 else 0 end) u2, sum(case date when 1 1 else 0 end) b_2_4, sum(case date when 2 1 else 0 end) b_4_8, sum(case date when 3 1 else 0 end) b_8_16, sum(case date when 4 1 else 0 end) b_16_24, sum(case date when 5 1 else 0 end) b_24_48, sum(case date when 6 1 else 0 end) o_48, sum(case date wh...

Visual Studio 2010 new install missing search solution toolbar -

just reinstalled visual studio 2010 , toolbar lets me search entire solution missing , cannot seem find toolbar option of member. any appreciated. it's settings issue persisted across reinstall. try reseting settings default , see if fixes problem. method 1 tools -> import / export settings reset settings pick favorite profile method 2 from visual studio command prompt type following devenv.exe /resetsettings

r - Mountain like plot for data in Square matrix -

Image
i have data square matrix. want plot meshgrid in matlab (mountains color gradients). also, if there big cliff, want label it. shown below the data have _92765 _222156 _384259 _384249 _384247 _384250 _92765 -1 3.4 4.85106 8.12927 8.462 9.12643 _222156 3.4 -1 1.50877 3.66383 3.58554 3.69655 _384259 4.85106 1.50877 -1 4.48433 4.51367 4.14421 _384249 8.12927 3.66383 4.48433 -1 0.288 0.252 _384247 8.462 3.58554 4.51367 0.288 -1 0.196 _384250 9.12643 3.69655 4.14421 0.252 0.196 -1 how can go it? thanks have looked @ wireframe() function in lattice library? here example on-line help: library(lattice) wireframe(volcano, shade = true, aspect = c(61/87, 0.4), light.source = c(10,0,10))

c# - How to store a reference to a static class? -

so like: public static class staticclass {} public class instanceclass { static staticclass staticproperty {get;set;} public instanceclass() { instanceclass.staticproperty = staticclass; } } i thought 1 compiler returns these errors: static types cannot used parameters static types cannot used return types edit: know doesn't work, why? imagine staticclass stored somewhere in memory, other variables allowed refer @ same memory, right? edit2: 1 of use cases this: say have 5 different static classes have collected no source code, , generic stuff, want have convenient access them through single static class. like: public static class genericstuff { public linearalgebra linearalgebra {get;set;} public stringutilities string {get;set;} public geometryops geometry {get;set;} } and use like: genericstuff.linearalgebra.getanglebetweenvectors(v0, v1); some other use cases think of. update : going use psychic pow...

iphone - How to get the pointers to an id variable and an NSObject pointer? -

id idpointer = [[someobject alloc] init]; nsobject *nspointer = [[someobject alloc] init]; how pointers of idpointer , nspointer ? to pointers pointers requires * on variable. , assign them address of normal pointer & . , dereference them again * in front. //declare , assign them id *idpointerpointer = &idpointer; nsobject **nspointerpointer = &nspointer; //dereference them (just example send message) [*idpointerpointer release]; [*nspointerpointer release];

Handling OCX errors in VFP (FoxPro) -

i have ocx can cause "internal application error" when calling 1 of it's methods in vfp9. i've tried using on error , try/catch. both, instead of getting error, microsoft visual forpro has encountered problem , needs close.... send error report/don't send dialog. this code looks like. on error code (note never see wait window): local lconerror public glerrorresult glerrorresult = .f. lconerror = on('error') on error glerrorresult = .t. this.oocxcontrol.method() if glerrorresult wait window 'error' endif on error &lconerror release glerrorresult try/catch code (again, never see wait window): local oerror exception try this.oocxcontrol.method() catch oerror when .t. wait window 'error' endtry is there else try handle error prevent app crashing? so have misbehaving ocx control. i'll assume you've considered options replacing vendor's control, or checking updates. far being able handle error, i...

java - How does the Play Framework function? -

i love play!. compared other enterprise java frameworks, it's incredibly simple developer use. but, how that? makes edit-refresh cycle possible compile language java? makes play! work way works? play uses eclipse compiler compile code @ run-time. take @ following class, used play perform necessary compilation @ run time. https://github.com/playframework/play/blob/master/framework/src/play/classloading/applicationcompiler.java

objective c - CoreData Optional Relationships and JSON null -

i have coredata model 2 objects. first object (images) contains list of image names. second object (book) has relationship field images object called imageid. data type set int16 , marked optional default value of 0, not every book have image. i request json representation of book object wcf service. 1 of book objects returned has "imageid" : null value. when converting json object managed object in objective-c following error message: unacceptable type of value attribute: property = "imageid"; desired type = nsnumber; given type = nsnull; value = how handle conversion? thought of checking null , setting value 0 doesn't seem correct. many thanks. * update * in process of implementing daniels solution discovered other fields returned service null. therefore possible modify nsdictionary category enable traverse , replace instance of nil? using jsonkit json parser , seems return parsed result nsmutabledictionary nsdictionary objects representing jso...

iphone - Private properties and methods in Objective-C -

in looking @ 1 of apple's examples, in tableviewcontroller.m, have this: // private tableviewcontroller properties , methods. @interface tableviewcontroller () @property (nonatomic, retain) nsmutablearray* sectioninfoarray; @property (nonatomic, retain) nsindexpath* pinchedindexpath; @property (nonatomic, assign) nsinteger opensectionindex; @property (nonatomic, assign) cgfloat initialpinchheight; ... more properties , methods @end @implementation tableviewcontroller ... usual stuff i'm wondering why put these properties in .m file , how private. seems imports tableviewcontroller.m file can use these properties , methods right? why not use @private in .h file? what they're doing declaring category on class, since done in .m file, effect methods "invisible". this doesn't mean methods cannot called outside. due fact there no real privacy in objective c, because we're dealing messages, not method calls. means can send object message if ...

Adding delay to a $.post jquery request -

i'm sending jquery $.post request on checkbox change in form. want delay $.post 500 ms in case user checks more 1 checkbox rapidly, avoid multiple useless requests. here's code, i've added settimeout function seems work except $.post function... var delay = (function(){ var timer = 0; return function(callback, ms){ cleartimeout (timer); timer = settimeout(callback, ms); }; })(); $(document).ready(function() { $('.checkbox').change(function() { delay(function(){ $.post("/?page_id=4", $("#selectors").serialize(), function(data){ $('#results').html(data); }); }); }, 1000 ); }); any idea why doesn't work? live example this: $('.checkbox').change(function() { delay(function(){ $.post("/?page_id=4", $("#selectors").serialize(), function...

windows - Latex plugin for visual studio 2010 -

i looking latex plugin visual studio 2010 (preferably free) . features must have: code folding syntax highlighting autocompletion error handling i not think there available vs. alternative, use eclipse texlipse plugin. has of features on list. not use windows ubuntu eclipse, r, mysql , sweave sufficient cater data connection, management, manipulation, analytical , reporting needs. tools listed available on windows sufficient connectivity sqlserver rodbc.

c# - Multithreaded file reading, does seek & read need critical section? -

i have file read multiple threads, need put each seek , read critical section? stream.seek(seekstart, seekorigin.begin); stream.read(); stream.seek(seeknext, seekorigin.current); stream.read(); or lock(filelock) { stream.seek(seekstart, seekorigin.begin); stream.read(); stream.seek(seeknext, seekorigin.current); stream.read(); } obviously i'm trying avoid following situation: . . thread a: seek <- preempted -> thread b: seek thread b: read <- preempted -> thread a: read (will reading wrong location?) . . because streams separate objects in separate threads, should ok without making critical. each stream should hold own seek location, , should not interfere others. this assumes declaring of variables within class object, , not static.

java - ExpandableListView Order Changed When Click -

when click groupview order of expandablelist changes i've found 1 similiar problem here the order seems random, don't understand happened. here's code, know it's mess, i've rewritten lot of times. public class managelistadapter extends baseexpandablelistadapter{ public static final int server_type=0x000001; public static final int history_type=0x000002; private list<serverelement> mdata; private layoutinflater minflater; private int viewtype; public managelistadapter (context c,int type,arraylist<serverelement> data){ minflater = (layoutinflater)c.getsystemservice(context.layout_inflater_service); mdata=(list<serverelement>) collections.synchronizedlist(new arraylist<serverelement>()); mdata=data; } @override public object getchild(int groupposition, int childposition) { // todo auto-generated method stub return mdata.get(groupposition); } @override public long getchildid(int groupposition, int childposi...

javascript - What the right way to graph negative numbers in Protovis? -

for simplest use case, bar chart values ranging -10 10, how 1 go coding cleanly using protovis javascript charting library? by cleanly mean centering axis, showing x , y axis labels, , representing column values of chart negative values fall below y axis , positive values exceed y axis. here's working example: http://jsfiddle.net/nrabinowitz/yk5by/3/ the important parts of follows: make x-axis scale going min value max value (in case, pv.scale.linear(-10,10).range(0,w) ; in example, calculate min , max based on data). base width of bar on absolute distance of datum 0: .width(function(d) { return math.abs(x(d) - x(0)); }) then adjust .left() property based on whether datum positive or negative: .left(function(d) { return d > 0 ? x(0) : x(0) - this.width(); }); because we're using simple x-axis scale, adding axis labels super-easy: vis.add(pv.label) .data(x.ticks()) // use pv.range(min, max, 1) here .left(x);

Database schema design and foreign keys in MySQL -

i'm trying create normalized database blog allowing reply comments. given few answers found, seems need @ adjacency list model , modified preorder tree traversal algorithm. however, after reading bit it, haven't found example of using foreign keys enforce data integrity. can done? what database design recommend in case? ideally, i'd able eliminate parent comment, , using pk-fk relationships (pk = primary key, fk = foreign key) able eliminate child comments in order avoid keeping orphans in table. update : clarification, i'd know database design used in blogs allow reply comments (that is, comments reply comment reply original thread). reddits source code open source on github, see how it....

php - split string after x characters -

how split $string after 5 characters array example: $string="123456789"; expected output $output[0] contain "12345"; $output[1] contain "6789"; if need split string after every 5 characters, try str_split() : $output = str_split($string, 5); if need extract first 5 characters , put rest of string in second part of array, can use substr() nulluserexception suggests (code now-deleted answer): $output[0] = substr($string, 0, 5); $output[1] = substr($string, 5);

java - Applying key bindings to state transitions when implementing a state pattern -

here's programming style question best strategy map input keys actions in class implement state pattern. i'm dealing 2 classes: the first implements state pattern, controls multi-state physical device: class devicecontroller { state _a, _b, _current; // actions may prompt transition 1 state public void actiona() { ... } public void actionb() { ... } public void actionc() { ... } public state getstatea() { ... } public state getstateb() { ... } public void setcurrentstate() { ... } }; the second keylistener retrieves keyboard input , calls appropriate action device controller when pressed input key matches (for time being) hard-coded bindings table: class keydemo implements keylistener { devicecontroller _controller; ... @override public void keypressed(keyevent arg0) { char key = character.touppercase(arg0.getkeychar()); switch (key) { case 'a': _controller.actiona(); ...

android - update UI from and event -

i have service sends continously values activity through custom event listeners. here works fine. values displayed in activity expected, others make application crash. because of incoming data calculated inside normal thread (that cannot have access changing it), , know have use handler here, far tried app still crashing. more graphically following onvalueschanged(float val) { mytextview.settext( float.tostring(val) ) } where val calculated in normal thread, of course makes crash app when doing settext. any suggestions? use asynctask instead of thread , in onpostexecute() can update ui. or use activity.runonuithread(new runnable() { void run() { // interesting. } });

c# - Cannot find certain words in context, missing reference, brain about to explode? -

i'm trying learn c#/silverlight/windows phone 7. what's going on here: when try use examples straight off of ms's msdn site, , kinds of errors: for example: using system; using system.io; using system.collections.generic; using system.device.location; using system.linq; using system.net; using system.windows; using system.windows.controls; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.animation; using system.windows.shapes; using microsoft.phone.controls; using microsoft.phone.tasks; using system.device.location; using microsoft.phone.reactive; private void registerphone(object sender, routedeventargs e) { // create request using url can receive post. webrequest request = webrequest.create("http://www.contoso.com/postaccepter.aspx "); // set method property of request post. request.method = "post"; // create post data , convert by...

iphone - Mock Animation running out of memory -

i trying simulated animation based on series of 54 images. getting - "program received signal: “0”." message - running out of memory. i trying best take care of them seem failing. running through 54 in 4-5 seconds, , should repeat (almost flip book). animation not can done using core animation due shiny 3d material in image. or, there better way of going this? here code: -(void)addimage:(nsstring*)imagename{ if (self.images == nil){ self.images = [[[nsmutablearray alloc] init] autorelease]; } [self.images addobject:[uiimage imagenamed:imagename]]; } // returns uiimageview contains next image display - (uiimageview *)nextimageview { // image @ next index uiimage *image = [images objectatindex:pictureindex]; ++pictureindex; // increment index if(pictureindex > images.count -1){ pictureindex = 0; } // create image view image uiimageview *imageview = [[uiimageview alloc] initwithimage:image]; // r...

Define a fixed-size list in Java -

is possible define list fixed size that's 100? if not why isn't available in java? yes , commons library provides built-in fixedsizelist not support add , remove , clear methods (but set method allowed because not modify list 's size). in other words, if try call 1 of these methods, list still retain same size. to create fixed size list, call list<yourtype> fixed = fixedsizelist.decorate(arrays.aslist(new yourtype[100]));

android ndk - jint problem with NDK -

i'm trying make first native function ndk , i'm in trouble basic stuff. please consider following c code: #include <jni.h> #include <string.h> jniexport jint jnicall java_eu_elevelcbt_sm_ycrcbutils_toargb( jnienv* env, jbytearray src, jintarray out, jint width, jint height){ jbyte *c_src = (*env)->getbytearrayelements(env, src, null); jint *c_out = (*env)->getdirectbufferaddress(env, out); if (c_out==null) return -1; int length = width * height; int co; unsigned int color; (co=0; co<length; co++) { color = c_src[co] & 0xff; color = 0xff000000 | (color<<16) | (color<<8) | color; c_out[co] = color; } (*env)->releasebytearrayelements(env, src, c_src, 0); return 0; } jniexport jint jnicall java_eu_elevelcbt_sm_ycrcbutils_sum(jint a, jint b){ return a+b; } and following java class: public class ycrcbutils { public native int toargb(byt...

read / write from sim card for android -

i've been trying read/write sim card still there's no luck. here's code far: //read sim public string adding() { uri simuri = uri.parse("content://icc/adn/"); cursor cursorsim = this.getcontentresolver().query(simuri, null, null,null, null); string b = ""; while (cursorsim.movetonext()) { b+= (cursorsim.getstring(cursorsim.getcolumnindex("name"))); b += "\n" + (cursorsim.getstring(cursorsim.getcolumnindex("_id"))); b+= "\n" + (cursorsim.getstring(cursorsim.getcolumnindex("number"))); } return b; } //to write sim public void testing4() { contentvalues values = new contentvalues(); values.put( "tag", "test" ); values.put( "number", "1234" ); getcontentresolver().insert( uri.parse("content://icc/adn/"); , ...