Posts

Showing posts from August, 2011

c++ - Self destructing objects -

just wondering whether object can self-destruct. consider situation. an object extends thread object. session : thread { session() {} ~session() {} threadmain() { while(!done){ /* stuff ... */ ... // sets done = true; } ~client(); } }; void start_session() { session* c = new session(); session->start(); // when exit here, i've lost reference s. if object // self destructs when done, don't need right? } somewhere along way, have function called start_session starts session. session ends. in conventional approach have have sort of list of session objects placed in list after calling new. to clean objects i'd have figure out ones finished , call cleanup function later. i thought might make more sense if clean themselves. can done? why? why not? better approaches? you can "delete this" when session loop exits but see https://isocpp.org/wiki/faq/freestore-mgmt

c# - Filtering rows of a DataTable with the return type of a DataTable -

i filter rows of datatable , perform linq query on resulting set of rows. second query operates on datatable.asenumerable. datatable.select method returns array of datarows. there anyway perform linq query on these, or convert array of datarows datatable, can chain results of filter linq query? while can convert resultant array of datarow objects new datatable, best bet perform linq query against datarow array. example: var queryreturn = r in mydatarows (int)r["idcolumn"] == 1 select r;

How to remove attribute from MongoDb Object? -

i have added middlename attribute customer object. customer simple object() instance. want remove attribute object. how can that? using mongodb interactive console. you should use $unset modifier while updating: // db.collection.update( criteria, objnew, upsert, multi ) --> reference to delete: db.collection.update( { "properties.service" : { $exists : true } }, { $unset : { "properties.service" : 1 } }, false, true ); to verify have been deleted can use: db.collection.find( { "properties.service" : { $exists : true } } ).count(true); remember use multi option true if want update multiple records. in case wanted delete properties.service attribute records on collection.

Looking for a technique to reduce "controller repetition" for CRUD operation in ASP.NET MVC -

i developing administration part of site. consist of manipulating list of data such as: products suppliers tax profiles ... i find task of creating controller handle crud operations of each model little repeating , prone mistake 1 controller another. i still need adapt of these controller additional operation, not all. does know proven approach reducing implication of controller usual crud operations? one suggestion @ tweaking t4 template used generate scaffold methods. check out rob conery's mvc starter site see he's done (look in /web/codetemplates in source general idea). there other mvc libraries out there such fubumvc aim cut down on code repetition, it's not based on actual asp.net mvc framework (and it's not thing).

ColdFusion: Reset JRun server -

is there way reset jrun server within coldfusion page? yep, can restart service want. write batch file , run cfexecute. <cfexecute name="#filepath#restartjrun.bat"></cfexecute> in batch file like: net stop "macromedia jrun cfusion server" net start "macromedia jrun cfusion server" as ciaran mentioned though, it's best solve performance problems rely of temporary fixes this.

php strftime('%P') on osx gives P instead of pm with setlocale(LC_TIME, 'en_CA') -

this code ... <?php setlocale(lc_time, 'en_ca'); $time = strtotime("07:00 pm"); echo strftime('%l:%m %p', $time); ?> provides result on osx 10.6.4 stock php 5.3.2 or php 5.2.13 macports: 7:00 p however desired result on ubuntu 9.10 php 5.2.10: 7:00 pm why difference? how can fix it?

javascript - how to refresh the Label which is inside the Grid view using Java script? -

i displaying time in label inside grid view. need refresh label every second. how java script.like ajax timer. edit: onload="settimeout(window.location.reload();. 1000);" whats wrong code or <asp:label id="label2" width="100px" runat="server" onload="settimeout(window.location.reload();. 1000);" font-size="12px" forecolor="black" text='<%# bind("time") %>'></asp:label> setinterval(function(){ var = new date(); $('#yourspanid').text(now.toutcstring()); // or whatever formatting need }, 1000);

multithreading - How to wait for a thread to finish in Objective-C -

i'm trying use method class downloaded somewhere. method executes in background while program execution continues. not want allow program execution continue until method finishes. how do that? here's way using gcd: - (void)main { [self dostuffinoperations]; } - (void)dostuffingcd { dispatch_group_t d_group = dispatch_group_create(); dispatch_queue_t bg_queue = dispatch_get_global_queue(dispatch_queue_priority_default, 0); dispatch_group_async(d_group, bg_queue, ^{ [self dosomething:@"a"]; }); dispatch_group_async(d_group, bg_queue, ^{ [self dosomething:@"b"]; }); dispatch_group_async(d_group, bg_queue, ^{ [self dosomething:@"c"]; }); // can synchronously wait on current thread: dispatch_group_wait(d_group, dispatch_time_forever); dispatch_release(d_group); nslog(@"all background tasks done!!"); // **** or **** // if want happen ...

java - how can i pass information from ant to sql file or procedure -

i creating user using ant target below <target name="create_user"> <exec executable="sqlplus" dir="${basedir}/dbsetup"> <arg value="system/oracle@orcl"/> <arg value="@create_user.sql"/> </exec> </target> and sql files follows........ create user test identified password; grant resource, connect test ; grant create view test ; grant create materialized view test ; grant create sequence test ; grant create procedure test ; grant create directory test ; grant create database link test ; alter user test quota unlimited on users; quit; at present user name hard coded in create_user.sql want prompt user name , password ant , pass sql file. please advice how can achieve or other way can achieve one option use &1 positional parameter in sql file, e.g.: create user &1 identified password; prompt username ant input task , pass valu...

android - ItemizedOverlay Issues (HelloMapView Tutorial) -

i having trouble hello map views tutorial android developer website: http://developer.android.com/resources/tutorials/views/hello-mapview.html my first problem upon clicking overlay item, application crash. problem solved making sure pass context itemizedoverlay class created... after fixed problem, icon overlay not display in map. able click on map overlay located , dialog box displays. unfortunately, cannot see icon. have made sure image reference object located in r.java resources file. in fact exact problem asked poster of following thread after going through same issues. unfortunately second question never answered. context null pointer here mapview class: package com.mapsexample; import java.util.list; import android.content.context; import android.graphics.drawable.drawable; import android.os.bundle; import com.google.android.maps.geopoint; import com.google.android.maps.mapactivity; import com.google.android.maps.mapview; import com.google.android.maps.over...

python - Mutable Default Argument Returns None -

i have simple code finds paths using graph stored in dictionary. code exactly: def find_path(dct, init, depth, path=[]): if depth == 0: return path next_ = dct[init] depth-=1 find_path(dct, next_, depth) if print path right before return path prints screen correct path (after initial depth of 5 ). however, value returned none . don't know what's going on! why value of path right above return correct, yet returned path not want? shouldn't find_path(dct, next_, depth) be return find_path(dct, next_, depth) # ^^^^ # return in python (unlike in say, ruby) have explicitly return value. otherwise none returned.

wpf - What MVVM framework is Good For? -

i know mvvm frameworks introduced in this thread please describe or give me link them useful for? not information mvvm mvvm framework. :) want know : mvvm framework? i think question not precise. far understand, ask features of each framework?! you can find detailed information here , here . however, @ least 1 of these links has been given in thread mentioned... edit: basically, mvvm framework collection of classes commonly used in applications utilising mvvm (model-view-viewmodel) pattern. may include messaging systems communicate between independent parts of software, dependency injection techniques, base classes viewmodels, project/class templates, validation mechanisms, commonly used commands, techniques displaying dialog boxes, , on... to understand such framework, have understand mvvm pattern first. because (or after did first mvvm project) have understanding of problems and/or challenges of pattern.

java - How do I turn off DBUG level logging in BayeuxServer (embedded in Jetty)? -

when running cometd bayeux implementation in jetty (7.1.5), lots of dbug level logging output console. i've identified logger org.eclipse.jetty.util.log.stderrlog instance, i'm not sure how configure it. i'm using jetty embedded within application, tried things suggested @ http://docs.codehaus.org/display/jetty/debugging ("with jetty embedded" section), had no success. at moment i'm running app |& grep -v dbug , that's annoying. know how configure type of logger? finally tracked down how set debug level. cometdservlet created , added context, can set loglevel init parameter on servletholder appropriate level (anything 3 or greater includes debug). servletholder comet = context.addservlet( cometdservlet.class, "/cometd/*" ); comet.setinitparameter( "loglevel", 2 );

datetime - what this line do in c# -

i want understand line in c#, int32 dayofweekindex = (int32)datetime.now.dayofweek + 1; what return example if run today ? i not have option run code. it depends on in world , computer clock set to. it returns value of dayofweek enum corresponding time run, plus 1. sunday 0, saturday 6. so, thursday, dayofweekindex 5.

javascript - select box issue in IE when using BOXOVER.js tool tip -

i using boxover.js tool tip: http://www.koders.com/javascript/fid8780cbe6d1bee164fc239aa55dcb13a53b3536e8.aspx?s=document#l6 the tool tip works elements except select box in ie. i have code need show image tool tip on selecting option in select box. ex: <select name="categoryname" id="categoryname" style="width:50%;" size="10" > <option value="">--select category--</option> <option title="cssbody=[bdycss] cssheader=[hdrcss] header=[category] body=[<center><p><img src='icon1.png'></p>]" value="1">category1</option> <option title="cssbody=[bdycss] cssheader=[hdrcss] header=[category] body=[<center><p><img src='icon2.png'></p>]" value="2">category2</option> <option title="cssbody=[bdycss] cssheader=[hdrcss] header=[category] body=[<center><p><i...

c# - does, myval = (someconditon) ? someVal : myval get optimized to not set the value in case it's false -

cpath = (cpath == null) ? request.path : cpath; first of wish clr let me ? request.path , not bother me creating : but i'm asking optimize away? or still assign. well, write as: if (cpath == null) { cpath = request.path; } to make clearer. alternative (as mentioned elsewhere) is cpath = cpath ?? request.path; but why care if there's assignment? really think that's going significant performance hit? note if cpath field rather local variable, potentially make difference - because value of cpath change between first check , second evaluation, , again between evaluation , assignment. whether noticed depends on caching etc, it's not simple might @ first.

jquery - Permission denied for ajax request inside an iFrame -

for many various reasons web page consist of following, ruby page www.example.com calls iframe php server (subdomain.example.com), in both parent , child there javascript instruction : document.domain="example.com"; parent page can access elements in child page, needed make parent page change height it's child , works nicely. but problem in ajax request when following code : $.ajaxfileupload ( { url:'www.example.com', secureuri:false, fileelementid:'image', datatype: 'json', success: function (data, status) { //code 1 }, error: function (data, status, e) { //code 2 alert(e); } } ) for reason execute code 2 , prompts error: error: permission denied http://www.example.com (document.domain= http://example.com ) property window.document http://www.example.com (document.domain has not been set). even though request correctly r...

PHP redirect based on HTTP_HOST/SERVER_NAME within same domain -

i trying redirect specific path based on http_host or server_name php-script. i have tried these scripts: 1. $domain = $_server["server_name"]; if (($domain == "example.dk") || ($domain == "www.example.dk")) { header("location: /index.php/da/forside"); } ?> 2. switch ($host) { case 'example.dk': header("http/1.1 301 moved permanently"); header("location: http://www.example.dk/index.php/da/forside/"); exit(); case 'www.example.dk': header("http/1.1 301 moved permanently"); header("location: http://www.example.dk/index.php/da/forside/"); exit(); default: header("location: http://www.example.se"); exit(); } ?> and other similar scripts. either page loads forever or browser ret...

Checkable UIPickerView in iPhone Safari -

Image
i try custom pickerview checkable when click dropdownlist on webview in picture (youtube website). http://img830.imageshack.us/img830/3747/screenshot20101004at606.png i use viewforrow method customize view each row in picker. - (uiview *)pickerview:(uipickerview *)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component reusingview:(uiview *)view { uiview *rowview = [[[uiview alloc] initwithframe:cgrectmake(0, 0, 280, 44)] autorelease]; rowview.backgroundcolor = [uicolor clearcolor]; rowview.userinteractionenabled = no; uiimageview *checkmarkimageview = [[uiimageview alloc] initwithframe:cgrectmake(5, 10, 24, 19)]; uifont *font = [ uifont boldsystemfontofsize:18]; uilabel *titlelabel = [[uilabel alloc] initwithframe:cgrectmake(35, 0, 240, 44) ]; nsstring *pickertext = [[itemlist objectatindex:row] objectforkey:@"name"]; titlelabel.text = pickertext; titlelabel.textalignment = uitextalignmentleft; titlelabel.backgroundcolor = [uicolor clea...

Does django grok YML ? django not loading fixtures YML file (yml is not a known serialization) -

i have created first django project. i have 2 apps in project foo , foobar. i have created folder named 'fixtures' in each of app folders. have not specified fixtures directory in settings.yml, ( according docs ), django should looking in {app}/fixtures folder. in {app}/fixtures folder, have several yml files. have split initial data various modules separate yml files, making sure there no cross file dependencies (i.e. related models in same yml file , ancestors occur in file before models use them). however, when run./manage.py syncdb after db objects created, there following message: no fixtures found i tried manually load fixtures using loaddata command: ./manage.py loaddata 0100_foobar.yml problem installing fixture '0100_foobar': yml not known serialization is documentation given in link above wrong?, or need install module in order django grok yml? btw, yml files parse correctly , have been checked correctness (i used them in project) - not ...

c++ - Class instance variables inside of class cause compiler errors -

the compiler giving me following complaints following class: class aguiwidgetbase { //variables aguicolor tintcolor; aguicolor fontcolor; //private methods void zeromemory(); virtual void onpaint(); virtual void ontintcolorchanged(aguicolor color); void (*onpaintcallback)(aguirectangle clientrect); void (*ontintcolorchangedcallback)(); public: aguiwidgetbase(void); ~aguiwidgetbase(void); void paint(); void settintcolor(aguicolor color); aguicolor getbackcolor(); }; warning 13 warning c4183: 'getbackcolor': missing return type; assumed member function returning 'int' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h 26 error 2 error c4430: missing type specifier - int assumed. note: c++ not support default-int c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h 11 error 3 error c4430: missing type specifier - int assumed. ...

How to Cast to Generic Parameter in C#? -

i'm trying write generic method fetching xelement value in strongly-typed fashion. here's have: public static class xelementextensions { public static xelement getelement(this xelement xelement, string elementname) { // calls xelement.element(elementname) , returns xelement (with validation). } public static telementtype getelementvalue<telementtype>(this xelement xelement, string elementname) { xelement element = getelement(xelement, elementname); try { return (telementtype)((object) element.value); // first attempt. } catch (invalidcastexception originalexception) { string exceptionmessage = string.format("cannot cast element value '{0}' type '{1}'.", element.value, typeof(telementtype).name); throw new invalidcastexception(exceptionmessage, originalexception); } } } as can see on first attempt l...

flash - ActionScript - Installing Documentation For Your Own Classes? -

is possible write/install own documentation self-created classes along adobe's documentation in adobe help? the best method of writing own documentation self-created classes asdocs , if going go down route, check out grant skinner's asdocr air app simplify process of managed , writing asdocs

unity container - UnityContainer usage and best practices -

is wrong use unitycontainer in app access references objects different parts of application (but same assembly)? the application (wpf) has several regions need access each other , have used unitycontainer that. example, "main" region (which drawing area) has presenter behind it, manages it's business logic, , have registered instance of presenter in container, , in other parts of application need access control region, access via unitycontainer. not sure if that's practice or bad one. no, in fact, that's kind of purpose it. there library out there called servicelocator works allows switch out ioc containers, provides way lookup container, etc. find overkill in i've never had swap out containers... using static "factory" container enough. usually, top level class has call , responsible assembling dependencies.

3d - Issue with Android OpenGLES lighting -

hey all, i'm writing little 3d engine android better learn platform , opengl. hope use base little 3d games. i'm trying implement lighting right now, , following nehe opengl android port tutorials. have simple spinning cube , 1 light should not change position. upon rendering scene on device light appears "dim" , re-lighten cube rotates. this swf video of behavior: http://drop.io/obzfq4g the code "engine" located here: http://github.com/mlasky/smashout-android-3d-engine/ the relevant bits are: http://github.com/mlasky/smashout-android-3d-engine/blob/master/src/com/supernovamobile/smashout/smashoutglrenderer.java i'm initializing opengl , setting scene. and http://github.com/mlasky/smashout-android-3d-engine/blob/master/src/com/supernovamobile/smashout/smmesh.java code rotating / drawing cube mesh. i wish formulate better question; i'm stuck/confused , can't think of intelligent question ask besides "does know mi...

Weblogic remote debugging using eclipse -

my weblogic installed in red hat os machine. in startweblogic.sh have added line java_options="-xdebug -xnoagent -xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n %java_options%" when try connect eclipse "failed connect remote vm. connection refused. connection refused: connect" message. can please tell me may going wrong? in startweblogic.sh file in bin folder, in rhel add line -xdebug -xnoagent -xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n at place find string: ${java_home}/bin/java . place above line after ${java_home}/bin/java

jtree - comparing two TreeNode (or DefaultMutableTreeNode) objects in Java Comparator -

my goal simple today, trying work out proper way implement compareto (or comparable) interface class extends defaultmutabletreenode. the problem this : have class represents times. i've written compareto method (which works desire) i've tested out arrays.sort() marvelous results. now lets have jtree bunches of different objects, this: new specialnode("zomg string!"); // add group of nodes right here new specialnode(new time("8:55 pm")); new specialnode(new sometypeyouveneverheardof()); so, being professional programmer, start coding without forethought whatsoever. here specialnode class: class specialnode extends defaultmutabletreenode implements comparator<specialnode> { public int compareto(specialnode sn) { // not not work correctly (read: @ all) // but, sub-par, how type information out of userobject // can cast correctly , call correct compareto method!! return this.getuserobject()....

DragAndDrop selectedItems of one silverlight Datagrid into another -

currently using "datagriddragdroptarget" drag row 1 datagrid another, client want able select multiple rows 1 datagrid , drop them another. i played around bit realized "datagriddragdroptarget" seems able drag , drop single row @ time only. is there alternative way dragdrop multiple selected rows? pressing shift key while dragging multiple rows datagrid works this. can suggest how can remove shift key press while moving multiple rows or how drag while holding ctrl?

iphone - CoreData could not fulfill a fault after MOC refreshed - how to solve? -

i'm new iphone development , have problem core data. at moment app works follows: i'm executing fetch core data , display list of objects in tableview detaching new thread, create new moc it, advised, getting xml, parse it, clear core data , fill new data xml saving moc. it works fine if user isn't scrolling tableview within saving of moc, if is, i'm getting error , application crashes. can explain in plain english why it's happening , how can solve problem. thanks lot. ok, solution easy, need normal objects, not faults coredata, using property of request object like this: //... [request setreturnsobjectsasfaults:no]; //... there no difference in memory allocation (at least didn't notice in tools), problem disappears)

wpf - Is there a rich text editor control that does both spell AND grammar checking? -

i'm looking winforms or wpf control can both spelling , grammar checking in english , red & green squiggly underlines, similar ms word. so far, i've been able find spell-checker controls. i'd open spell checking , grammar checking libraries - if can recommend integration point editor allows underlining. for historical context, went ckeditor , afterthedeadline. use ckeditor on our current project, haven't seen progress atd in recent years. http://ckeditor.com/ https://github.com/ckeditor http://www.afterthedeadline.com/ https://github.com/automattic/atd-ckeditor

sql server - I cant reach my new SQL instance -

i using older version of sql on server, , worked fine when typing servername,, directly connect server, i installed new instance of sql, , iam trying connect new instance dowsne't work. servername/new_instance can me out? how can reach new sql server? you may need allow both sql server & windows authentication do by in sql server management studio right click on instance name select 'security' select 'sql server , windows authentication mode'

c# - Dynamically change the Flajaxian upload folder name -

i trying dynamically change upload folder name, it's not working form me. please help. i using flajaxian s3 amazon uploader. code follows <fjx:fileuploader id="fileuploader1" runat="server"> <adapters> <fjx:directamazonuploader onfilenamedetermining="fileuploader1_filenamedetermining" accesskey="webconfig:amazonaccesskey" secretkey="webconfig:amazonsecretkey" bucketname="media.sitename.com" /> </adapters> </fjx:fileuploader> server side code follows protected void page_load(object sender, eventargs e) { ((com.flajaxian.directamazonuploader)fileuploader1.adapters[0]).path = request.params["sid"].tostring(); } protected void fileuploader1_filenamedetermining(object sender, com.flajaxian.filenamedeterminingeventargs e) { random r = new random(); e.filename = r.next(10000) + ".jpg"; } ...

actionscript - flex MS Project library -

is there actionscript library works mpp(ms office project)? library parses ms project xml? also please advice me links may me i don't know of such library per-se, happened implement along these lines week. wrote simple script parse exported msproj csv files xml , sent xml flex application. maybe can similar on server side. i doubt find native as3 class parses proprietary binary format of project, intermediate format might necessary here.

What algorithm does gcc use to convert calls through function pointers to direct calls? -

i've heard recent versions of gcc @ converting calls through function pointers direct calls. however, can't find on web or quick through gcc's source code. know if true , if so, algorithm use this? you might find article interesting. it's dated 2005, , i'm not sure if that's 'recent' enough, deals subject comprehensively: http://www.codeproject.com/kb/cpp/fastdelegate.aspx

c# - Bang vs Default Property in Visual Basic -

for given class, default property of list, can access instance object in list doing myclass.defproperty("key"). can achieve same results typing myclass.defproperty!key. i have been told using parenthesis , quotes faster way runtime accesses property, i'd understand difference , how each work... i understand c# has similar behavior replacing parenthesis square brackets. given following code in visual basic.net: dim x new dictionary(of string, string) x.item("foo") = "bar" you can access "foo" member of dictionary using of following: dim = x!foo dim b = x("foo") dim c = x.item("foo") if @ il under reflector.net you'll find translate to: dim string = x.item("foo") dim b string = x.item("foo") dim c string = x.item("foo") so, equivalent in il and, of course, execute @ same speed. the bang operator lets use statically defined keys conform standard variable naming ...

html - How do you make a .mov "click to watch" so that it is not downloaded immediately? -

on website, have embedded video (.mov) opens , begins play when user opens page. make site easier use making image of first frame users can click on begin video. what's best way in html/javascript? <embed src="http://www.tizag.com/files/html/htmlexample.mpeg" autostart="false" /> check autostart false

c# - Can I check if an email address exists using .net? -

ive seen php examples of how can ping inbox(without sending mail it) check whether exists. wondering if knows if possible .net? if im going write app bulk check on list of emails have captured through site. smtp defines vrfy command this , since abuse spammers totally overwhelmed number of legitimate uses, virtually every e-mail server in world configured lie .

Is there a command that can be run from a cygwin shell to print out an xml file with color highlighting? -

is there command can run cygwin shell print out xml file color highlighting? use gvim! if on first editing file appears in plain black , white, select 'xml' syntax menu. play 'edit'->'color scheme' menu until find style taht suits you. then use 'syntax' -> 'convert html' , save results.

opengl - How to copy CUDA generated PBO to Texture with Mipmapping -

i'm trying copy pbo texture automipmapping enabled, seems top level texture generated (in other words, no mipmapping occuring). i'm building pbo using //generate buffer id called pbo (pixel buffer object) glgenbuffers(1, pbo); //make current unpack buffer glbindbuffer(gl_pixel_unpack_buffer, *pbo); //allocate data buffer. 4-channel 8-bit image glbufferdata(gl_pixel_unpack_buffer, size_tex_data, null, gl_dynamic_copy); cudaglregisterbufferobject(*pbo); and i'm buildilng texture using // enable texturing glenable(gl_texture_2d); // generate texture identifier glgentextures(1,textureid); // make current texture (remember gl state-based) glbindtexture( gl_texture_2d, *textureid); // allocate texture memory. last parameter null since // want allocate memory, not initialize glteximage2d(gl_texture_2d, 0, gl_rgba_float32_ati, size_x, size_y, 0, gl_rgba, gl_float, null); // must set filter mode, gl_linear enables interpolation when scaling gltexparameteri(gl_texture...

linux - 301 redirect urls -

i'm trying redirect old url new 1 using 301 i need example of rewritequerystring following 301? http://www .example.com/search/?depid=1&typecatid=1 following http://www.example.com/mens/clothing so when type in long url in browser, redirected new, shorter url any ideas? rewriteengine on rewriterule ^search/\?depid=1&typecatid=1$ /mens/clothing [r=301] ^ try that.

c - Can popen() make bidirectional pipes like pipe() + fork()? -

i'm implementing piping on simulated file system in c++ (with c). needs run commands in host shell perform piping on simulated file system. i achieve pipe() , fork() , , system() system calls, i'd prefer use popen() (which handles creating pipe, forking process, , passing command shell). may not possible because (i think) need able write parent process of pipe, read on child process end, write output child, , read output parent. man page popen() on system says bidirectional pipe possible, code needs run on system older version supporting unidirectional pipes. with separate calls above, can open/close pipes achieve this. possible popen() ? for trivial example, run ls -l | grep .txt | grep cmds need to: open pipe , process run ls -l on host; read output back pipe output of ls -l simulator open pipe , process run grep .txt on host on piped output of ls -l pipe output of simulator (stuck here) open pipe , process run grep cmds on host on piped output ...

objective c - Preference Pane loses focus when loading -

i made preference pane , every time loads system preferences loses focus. if remove controls pref pane window issue not occur there's sort of image or control in window occurs. what missing? nevermind. pref pane launching app that's why it's losing focus...

sql - How do I return the sum for this query? -

i have following tables need find out sum. table a id name 1 jason 2 peter 3 ravi table b id id_sec 1 11 1 12 1 13 2 21 2 22 2 23 3 31 3 32 3 33 table c id_sec value include_ind 11 100 y 12 200 y 13 300 n 21 10 y 22 20 n 23 30 n 31 1000 n 32 2000 n 33 3000 n output id name total include_ind_count [only count when y] 1 jason 600 2 2 peter 60 1 3 ravi 6000 0 use: select a.id, a.name, sum(c.value) total table_a join table_b b on b.id = a.id join table_c c on c.id_sec = b.id_sec group a.id, a.name

php - Kohana 3: Routing with subdirectories error, controller does not exist -

so i'm trying build route sub directories , following kerkness wiki guide keep getting errors. if point out i'm doing wrong appreciate it. http://kerkness.ca/wiki/doku.php?id=routing:building_routes_with_subdirectories the code: route::set('default', '(<directory>(/<controller>(/<action>(/<id>))))', array('directory' => '.+?')) ->defaults(array( 'directory' => 'admin', 'controller' => 'main', 'action' => 'index', )); the url: /admin/weather/feedback the file: /application/classes/controller/admin/weather/feedback.php class controller_admin_weather extends controller_admin_base { the error: reflectionexception [ -1 ]: class controller_admin_weather not exist weather needs controller not feedback. make weather.php in admin folder , put controller controller_admin_weather , action action_feedback...

iphone - Custom uitableview cell issue -

i have custom uitableviewcell such: @implementation cellwiththreesubtitles @synthesize title, subtitle1, subtitle2, subtitle3; - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier { if (self = [super initwithstyle:style reuseidentifier:reuseidentifier]) { self.textlabel.backgroundcolor = self.backgroundcolor; self.textlabel.opaque = no; self.textlabel.textcolor = [uicolor blackcolor]; self.textlabel.highlightedtextcolor = [uicolor whitecolor]; self.textlabel.font = [uifont boldsystemfontofsize:22.0]; } return self; } - (void)layoutsubviews { [super layoutsubviews]; cgrect contentrect = self.contentview.bounds; cgrect frame = cgrectmake(35.0, 0, contentrect.size.width, 50.0); self.textlabel.frame = frame; uilabel *sublabel1 = [[uilabel alloc] init]; frame = cgrectmake(35.0, 34.0, contentrect.size.width, 25.0); sublabel1.font = [uifont systemfontofsize:18.0];...

iphone - :active pseudo-class doesn't work in mobile safari -

in webkit on iphone/ipad/ipod, specifying styling :active pseudo-class <a> tag doesn't trigger when tap on element. how can trigger? example code: <style> a:active { background-color: red; } </style> <!-- snip --> <a href="#">click me</a> <body ontouchstart=""> ... </body> applied once, opposed every button element seemed fix buttons on page. alternatively use small js library called ' fastclick '. speed click events on touch devices , takes care of issue too.

fonts - objective c finding pixel width of a string -

Image
i have uibutton of fixed width , want place text in it. since size of string unknown in advance, have resize font read string flat file. how can that? function similar following great: uifont resizefontas:(uifont)initialfont andstringas:(nsstring*)string andwidthas:(int)width thanks in advance edit : code doesnt seem work: // method creating button, background image , other properties - (uibutton *) getcallagentbuttonwithtitleas:(nsstring *)atitle andimageas:(uiimage*)bgimg atindex:(int)index{ uibutton *abutton = [uibutton buttonwithtype:uibuttontyperoundedrect]; abutton.frame = cgrectmake(10, 2+index*50, 300, 48); abutton.titlelabel.frame = cgrectmake(abutton.titlelabel.frame.origin.x + 25.0, abutton.titlelabel.frame.origin.y, abutton.titlelabel.frame.size.width - 50.0, abutton.titlelabel.frame.size.height); abutton.titlelabel.adjustsfontsizetofitwidth = yes; [abutton settitle:atitle forstate:uicontrolstatenormal];...

wpf - How to render a checked CheckBox (Aero theme) to a RenderTargetBitmap? -

my checkbox rendered without check mark. if use 1 checkbox (instance object) render can check mark show, cannot use solution. need able render using local checkbox. checkbox has aero theme applied via "/presentationframework.aero;component/themes/aero.normalcolor.xaml" , must have me. other themes built-in themes royal, , luna render check mark. xaml <canvas name="canvas"> <button click="button_click" canvas.left="440" canvas.top="277"> paint </button> <image name="image"/> </canvas> c# private void button_click(object sender, routedeventargs e) { var checkbox = new checkbox { width = 100, height = 30, ischecked = true, }; var rectangle = new rect(0, 0, checkbox.width, checkbox.height); //need var visualbrush = new visualbrush(checkbox); checkbox.arrange(rectangle); var rendertargetbitmap = new rendertargetbitmap((int)rectangle.width, (int)rectangle.heig...

registry - PowerShell: How To Use Standard Output In Place of Filename -

i'm writing c# class runs process (reg) export registry keys. reg requires specify filename export rather have output of reg directed standard output can capture directly in c# code (using process.standardoutput). there way in powershell specify standard output filename? if have use reg program (rather use powershell query/dump registry - or in c# program itself), best going allow dump out temporary file, pipe contents of file standard out , capture in c# program way: $guid = [guid]::newguid().tostring("n") reg export hkcu\software\microsoft\windows "$env:temp\$guid" | out-null get-content "$env:temp\$guid" remove-item "$env:temp\$guid" in case not aware: using powershell, can navigate registry though part of file system. perhaps helpful in other regard? cd hkcu:\software\microsoft\windows dir

c++ - template class + operators + friends = unresolved externals -

i have class called fraction, , i'm declaring operators friends. declared friend operators beforehand, http://www.parashift.com/c++-faq-lite/templates.html#faq-35.16 told me do, fixed +, -, *, , /. << , >> still don't work. template <class t> class fraction; template <class t> fraction<t> operator+ (fraction<t> const& left, fraction<t> const& right); template <class t> fraction<t> operator- (fraction<t> const& left, fraction<t> const& right); template <class t> fraction<t> operator* (fraction<t> const& left, fraction<t> const& right); template <class t> fraction<t> operator/ (fraction<t> const& left, fraction<t> const& right); template <class t> ostream& operator<< (const ostream& output, fraction<t> const& value); template <class t> istream& operator>> (const ostream& input, fr...

licensing - Do I need to offer an iPhone app under GPL if the webserver software is licensed under the terms of the GPL? -

i'm write iphone / android app have nice gui on mobile devices open source project web software html frontend. server licensed under terms of gpl 2. there json api implement in server code. release api on server side under gpl 2 too. but whats mobile app? think new product. uses api of open source project. standalone app isn't it? can choose properitary license app , let users pay it, right? thanks! short answer: no. longer answer: simple use of application not make product of application gpl.gpl says: the output running covered work covered license if output, given content, constitutes covered work. what means website (output running covered work) running on gpl server gpl if website gpl other reasons. so website/web service , json api need not gpl. but.. since website uses gpl covered json api must released under gpl. unless.. can contact author of json api (yourself) give permission use library under non gpl license (in case, json api d...

algorithm - How to represent / Modify 3d solids -

in program have cubes (simple, xyz location, xyz size). want bo able take 1 of these cubes , 'subtract' cube it. so question, generic data structure represent resulting 3d object, , kind of algorithm used subtract 3d solid another? this pretty general question , depends on want know solid , how fast want know it. assuming want membership tests, might work (psuedocode): class solid { solid solids = [] // each solid has list of solids // have been subtracted it. abstract method containedinself(point) { // vary 1 type of solid } method contains(point) { if !containedinself(point) return false; else { solid in solids { // loop on contained solids if solid.contains(point) return false; // point contained in solid has been subtracted } // know point contained not contained in // that's been subt...

iphone - Using a custom UITableView without linking in IB -

i have custom uitableview class creating shadow effects on of uitableviews. possible incorporate class uitableviewcontroller(s) without creating nib file each table view controller? there way link custom uitableview other in ib? using uitableviewcontroller, set delegate , datasource on custom uitableview controller , set custom tableview instance uitableviewcontroller's tableview property. [instanceofmycustomuitableview setdelegate:self]; [instanceofmycustomuitableview setdatasource:self]; [self settableview:instanceofmycustomuitableview]; self being instance of uitableviewcontroller

java - Wicket: Get URL from browser -

i need retrieve url current web page opened in firefox using wicket. can tell me how that? you need query underlying httpservletrequest : public class dummypage extends webpage{ private string getrequesturl(){ // wicket-specific request interface final request request = getrequest(); if(request instanceof webrequest){ final webrequest wr = (webrequest) request; // real thing final httpservletrequest hsr = wr.gethttpservletrequest(); string requrl = hsr.getrequesturl().tostring(); final string querystring = hsr.getquerystring(); if(querystring != null){ requrl += "?" + querystring; } return requrl; } return null; } } reference: (wicket) component.getrequest() (wicket) request (wicket) webrequest (servlet api) httpservletrequest

bash - Trouble nesting expressions in UNIX -

i have following unix statement: #!/bin/bash $x=$((grep ^'[a-z]' $1 | wc -l)) echo "$x" however, i'm getting error message relating missing operand whenever try run script. there way assign variable value in unix? edit: well, became clear me grep cannot seem examine single words, intended do. there unix command can point me deals searching pattern in word? i'm trying make unix code can tell if word passed script starts number. unix call helpful? i believe remaining problem $( ... ) , $(( ... )) 2 different things. former command substitution, want. latter arithmetic . try this: #! /bin/sh x=$(grep -c '^[a-z]' "$1") echo "$x" i don't know why had caret outside single quotes; cause problems shells (where caret either history expansion or alias |), think bash not 1 of shells there's no reason tempt fate. obligatory tangential advice: when expanding shell variables, put them inside double quotes...

c# - entity framework - how can I implement this SQL in the abbreviated EF linq -

can out c# code implement sql entity framework linq in abbreviated form? (e.g. have "." notation such xxx.where(... etc) select pn.name, sum(u.amount) usages u, processnames pn pn.id == u.processnameid , u.datetime between '2010-01-08' , '2010-10-11' group pn.name method-based query: implement in lambda need leverage queryable.groupjoin : var query = context.processnames .groupjoin(context.usages .where(u => u.datetime >= new datetime(2010, 1, 8) ) && u.datetime <= new datetime(2010, 10, 11), pn => pn.id, u => u.processnameid, (pn, usages) => new { name = pn.name, sum = usages.sum(u => u.amount) }); query expression: , same query in query expression syntax: var query = pn in context.processnames join u in context.usages .where(u...

What are some options that exist for osx like MacRuby, but using javascript? -

just wondering of options out there people know of. curious other people use. k. came across another: jscocoa http://inexdo.com/jscocoa and tidesdk: http://tidesdk.org

How to create self cumulating vector in R -

i think easy r kung-fu weak. i'm trying create vector of in cumulative way. code works i'd more elegant , automated. have millions of rows need cumulated. a <- c(4,4,5,1,9) <- a[order(-a[])] k <- a[1:length(a)]/sum(a) w <- c(k[1],k[1]+k[2],k[1]+k[2]+k[3],k[1]+k[2]+k[3]+k[4],k[1]+k[2]+k[3]+k[4]+k[5]) w did mean cumsum() ? > <- c(4,4,5,1,9) > <- a[order(-a[])] # calling sort shorter > k <- a[1:length(a)]/sum(a) # long way > k [1] 0.391304 0.217391 0.173913 0.173913 0.043478 > k <- a/sum(a) # same, shorter > k [1] 0.391304 0.217391 0.173913 0.173913 0.043478 > ck <- cumsum(k) > ck [1] 0.39130 0.60870 0.78261 0.95652 1.00000 > edit overlooked simplification: > <- c(4,4,5,1,9) > ck <- cumsum( sort(a, decr=true) / sum(as) ) > ck [1] 0.39130 0.60870 0.78261 0.95652 1.00000 > you want sort() here rather order() coupled indexing.

The order of TCP message? -

i'm developing c++ application server , client use tcp. have 3 messages on server: a, b , c. sent sequentially: -> b -> c. , clients responses acknowledge messages:ra, rb, rc. do client receive a, b , c in order a->b-c? server receive ra->rb->rc? tcp guarantees order packets received (on single connection) same order sent. no such guarantee if you've got multiple tcp connections, though - tcp preserves ordering packets within given tcp connection. see the wikipedia article on tcp more overview. one of functions of tcp prevent out-of-order delivery of data, either reassembling packets order or forcing retries of out-of-order packets.

video - How to extract Y,U, and V components from a given yuv file using Matlab? Each component is used for further pixels level manipulation -

hey guys. i'm playing yuv file. have suggestion on how extract y,u,v components yuv video? found piece of program shown below. don't know part valid components want. thanks. % function mov = loadfileyuv(filename, width, height, idxframe) function [mov,imgrgb] = loadfileyuv(filename, width, height, idxframe) % load rgb movie [0, 255] yuv 4:2:0 file fileid = fopen(filename, 'r'); subsamplemat = [1, 1; 1, 1]; nrframe = length(idxframe); f = 1 : 1 : nrframe % search fileid position sizeframe = 1.5 * width * height; fseek(fileid, (idxframe(f) - 1) * sizeframe, 'bof'); % read y component buf = fread(fileid, width * height, 'uchar'); imgyuv(:, :, 1) = reshape(buf, width, height).'; % reshape reshape(x,m,n) returns m-by-n matrix %whose elements taken columnwise x. %an error results if x not have m*n elements ...

authentication - How does someone monitor web API access rate limit? -

i wondering how people manage access json or other type of apis. there tool manage rate limit such ip address allows access api 60 times per second. yes, take @ http://www.webservius.com - it's free low-call-volume apis

XStream with xml and java object -

i have 2 java classes.... public class item { private int itemindex; private string containertype; private map<string, list<string>> contenttype; private string status; private list<string> remark; // getters , setters } please tell me how convert item object xml , xml item object? have used xstream jar conversion. need store multiple item (list of items) in xml. please provide full coding in java add new item existing items (stored in xml). sample code objectoutputstream out = xstream.createobjectoutputstream(somewriter); out.writeobject(new person("joe", "walnes")); out.writeobject(new person("someone", "else")); out.writeobject("hello"); out.writeint(12345); out.close();

c# - Can't bind to parameter -

i've got default routing: routes.maproute( "shortie", // route name "{controller}/{id}", // url parameters new { controller = "ettan", action = "index", id = "id" } // parameter defaults ); routes.maproute( "default", // route name "{controller}/{action}/{id}", // url parameters new { controller = "ettan", action = "index", id = urlparameter.optional } // parameter defaults ); i've got controller: newscontroller. has 1 method, this: public actionresult index(int id) { ... } if browse /news/index/123, works. /news/123 works. however, /news/index?id=123 not (it can't find method named "index" id allowed null). seem lacking understanding on how routing , modelbinder works together. the reason asking want have dropdown different news sources, parameter "id". ...