Posts

Showing posts from June, 2012

java - How do you write an extra class for often used code and call it from everywhere? -

in little app users can have @ 'more information' or send me feedback when click on the menu button (of device) @ every xml file of app. this code (when click on menu button): @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu, menu); return super.oncreateoptionsmenu(menu); } @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.impressum: startactivity(new intent (this, moreinformation.class)); break; case r.id.feedback: /* * */ break; } return super.onoptionsitemselected(item); } now put code java classes. works i'd create class (let's call ismenubuttonpressed.class ) contains code above , i'd remove code above other java classes , call ismenubuttonpressed.class (in these java classes when menu button pressed). how can that? how pass informati

c++ - Disadvantages of passing around functions? -

i'm learning c++ (coming java) , discovered can pass functions around. cool , think immensely useful. thinking on how use , 1 of idea's popped head customizable class. the best example of train of though customizable classes (code) person class. person have functions pertaining p. later person may pick sword (s), person has access functions pertaining both p , s. are there limits or performance issues this? sloppy , plain frowned upon? any insight educational, thanks. ~aedon there slight performance hit since pointer or reference must dereferenced before calling function. this advantageous feature. many design patterns , polymorphism depend on pointers functions. check out "visitor design pattern". another usage table of functions. example, write generic menu engine displays different menus using different functions. also research "factory design pattern."

java - JTabbedPane: How to restrict user from moving out of current tab -

how can restrict user going away current tab. need show confirmation message save/discard changes before leaving current tab. how can implement functionality in jtabbedpane? you override setselectedindex in jtabbedpane object, called before change takes place. if this, remember call super.setselectedindex after displayed confirmation. alternatively, eng.fouad states, add changelistener , display confirmation message there, happens after tab has been changed, confirmation message display after new tab has been displayed on screen: http://www.java2s.com/tutorial/java/0240__swing/listeningforselectedtabchanges.htm the second option easier implement if can live fact new tab displayed when confirmation pops up.

flex - CollapsibleAccordion label not visible problem when migrated from Flex3 to Flex4 -

the collapsibleaccordion. have 2 canvas inside collapsibleaccordion, , works fine, problem unable see labels when migrated code flex4 flex3. the code problem below: <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:cal="cal.*" layout="absolute" addedtostage="stage_init()" applicationcomplete="init()" xmlns:geometry="com.degrafa.geometry.*" xmlns:degrafa="com.degrafa.*" xmlns:paint="com.degrafa.paint.*" xmlns:containers="flexlib.containers.*" xmlns:flexlib_controls="flexlib.controls.*" xmlns:mdi_containers="flexlib.mdi.containers.*" xmlns:auto="com.hillelcoren.components.*" xmlns:local="*" backgroundcolor="#f7fafe" backgroundgradientcolors="[#f7fafe, #6caaeb]" xmln

c++ - WIndows service run desktop program in Remote Desktop -

i need launch program in remote desktop, program open window , need user interact, application windows service. i'm using windows 2008. i'm created application success launch program session connect mouse, keyboard, need launch in rdp. now i'm using these functions. wtsenumeratesessions (enum sessions, here know if rdp) wtsqueryusertoken (get user token) duplicatetokenex ( make primary token) createprocessasuser (run application si.lpdesktop = _t("winsta0\\default")) but work success run application in console connect keyboard, mouse, monitor, not rdp. anyway can me ? thanks. so you're trying launch gui application in particular rdp session on machine? have right idea, more or less, though may missing few pieces. take @ processhelper class in source automated tests of cassia library . can remove lot of managed cruft use in c++. can omit gettokeninformation( ...tokeninformationclass.tokenlinkedtoken... ) nonsense if don't need run pr

c++ - How to re-route std::clog in another CRT lib? -

i have win32 program that's built vs2008, code linked msvcr90.dll , msvcp90.dll. however, it's running code in dll (which can't modify) that's been built vs2005 , when code in dll prints clog stream via msvcr80.dll , msvcp80.dll. here's problem: if re-route std::clog in code, affect code built against crt 9.0 libs, code using older crt 8.0 wont have output re-routed. there way re-route clog stream in dll built against older crt? i've investigated calling getmodulehandle() , getprocaddress() on older crt dlls , have managed re-route c stderr stream (via _open_osfhandle , _dup2), c++ clog stream still seems unaffected. think need call ios_base::sync_with_stdio() in older crt lib couldn't valid address function. appreciated. thanks. build helper dll using vs2005 - dll should export functions setup need vs8 runtime.

android - Keeping a reference to gl in GLSurfaceView::onSurfaceCreated? -

is safe keep reference gl10 gl parameter when glsurfaceview::onsurfacecreated called? i'd initialize textures @ point later onsurfacecreated don't know now, wondered if keeping reference ok. i think bad idea. can bind textures in glsurfaceview.renderer::ondrawframe.

c# - How to do aligned scrolling through two chart areas without using AlignToChartArea? -

i have 2 chartarea objects in chart ( system.windows.forms.datavisualization.charting i'm using). one point graph, , other rangebar graph. horizontal axis on rangebar graph y axis, cannot use this: chart1.chartareas["chart area 2"].alignwithchartarea = "default"; i've figured out how zoom both charts , keep them aligned, when try scroll both charts clicking on scrollbar on 1 of horizontal axes, can't quite line up. almost line up, they're off maybe second or (the horizontal axis in both graphs time). here's have: private void thechart_axisviewchanged(object sender, vieweventargs e) { if (e.chartarea == thechart.chartareas["mypointchartarea"]) { thechart.chartareas["myrangebarchartarea"].axisy.scaleview.position = e.newposition; thechart.chartareas["myrangebarchartarea"].axisy.scaleview.size = e.newsize; thechart.chartareas["myrangebarchartarea"].axisy.sca

actionscript 3 - How to Save a Shape (or Sprite) to a Folder After Creation? -

i trying create county map of illinois using x,y coordinates shp file. have x,y coordinates , county names saved in csv file have no problem reading in via actionscript 3 (and map looks great), in order save time in future application save each county shape permanent shape in application , give them labels, i.e. sprite1 (label='champaign'). possible? if so, appreciated. in case not possible trying alternate solution: create new sprite (var spr:sprite = new sprite();) each county, draw using spr.graphics.drawpath, , give name (spr.name='champaign') , 'push' vector of sprites (var xy_sprites:vector. = new vector.();). great, doesn't work when try loop through each sprite in vector , add eventlistener sprite pop name when mouseover of counties. sprite data type not correct way go or missing sprites? some of code draw shapes , save in vector: function drawxymap(str:string):vector.<sprite> { var arr:array = str.split("\n"); var xy_sprite

multithreading - Why not use a full list of runnable threads, as opposed to just threads that are runnable but not running? -

i'm considering concepts behind multiprocessing, , i'm trying come reason why ready list used contains runnable threads aren't running, opposed list of runnable threads head of data structure being running thread(s)? thanks opinions. edit: let me clarify. far know, thread packages use ready list identify processes ready run, while running process identified separate variable. why don't include running processes in ready list data structure running thread @ head of structure, making thread package inclusive. multiprocessing cause problems in design scheme? because thread can run on 1 processor (core) @ time. list (queue, really) of threads ready run used scheduler when it's looking thread should run; if thread running on 1 cpu, can't run on cpu @ same time, scheduler not want @ (at time -- sometime later when it's not running , eligible run again, care again...)

c# - CommandBars in outlook 2010 -

so i've noticed commandbars appear in tabaddins in outlook 2010 default. there way can them appear in custom ribbon tab instead? if impossible or challenging, welcome suggestions easier ways achieve similar. you can create custom ribbon tab ribbon designer , move commandbar items ribbon buttons. an decent example can found http://msdn.microsoft.com/en-us/library/bb386104.aspx

Open File method in Perl -

i tested >> , > open destination file in code below, work well. what's different them? my $sourfile = "ch1.txt"; $destfile = "chapter1.txt"; open (sourfile, $sourfile); open (destfile, ">>$destfile"); #both >> , > work here. #my $fh = \*data; $fh = \*sourfile; the difference: > open file writing. >> open file appending. you might want switch using 3-argument form of open , , using lexical variables file handles: open(my $handle, '>', "some_file") or die $!;

Facebook OAuthException: Error validating application -

i have simple php page going used post message own wall. i've obtained offline_access token has "read_stream" , "publish_stream" permissions. define('fb_apikey', 'my_app_key'); define('fb_secret', 'my_app_secret'); define('fb_session', 'my_offline_token'); require_once('facebook.php'); try { $facebook = new facebook(fb_apikey, fb_secret); $facebook->api_client->session_key = fb_session; $attachment = array( 'message' => 'some meesgae', 'name' => 'this demo facebook application!', 'caption' => "caption of post", 'link' => 'mylink.com', 'description' => 'this description', 'actions' => array(array( 'name' => 'get search', 'link' => 'google.com'

iphone - App crashing with this error message - I cannot find anything about this after googling it- Can someone help please -

im not getting compile time errors nor comes when run build & analyze. @ run time app crashes when click uitextfield. -[__nscftype textfielddidbeginediting:]: unrecognized selector sent instance 0x583cb90 *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscftype textfielddidbeginediting:]: unrecognized selector sent instance 0x583cb90' 0 corefoundation 0x00fa25a9 __exceptionpreprocess + 185 1 libobjc.a.dylib 0x010f6313 objc_exception_throw + 44 2 corefoundation 0x00fa40bb -[nsobject(nsobject)doesnotrecognizeselector:] + 187 3 corefoundation 0x00f13966 ___forwarding___ + 966 4 corefoundation 0x00f13522 _cf_forwarding_prep_0 + 50 5 uikit 0x00394581 -[uicontrol(deprecated) sendaction:totarget:forevent:] + 67 6 uikit 0x00396e62 -[uicontrol(internal) _sendactionsforeventmask:withevent:] + 7 uikit 0x0039ce11 -[uitextfield willattachfieldeditor:] + 404 8 uikit 0

java - Grammar inference library? -

what best (or any) open source libraries regular or context-free grammar inference set of examples believed generated common grammar? i'd prefer library in java, python or ruby, of course beggars can't choosers. i did googling, couldn't find actual implementations, though did find plenty of interesting references. this library looks interesting, couldn't find available download anywhere. edit (2011-11-14): clarity (though i'm not sure how misunderstood), question grammar inference, not grammar generation or parsing. in other words, given set of strings accord unknown grammar, find restrictive grammar satisfy. i have not used them yet, had identical question , (after searching) found these 2 libraries, @ least: libalf c++ gitoolbox matlab unlike other answers question, these actual grammar inference libraries rather parser generators .

android - What is the difference between active scan and passive scan? -

what difference between mwifimanager.startscanactive() , mwifimanager.startscan() . difference between active scan , passive scan ? passive scanning listens beacons sent access points. means waiting beacon sent (usually few seconds). an active scanning emit probes aps immediately.

c - getaddrinfo error: ai_socktype not supported -

struct addrinfo *myaddrinfo, *curmyaddrinfo, hint; memset(&hint, 0, sizeof(struct addrinfo)); hint.ai_family = af_inet; hint.ai_protocol = ai_passive; hint.ai_socktype = sock_stream; const int code = getaddrinfo(null, server_port, &hint, &myaddrinfo); if ((code) != 0) { printf("getaddrinfo error occours: %s ", gai_strerror(code)); return 1; } this gives error: "ai_socktype not supported" if comment out hint.ai_protocol = ai_passive; through, wondering why happens? thanks time that's because ai_passive referred ai_flags field, (not ai_protocol). try : hint.ai_flags = ai_passive; and have @ addrinfo structure .

php - User tracking through urls and avoiding manual tampering -

i'd keep track of how many people follow link sent through email. at moment, i'm thinking of having separate page called through link variable indicate done email. obviously, can tampered manually through address bar of navigator. approaches use limit this? 1)use different url redirect real one: http://www.mysite.com/emailoffer -> http://www.mysite.com/specialpage emailoffer logging, , send location http header pointing real page (specialpage) http://www.mysite.com/emailoffer this: /* logging code goes here - mysql stuffs */ header("location: http://www.mysite.com/specialpage"); 2)add parameter like: http://www.mysite.com/specialpage?email in php, can do: if(array_key_exists('email',$_get)) addtocounter(); 3)you log http referer header hits page , run query referers containing "mail" (e.g., mail.google.com, hotmail.com) to prevent tampering, make parameter seem worth while: http://www.mysite.com/specialpage?secre

c# - Opening another form with a method/function that is on another thread? -

is possible open second form, when method/or function opening 2nd form on thread? i have read other threads related this.. seems cant figure out how use invoke here's how open 2nd form when im calling this.. nothing happens..(because on 2nd thread) timermode f2 = new timermode(); f2.showdialog(); please me. newbie multi -threading.. it should doing something. because showdialog run own message loop. timermode form should @ least visible , functioning. but, right, not best practice if form interacting other forms running on main ui thread. here how might it. anotherform.invoke( (methodinvoker)(() => { new timermode().showdialog(); })); note anotherform reference 1 of other forms hosted on main ui thread.

how to use groupBy with F# linq-to-sql? -

i do <@ linq.inctxes |> microsoft.fsharp.linq.query.groupby (fun intx -> intx.rectime, intx.id, intx.str) @> |> microsoft.fsharp.linq.query.query |> seq.map ^-^ fun sq -> but f# linq can't understand / translate type tuple of 3 elements ... can ? the tuples can't translated sql. can do group in f# , not in "sql" (f# quotation) shown below. <@ linq.inctxes @> |> microsoft.fsharp.linq.query.query |> seq.groupby (fun intx -> (intx.rectime, intx.id, intx.str)) |> seq.map ^-^ fun sq ->

Matlab: How to properly use the Java ImageIO class to get a BufferedIMage -

i'm trying mock-up in matlab on image data in database. image data java, output base64 encoded byte array. i'm not familiar [java image] format. however, wrote following matlab code based on java written working me. follow same basic outline, , java code able read image fine. matlab code looks this: function [ result ] = querydb( thequery ) conn = database( ... ); % connect database result = fetch( exec( conn, thequery ) ); result = result.data; close( conn ); end data = querydb( 'sql query data' ); data = uint8( data{1,1} ); data = org.apache.commons.codec.binary.base64.decodebase64( data ); data = uint8( 127 + data ); % base64 decoder returns signed int8 import javax.imageio.imageio; import java.io.bytearrayinputstream; datastream = bytearrayinputstream( data ); bufferedimage = imageio.read( datastream ); upon inspection of bufferedimage , empty array of double opposed java bufferedimage instance. i ran few tests on datastream see if

nsfetchedresultscontroller - Core Data Predicate one-to-many and many-to-one problem -

i have client entities , job entities. each job can have 1 client. relationship jobs of client (client<-->>job) called jobofclient. each client can have many jobs. relationship client of job (job<<-->client) called clientofjob. (of course, these inverse relationships.) i have predicates working, last 1 not. leaving out of fetchedresultscontroller set up, here of key lines of code 3 cases: here, sort through jobs, looking jobs aren't related client: nsentitydescription * entity = [nsentitydescription entityforname:@"job" inmanagedobjectcontext:datainterface.managedobjectcontext]; nspredicate *predicate = [nspredicate predicatewithformat: @"clientofjob == nil"]; here sort through jobs, looking jobs of particular client: nsentitydescription * entity = [nsentitydescription entityforname:@"job" inmanagedobjectcontext:datainterface.managedobjectcontext]; nspredicate *predicate = [nspredicate predicatewithformat: @&quo

c - Using getaddrinfo not giving desired output -

extern "c" int rtinet_lookup( const char * host, char * address, unsigned int port) { struct addrinfo hints, *res; int errcode; char addrstr[inet6_addrstrlen]; void *ptr; memset (&hints, 0, sizeof (hints)); hints.ai_family = af_unspec; hints.ai_socktype = sock_stream; hints.ai_protocol = ipproto_tcp; hints.ai_flags |= ai_canonname; errcode = getaddrinfo (host, "port", &hints, &res); /*if (errcode != 0) { perror ("getaddrinfo"); return -1; }*/ info(str("host: %s", host)); while (res) { inet_ntop (res->ai_family, res->ai_addr->sa_data, addrstr,inet6_addrstrlen); info(str("inside while condition res ")); switch (res->ai_family) { case af_inet: ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr; break; case af_inet6: ptr = &((struct sockaddr_in6 *) res->ai_addr)->s

What are all the formats of video supported by html5? -

i trying develop simple webpage newly added basic elements of html5. while working video tag, see formats .avi not supported. so there list of video formats supported html5? even if particular format webm/ogg supported html5, safe enough presume browser used capable display video? there no universally supported format (yet) unfortunately. technically, html5 doesn't support video formats, it's browsers support specific video formats. has led giant mess. you can find list of format compatibility on wikipedia . that, vp8/webm best bet if want support single format. luckily <video> tag support fallbacks if providing more 1 encoding feasible uses, in case vp8/webm version combined h.264 version covers every major browser. for multiple versions of same video, can use following code: <video width="320" height="240"> <source src="myvideo.mp4" type="video/mp4" /> <source src="myvideo.ogv"

Smarty Date Difference -

please post smarty syntax number of days between 2 dates database. able display other fields,but date field number of days not working way expected.please let me know there way solution without smarty additional plugins. smarty not include specific functions doing date math operations. have date_format timestamps, otherwise you'd either have write own days_diff plugin, find 1 online ( here's one , code review first of course), or date math in php , assign new variable in smarty.

java - Service Layer inject multiple DAO in practice -

here design problem between dao layer , service layer: in dao layer, there dao classes called: dao1, dao2, dao3 ... in service layer, there service classes called: service1, service2, service3 ... service1 need inject dao1, dao2, dao3 service2 need inject dao2, dao3, dao4 service3 need inject dao3 ... example creating user: userservice need inject userdao create user, userservice need inject logdao record system log information. it seems there repeating work need do. there solution in practice? using spring framework. using @resource annotation inject these dao in service class. my solution is: inject dao class (dao1, dao2, dao3 ...) daocollection class, service1, service2, service3... extends daocollection class. approach? thx you'd have define daos services use anyway, you'd have 'repeating' work extend. depending on framework use (if any) declaration shouldn't overhead (to type). example in ejb 3+: class service1 { @ejb

How to set value range to a column in mysql? -

i want set value range column of table. example decimal decimal, decimal column should allow insert or update value between 0 30. thanks in advance...! as mysql still doesn't support check constraints, way in mysql trigger (for update , insert) checks new value of column , throws error if value outside valid range.

database - mysql select between or what? -

i'm learning mysql , have case, have table this: id, level, minpost, maxpost 1, 'newbie', 0, 99 2, 'enthusiast', 100, 499 3, 'activist', 500, 749 4, 'socialite', 750, 999 so how know "level" if have 80 posts? should use select between or maybe have suggest problem? ps. cant post image :( select level <table> <mylevel> between minpost , maxpost the between operator following: expr between min , max equals: (min <= expr , expr <= max)

osx - Silverlight 5 "full access to the filesystem" in Mac? -

silverlight 5 allows full access local file system. know if feature available on mac os x? nope. trusted applications windows-only feature in silverlight 5. , trusted applications can access local file system.

sql server 2008 - Get a random value from a range in MS SQL? -

let suppose table can have values 000 999 (three digits , less 1000) some of values filled. let's suppose table has 000,002,005,190 (001,004,003,006,..189,191,..,999 can inserted table) and these values randomly allocated 000 , 002 in table 001 not in table yet. how can values can insert table yet. declare @t table (value char(3)) insert @t values ('000'),('002'),('005'),('190') ;with rncte ( select -1 + row_number() on (order type, number, name) rn master.dbo.spt_values ) select right('000' + cast( rn varchar(11)),3) rncte not exists ( select 1 @t value = rn ) , rn < 1000 edit this query works generating complete list of possible numbers system table ( master.dbo.spt_values ) guaranteed contain more 1000 rows inside cte rncte . -1 added row_number have values start @ 0 rather 1. the outer query 0 pads numbers display, returning not in source data , le

sql - Error while reading ms-excel file in coldfusion -

i executing sql read data ms-excel in coldfusion . sql is: select * "excel 8.0; database=c:\coldfusion8\wwwroot\myfiles\saletemplate.xls; hdr=yes".[template$] title not null , title<>'' but getting error: "excel 8.0; database=c:\coldfusion8\wwwroot\myfiles\saletemplate.xls; hdr=yes"' not valid name. make sure not include invalid characters or punctuation , not long. how solve error? the query use excel data through access datasource formatted this: select * [template$] in 'c:\coldfusion8\wwwroot\myfiles\saletemplate.xls' 'excel 8.0;'

vssget - Solution required for the query related to Visual Source Safe 6.0d -

i'm using microsoft visual studio .net 2003 enterprise developer tool( visual source safe 6.0d ). per knowledge, in vss there provision admin provide access(r/w access or checkin / checkout access) given specific user perticular folder(that having no. of different types of files) in project. want know, there provision @ admin level provide access specific file (that in folder) given user. there no file-based security setting support in vss, far know

jQuery select parent -

this might duplicate question, did search , got many different answers don't know use or how this. <? if(isset($content)) { $i = 1; foreach($content $item) { echo "<li><a href='#' name='" . $item['id'] . "'>" . $item['title'] . "</a></li>"; $i++; } } ?> i've added function these links jquery handle ajax call. select links follows: $("#tips_list ul li a").click(function(e) { //... } however, doesn't make lot of sense because have click on actual text instead of list item. figured i'd re-structure html anchor tag wraps around li tag. `<a href="#" name=""><li>foo</li></a>` i changed jquery code accordingly: $("#tips_list ul li").click(function(e) { //... } however, now, when click.. grabs list item tag $(this) ; means can't grab name attribute anc

api - Is there any easy way to "provide" more permissions for my facebook connect app, using sfFacebookConnect -

from see now, seems plugin provides me authenticated facebook user's email address.i need first name, last name, , other data. with plugin (few month ago) facebook_connect setting in app.yml did not work. so, i've put fb login button : <a href="https://www.facebook.com/dialog/oauth?client_id=*id_client*&redirect_uri=<?=urlencode("http://*your_url_callback*")?>&scope=email,user_birthday,publish_stream&response_type=token"><img src="/images/fb_dark_medium_short.gif" alt="facebook connect" style="width:100px"/></a> you can add in scope parameter permissions. hope can

objective c - Is there a modalViewControllerDidEnd method for modal view? -

i present navigation controller modally [self presentmodalviewcontroller:navcontroller animated:yes]; how can detect if modal view did end? there delegate method? as far know there no method or notification sent. i implement own delegate protocol time. i've posted code example delegate pattern answer question: delegate , passing data . there method called somethinghappenedtellmydelegate should trigger close dismissmodalviewcontrolleranimated:

voice recording and play programatically in blackberry -

is possible in blackberry record voice , play programatically. please give me idea how can achieve this. reference link if possible. thanks in advance. try this. - record code player player = manager.createplayer("capture://audio?encoding=amr"); recordcontrol recorder = (recordcontrol)player.getcontrol("recordcontrol"); recorder.setrecordlocation("file:///sdcard/blackberry/music/recordingfile.amr"); recorder.startrecord(); player.start(); thread.sleep(5000); recorder.commit(); player.close(); - play code player music = manager.createplayer("file:///sdcard/blackberry/music/musicfile.mp3"); music.realize(); music.start();

.net - Scripting - Remove Unused References -

the current application im working on has on 300 lightweight projects then built single application (with lot of dlls). ive started notice lot of projects have number of unused references being removed using "unused references..." button in visual studio on each project. is there way script activity on every project or tool use? dont want have go through projects individually. rob 300 dlls project, personaly think big number. if write custom ms build task il merge dlls speed overall working. ms build task: http://msdn.microsoft.com/en-us/library/ms171466.aspx il merge: http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx

Android: Why won't my emulator launch? -

i've created simple test project , generic emulator testdevice . however, can't app launch. i console-type window (oddly placed partially off screen) , nothing happens. i developing in eclipse (helios 3.6) on windows. here's log: [2011-05-11 10:08:04 - androidtest] android launch! [2011-05-11 10:08:04 - androidtest] adb running normally. [2011-05-11 10:08:04 - androidtest] performing androidtest.androidtestactivity activity launch [2011-05-11 10:08:04 - androidtest] automatic target mode: preferred avd 'testdevice' not available. launching new emulator. [2011-05-11 10:08:04 - androidtest] launching new emulator virtual device 'testdevice' [2011-05-11 10:08:14 - androidtest] new emulator found: emulator-5554 [2011-05-11 10:08:14 - androidtest] waiting home ('android.process.acore') launched... edit thanks tips! i targeting android 3.0 (api level 11) i've ensured specified androidtest.androidtestactivity launch action i'v

wpf - Two way binding to different value than -

is there way in wpf can getb value property display in textbox, when value of textbox updated, update different property on bound object? eg: 2 fields - quantity , newquantity. thinking along lines of imultivalueconverter if try add binding object , "two way binding requires path or xpath error". the problem i'm using web service, proxy classes autogenerated. i'm not sure i'd recommend it, because horrible bit of code, could in viewmodel behaviour want: private string _quantity; private string _newquantity; //bind public string quantity { { return _quantity; } set { _newquantity = value; } } public string newquantity { { return _newquantity; } }

asp.net mvc - Where is the Source Code for Html.TextBoxFor -

i browsing source code of asp.net mvc 3 downloaded codeplex. m particularly interested in seeing source code of typed helper methods textboxfor , dropdownlistfor failed locate them in inputextensions.cs , elsewhere. plz can point out can find required code. purpose see how these helper methods add html 5's data-* attributes different input elements on form. regards adeel get reflector (version 6. should somewhere available free), open system.web.mvc.dll , search inputextensions or get mvc source code , open in visual studio, , search inputextensions edit: misread question.. i guess looking inputextensions.cs line: 371 tagbuilder.mergeattributes(htmlhelper.getunobtrusivevalidationattributes(name, metadata));

java - How to programmatically determine which (load balanced) tomcat server the webapp is running on -

i have webapp running on 2 load balanced tomcat servers. what's best way app determine server it's running on? while can tell sessionid server it's running on (as .jvm1 , .jvm2 appended), how can similar information in background task (scheduled via spring's @scheduled annotation)? it might overkill , if there's way it's better, might able query tomcat engine mbean , it's jvmroute property. mbean usually called catalina:type=engine or catalina:type=engine,service=something (see here more details ).

java - converting a binary tree into List<List<Node>> -

is algorithm correct? list<list<node> > ol = new arraylist<list<node>>(); build(root,0) void build (node node,int level) { if(node==null) return; list<node> il; if(ol.size() < level){ il = new arraylist<node>(); }else{ il= ol.get(level); } il.add(node); ol.put(level,il); build(node.left, level+1); build(node.right,level+1); } assuming want list of nodes each level, seems correct, except: ol.put(level,il); list doesn't have put method (it set in case). i'd drop line above , add ol.add(il) after creating new array list level. i'd pass outer list method parameter instead of using member variable (although that's more of design issue) there's ; missing after build(root, 0) edit: clarify no. 2: if(ol.size() < level) { il = new arraylist<node>(); ol.add(il); //add here only, assuming level = ol.size() + 1 true in case }

c# - How do you resize a form to fit its content automatically? -

i trying implement following behaviour: on form there tabcontrol. on tabcontrol there treeview. prevent scrollbars appearing, form change size according contents of treeview when displayed first time. if treeview has many nodes displayed on default size of form, form should change it's size there no vertical scrollbar on treeview (up maximum size allowed size of screen). what need know is, if possible achieve behaviour through properties of controls. i'm sure can achieved calculating , settings sizes of elements programmatically, know if there way achieve settings autosizemode etc. [update] it's first dialog user of application sees: it's dialog select database work with. it's list of databases, tabcontrol, buttens etc. if list long, scrollbars appear , colleague of mine wants them disappear. use autosize , autosizemode properties. http://msdn.microsoft.com/en-us/library/system.windows.forms.form.autosize.aspx an example: private void fo

iphone - How To Rotate an UIImageView based on a point in Touches Moved Method? -

dear all, i want rotate uiimageview relative point in touchesmoved method. i tried 2 -3 methods not getting exact result expected be. first method used cgaffinetransform transforms = cgaffinetransformmakerotation(m_pi/2); imgview.transform = transforms; this written in touchesmoved. expect rotation image view in each touchesmoved. rotation occuring once . second method used was cgaffinetransform transforms = cgaffinetransformrotate(imgview.transform, m_pi/2); imgview.transform = transforms; now result image in image view continusely rotating in each move. imageview not rotating. need rotate imageview not image. any appreciated. thanks & best regards, rupesh r menon if understood correctly want achieve single finger rotation on image. if can use following functions 1 of live working project. can use single image multiple images. need modify @ extend multiple images. best way extend uiimageview class , create own class. from touches moved call fun

What's the difference between GWT's EditTextCell and TextInputCell? -

both cells seem render <input type="text"...></input> . how differ? respective uses? edittextcell special cell can used edit text. default cell in normal mode , text displayed non-editable html. on click cell changes edit mode , text displayed in input. user can edit text inside input. if in edit mode enter changes normal mode , fires valueupdater. if in edit mode esc changes normal mode without firing valueupdater. on other hand textinputcell cell displays text in input element. to see both cells action (columns 3 & 4): http://gwt.google.com/samples/showcase/showcase.html#!cwcellsampler

java - Regex to remove the uri prefix (within tag) only from xml tag -

i need regular expression remove uri prefix(within tag) xml tag. example input: <ns1:fso xlmns:="http://xyz"><sender>abc</sender></ns1:fso> output: <fso xlmns:="http://xyz"><sender>abc</sender></fso> here code: import java.util.regex.matcher; import java.util.regex.pattern; public final class regularexpressiontest { private static string regex1 = "<\\/?([a-z0-9]+?:).*?>"; private static string input = "<ns1:fso xmlns:ns1='https://www.example.com/fsocanonical'> <ns2:senderid xmlns='http://www.example.com/fsocanonical'>abc</ns2:senderid> <receiverid xmlns='http://www.example.com/fsocanonical'>testdata</receiverid> <messageid xmlns='http://www.example.com/fsocanonical'>4cf4dc05126a0077e10080000a66c871</messageid> </ns1:fso> "; private static string replace = "";

mysqli - Skip a sql statement from replication (Mysql) ? [ Disables or enables binary logging for the current session ] -

i want inserts on table (master mysql db) dont want replicate without effecting replication process. set sql_log_bin = {0|1} disables or enables binary logging current session (sql_log_bin session variable) if client has super privilege. statement fails error if client not have privilege

tfs - What is the default number of build agents that can run on a build service when the build service is installed on its own dedicated server? -

i attending competition supposed answer couple of engineering , technical related questions. hope of guys me one. i've searched web couple of hours, can't seem make out difference in names used. saw article http://msdn.microsoft.com/en-us/library/dd793166.aspx on msdn, still can't make out answer. the question is: in team fitting solutions use team foundation server 2010 manage , build our c# , c++ code. team foundation server able build code using number of build agents , build services. default number of build agents can run on build service when build service installed on own dedicated server? one build agent per build service the default number of build agents defined number of processor cores on server hosting build service none, because build agent cannot run on server hosting build service; needs own dedicated server thanks work. it turns out correct answer answer number 2. found "if installed team foundation build service on own se

java - Lucene distinct result -

please, me distinct result field. tried go many way, googled... can't ti. i tried add hashset, tried duplicatefilter. think collector without success. result. use java, lucene-2.9.3. example: some_id description 1 bbb aaa 1 aaa ccc 2 aaa ddd 2 fff aaa and if search description in result must distinct some_id (1,2). maybe have solution or have code example. thanks advance. the very-new (still patch) grouping module on https://issues.apache.org/jira/browse/lucene-1421 might relevant here. enables group hits according field. example, if group "author" documents having same author in same group.

MySql sum query -

i need mysql query following: select items in table, group them type, order them count type , sum count. this i've done far: select type, count(*) cnt $tbl_name group type order count(*) desc; this gives me count each group. should add code also show total count (sum counts every group). select * ( select type type, count(*) cnt $tbl_name group type rollup) inner_table order cnt desc; note forst row rolled total sum. rollup reference

PowerPoint VBA - Update linked graph from Excel at regular intervals -

i'm trying build system have powerpoint presentation linked graph external excel file. i've seen can right click graph in powerpoint , click "update link" , graph automatically updated. but if want automated? if can done without creating add-in have been great. event handlers there in powerpoint? reckon there's event slidechanged or something? possibly have presentation go in endless loop , update link @ each new slide switch? there possibly huge amounts of graphs. , 1 slide each section of graphs. or, other bright ideas? system i'm trying build framework collecting data , displaying in whatever form might wanted. data automatically imported economy software , database. i've created command line application opens excel file , runs macro (collecting fresh data , copy worksheet). command line application set run specific times via scheduled tasks. , it's data want show graphs from, automatically. i did large bit of myself :) here's code v

rtmp - problem connecting to red5 "firstApp" from librtmp -

i trying connect red5 tutorial "firstapp" application librtmp client. note can connect flex client, tutorial describes: ... //from flex client netconnection nc = new netconnection(); nc.connect("rtmp://localhost/firstapp"); - connected, works //from librtmp rtmp* r = rtmp_alloc(); retval = rtmp_setupurl(r, "rtmp://localhost/firstapp"); retval = rtmp_connect(r, null); - no connection retval = rtmp_setupurl(r, "rtmp://localhost:1935/firstapp"); retval = rtmp_connect(r, null); - still no connection //the same thing works fine red5 "live" application retval = rtmp_setupurl(r, "rtmp://localhost:1935/live/instance"); retval = rtmp_connect(r, null); - works, connected any ideas problem might be? thank you, -v can take @ logs? perhaps librtmp still send "live" name of application.

java - Is there any way to implement ws-security in metro via annotations? -

since not want create lot of wsit files enable security (encryption of message , authentication of users) , not want use netbeans use metro plugin there, want ask if there easy way implement ws-security via annotations? or there eclipse plugin besides soap ui, in fact not usefull, create such wsit files? thanks in advance. according this post , metro not support ws-policy programmatically. 2009 though, don't know if that's still case. metro can policy directly wsdl if don't want use wsit files (if have policy in wsdl @ all, is). this how did in metro-generated service class. loads policy directly wsdl, in classpath, , apply policies in runtime, provided have installed metro in application server , don't have conflicting dependencies in project (this 1 bit of hassle me find, of dependencies had jaxws-rt dependency, may ruin metros policy resolving). private final static url customerservice_wsdl_location; static { customerservice_wsdl_location =

python - Use scipy.integrate.quad to integrate complex numbers -

i'm using right scipy.integrate.quad integrate real integrands. situation appeared need integrate complex integrand. quad seems not able it, other scipy.integrate routines, ask: there way integrate complex integrand using scipy.integrate, without having separate integral in real , imaginary parts? what's wrong separating out real , imaginary parts? scipy.integrate.quad requires integrated function return floats (aka real numbers) algorithm uses. import scipy scipy.integrate import quad def complex_quadrature(func, a, b, **kwargs): def real_func(x): return scipy.real(func(x)) def imag_func(x): return scipy.imag(func(x)) real_integral = quad(real_func, a, b, **kwargs) imag_integral = quad(imag_func, a, b, **kwargs) return (real_integral[0] + 1j*imag_integral[0], real_integral[1:], imag_integral[1:]) e.g., >>> complex_quadrature(lambda x: (scipy.exp(1j*x)), 0,scipy.pi/2) ((0.99999999999999989+0.99999999999999989j),

properties - Problems with adding a `lazy` keyword to C# -

i love write code this: class zebra { public lazy int stripecount { { return expensivecountingmethodthatreallyonlyneedstoberunonce(); } } } edit: why? think looks better than: class zebra { private lazy<int> _stripecount; public zebra() { this._stripecount = new lazy(() => expensivecountingmethodthatreallyonlyneedstoberunonce()); } public lazy int stripecount { { return this._stripecount.value; } } } the first time call property, run code in get block, , afterward return value it. my questions: what costs involved adding kind of keyword library? what situations problematic in? would find useful? i'm not starting crusade next version of library, curious kind of considerations feature such should have go through. i curious kind of considerations feature such should have go through. first off, write blog subject, amongst others. see old blog: http://blogs.msdn.com/b/eric

.htaccess - Redirect 301 Not working the way I intended it to! -

trying simple 301 redirect htaccess using code: redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/ the results sending me http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/?page=cat/radiator-cages/product/radiator-support-cage any idea i'm doing wrong? in advance help. --update-- rewritecond %{http_host} ^mysite.com [nc] rewriterule ^(.*)$ http://www.mysite.com/$1 [l,r=301] rewriterule ^product/(.*)/(.*)/$ /index.php?page=product&parent_url=$1&product=$2 [l,nc] redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/ i suggest trying use redirect 301 statement first. your htaccess should somthing this redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/ rewrite

Jquery Datepicker Chrome -

when using jquery ui datepicker, encouter problem when used in google chrome: when enter date day higher 12, not accept valid date, because chrome thinks dateformat mm/dd/yyyy. tried solve adding code try force date settings dd/mm/yyyy $('.date').datepicker({ dateformat: "dd/mm/yy" }); is there way resolve issue, our datepicker accept dd/mm/yyyy values? have issue in google chrome, datefix works firefox, ie & safari. using aspx & mvc3 project. if solve our issue, great thanks i have had same problem , related webkit based web browsers. if set uppercase m textbox show moth letters. best solution me override validate date function jquery.validate.js create jquery.validate.date.js , ensure loaded after jquery.validate.js add following code jquery.validate.date.js $(function() { $.validator.methods.date = function (value, element) { if ($.browser.webkit) { //es - chrome not use locale when new date objects inst

javascript - update SVG dynamically -

i have objects inside of svg can clicked user. is there way to: - send information object (id) clicked user 'main html document'? - draw outside document in svg file. probably, description unclear,... want implement this: user click on object inside of svg-image; main document receive id of clicked object and: display information object; draw additional object inside of svg-image. questions: how communication svg document , document svg? thanks lot, thoughts welcome! p.s. svg not best way that? better then? edit: saw recommendation regarding use of raphael,.. see 'native' options. (for i'm analyzing raphaels implementation see that, don't think doing need). see this example how dom of referenced svg parent document. and here's example of how can call svg file parent document. svg suited doing describe.

multithreading - c++ Boost Multithread Running Slow when two threads read file and tokenize the CSV File -

i have 2 functions, used work me, did changes in codes don't know happened. when executed functions multi-threads, cpu 10-30%, , slow. readfile line parse csv line using boost token. boost::thread offlineul(&avatti::avacollectttiadvance::ueandcellparamparseul,c,tracefilenameul.c_str(),numoflines,ghostfilter,"","/",offlinemode,openexcelauto); boost::thread offlinedl(&avatti::avacollectttiadvance::ueandcellparamparsedl,c,tracefilenamedl.c_str(), numoflines,"","/",offlinemode,openexcelauto); offlinedl.join(); offlineul.join(); int avacollectttiadvance::ueandcellparamparsedl(const char *inname, int numofrecords, const char *userdir, const char* currentdir, int offlinemode, int openexcelauto) { typedef boost::tokenizer <boost::escaped_list_separator<char> > my_tokenizer; vector <string> mystr; std::ifstream infile(ttiasciitraceoutputuserdir.str(),std::i

xml - Python object wrapper for lxml etree? -

given lxml.etree possible somehow construct object representation of tree, sub-elements can accessed in object-like fashion (with '.' operator)? i know lxml has library called objectify looks can constructed given raw xml , adding new elements tree still requires go through etree-like node creation. ideally want achieve is: tree = objectify( etree_root ) print tree.somenode.get( 'attrib_name' ) tree.somenode.set( 'attrib_name', 'some_val' ) node( tree.somenode, "somechild" ) tree.somenode.somechild.set( 'attrib', 'foo' ) i guess have override __setattribute__ respectively __getattribute__ operators. guess have subclass etree.element class achieve this. but, on other hand api quite impractical, since there might multiple child-nodes same tag name. to find elements can use xpath expressions, correllate idea. api follows: subchild = root.find('child/subchild')

jqgrid filterToolbar search input size -

i'm starting use filtertoolbar: mygrid.jqgrid('filtertoolbar', {stringresult: true, searchonenter: false, defaultsearch : "cn"}); my question if can control search inputs size - update : it's height , width size . thank's in advance. if understand correct should include in colmodel in definition of column input size want restrict option like searchoptions:{ attr: {maxlength: 5}} in example in corresponding input field of searching toolbar allowed type not more 5 characters. updated : don't understand why need such behavior, can use datainit of searchoptions set height , width of input control. can use either jquery.css or jquery.height , jquery.width methods: searchoptions:{ attr: {maxlength: 5}, datainit: function(elem) { //$(elem).css({height:"30px", width:"40px"}); $(elem).height(30).width(40); } } if increase height of control in searching toolbar should change addition

objective c - How do I install uncrustify? -

how install uncrustify ? followed instruction install uncrustify when run it, not work. can give me installing tool? want run on objective-c code in xcode 4. in adavance on os x mavericks 10.9.1 : 1- install brew, open terminal windows , type : ruby -e "$(curl -fssl https://raw.github.com/homebrew/homebrew/go/install)" it ask download other files, answer ok (for more information see : http://brew.sh/index_fr.html ). 2 - install uncrusify, open terminal windows type : brew install uncrustify 3 - make code beautiful, download bbuncrustifyplugin-xcode available @ https://github.com/benoitsan/bbuncrustifyplugin-xcode you have : compile project copy file uncrusify.cfg in home directory restart xcode. nb : bbuncrustifyplugin, don't need use automator. 4 - after restarting xcode, use menu edit > uncrustify selected files uncrustify selected items in project navigator. your code beautiful! that's magic! post-scriptum : can change un

javascript - Change Picture with JS -

i want change background picture(a div) javascript take database. picture embedded in css. want use jquery. css .home_div { width: 958px; height: 350px; margin-bottom: 12px; background: url(../images/bg_home_div.png) } no jscript. use jquery on other part of website. using jquery, can: $('body').css('background-image', 'images/myimage.jpg');

Facebook like: pages that require a login -

i have facebook button on page requires user logged in. when user clicks button when logged in, posts wall "this user liked google accounts www.mypage.com" want people able page want other users see proper page title , not google accounts. want entire page visible loggeed in users. how let facebook see page can scrape proper title, when users click on link asked login?

Android: How to divide LinearLayout in two parts of exactly the same size? -

i have following layout: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:orientation="horizontal" android:weightsum="2"> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:name="ch.lexs.view.lawlist" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"> </fragment> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:name="ch.lexs.view.paragraphlist" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"> </fragment> </linearlayout> my intention divide linea

asp.net - Database design - one database, multiple sites -

i know question has been asked many times before couldn't find exact answer mine. please let me ask here. we built cms control 1 site. company expanding , have couple more sites identical core structure. decided go 1 database easy maintenance later on. we have 10 tables. example, pages, news, settings (different each site), ... it doesn't sound idea if add 1 app_id (or site_id) column every each of these tables know records particular site should pull out. for instance, pages: pageid | body | siteid 1 | abc | 1 2 | cde | 1 3 | aafd | 2 4 | gsgs | 2 5 | feg | 3 i think abundant add siteid column every table in database. i looked @ multi-tenant architecture don't know how apply our sites cms. what best way handle situation, please help. enlightenment appreciated. simple code we've been reviewing various strategies multi-tenant single database. if don't want ad

image - Do the libjpeg and the .Net jpeg codec really differ significantly on monochrome data? -

Image
i work lot of monochrome image data , morning noticed there appears significant difference between way libjpeg , .net jpeg codec handle monochrome data. appears monochrome image saved @ quality setting using libjpeg , opened using default .net jpeg codec loads 16 different shades of gray , intermediate shades rendered stippled. here histogram of smooth gradient saved libjpeg , loaded .net the histogram should have been level. and here (zoomed in) sample of gradient looks (it should smooth transition) this should smooth transition gray 85 on left gray 136 on right 4 shades of gray rendered make transition. my question crazy , if not how far codec discrepancy go? there workaround if using both libraries in different programs? i not blaming either codec, pointing out appears discrepancy. noticed images knew created using libjpeg, assumed quality setting issue, tried using faststone image resizer create test images , got same result, tried using irfanview , got same resul