Posts

Showing posts from April, 2015

c# - MVC: what code gets called when you click the "submit" button? -

mvc newbie question; i'm learning playing around rather reading manual... :) i see when create "edit" view auto-generated view includes "submit" button: <input type="submit" value="save" /> but code gets called behind scenes save? specifically, model underlying view has own fancy save logic in code want call. how view invoke code instead of whatever standard code being called invisibly behind scenes? it call whatever public action method form action pointing on controller. can call save on view model. public virtual actionresult save(myviewmodel model) { model.save(); --- more code stuff here } set form action mycontroller/save you can use using (html.beginform... in code point form specific action method on specific controller.

android - placing a text value in a desired position -

i have drawn graphic object ,say rectangle. write text @ each corner of rectangle. how achieve ? private static class simpleview extends view { private shapedrawable mdrawable = new shapedrawable(); public simpleview(context context) { super(context); setfocusable(true); this.mdrawable = new shapedrawable(new rectshape()); this.mdrawable.getpaint().setcolor(0xff0f00ff); } @override protected void ondraw(canvas canvas) { int x1 = 50; int y1 = 150; int width = 400; int height = 50; this.mdrawable.setbounds(x1, y1, x1 + width, y1 + height); this.mdrawable.draw(canvas); int x = 0; int y = 0; paint paint = new paint(); paint.setstyle(paint.style.fill); etc if using canvas thenjust use drawtext() method. drawtext(string text, int start, int end, float x, float y, paint paint) source: htt...

dependencies - msbuild reference resolution -

i've been doing work analyzes relationships between various projects in source control. far i've been using powershell , xpath through select-xml cmdlet process our csproj files, relies on tenuous knowledge of how msbuild uses projectreference , reference elements in project files. dawned on me better if use msbuild resolve references , somehow inspect results of reference resolution process. msbuild experts: seem possible? entail writing custom targets file or something? forced building projects since csproj files import microsoft.csharp.targets? any insight nice. thanks! it quite easy. first reference these assemblies: microsoft.build microsoft.build.engine microsoft.build.framework microsoft.build.utilities.v4.0 ...and can create tooling around msbuild object model. i've got custom msbuild task analysis right in build, snippet below: private bool checkreferences(string projectfullpath) { var project = new project(projectfullpath); var it...

multithreading - How Java multi-threaded program is able to use multiple CPU cores? -

could please provide explanation how java multi-threaded program (e.g. tomcat servlet container) able use cores of cpu when jvm single process on linux? there in-depth article describes subject in details? edit #1 : i'm not looking advice how implement multi-threaded program in java. i'm looking explanation of how jvm internally manages use multiple cores on linux/windows while still being single process on os. edit #2 : best explanation managed find hotspot (sun/oracle jvm) implements threads native threads on linux using nptl. more less each thread in java lightweight process (native thread) on linux. visible using ps -elf command print outs not process id ( ppid ) native thread id ( lwp ). more details can found here: http://www.velocityreviews.com/forums/t499841-java-5-threads-in-linux.html distinguishing between java threads , os threads? edit #3 : wikipedia has short nice entry on nptl further references http://en.wikipedia.org/wiki/native_posix_thread_l...

Matrix Class - Android SDK -

in matrix class of current android sdk, there 2 apis find hard understand. what differences between: 1. postscale(float sx, float sy) , 2. postscale(float sx, float sy, float px, float py) in particular, purposes of last 2 parameters ? this should center of scaling . if have wolfram player installed, try link better understanding: understanding 2d scaling

axapta - Dynamics AX 2009: Add a field to InventJournalTrans, propagate to InventTrans -

i need add additional field inventjournaltrans , after posting show in inventtrans table. field reference column record in table. method(s) need modify make behavior happen? currently, have added fields both tables , modified form allow user enter , save new field. can't seem find bottom of rabbit hole on actual posting inventtrans occurring. ideally, should a: inventtrans.reasonrefrecid = inventjournaltrans.reasonrefrecid; assignment statement before the inventtrans.insert(); call. have clue on at? the link above contain solution -- have included code page in case page disappears or no longer becomes available. gl00mie answering on site , providing answer. you should create new inventmovement method this: public mynewfieldtype mynewfield() { return mynewfieldtype::defaultvalue; // suppose new field enum } then modify \classes\inventmovement\initinventtransfrombuffer void initinventtransfrombuffer(inventtrans _inventtrans, inventmovement ...

sql server - displaying parameter of the string in sql -

i have string "dbo.proudction @prodid= '1,2,10,4,5,6,7,8,13,16,17,3' ,@stock= 0”. i have execute query to select '1,2,10,4,5,6,7,8,13,16,17,3'. if understand correctly, want do: select @prodid;

php - CSS-only version of com_content in Joomla -

has built version of com_content joomla 1.5 component? i've got table-free design don't want introduce ugly tables content. there alternative component pure css? thank you. check com_content in beez template, tables free. also, (i think) template overrides in template tables free; used base templates , made appropriate changes.

c# - How can I create a window with an arrow pointing to another window? -

Image
i able design similar see when exception in visual studio, sort of window line connecting window point in code window. i've included picture of below: i notice whenever code window loses focus, exception window disappears. when focused, though, can move window around, , arrow continues point @ target. how being done? specifically, how can draw line 1 window another ? i'm coding in c# , using windows forms. in example, window exception not disappear if text box loses focus! by investigating little bit spy++ tool (put find window cursor on line), notice line see between yellow text , exception window contained in window (with transparent background) (with class window of type "windowsforms10.window.8.app.0.34f5582_r41_ad1" in vs 2010). window has ws_popup style, , exact bounding box of line (its size , position fit line). so can same thing: create transparent popup window, draw line on , set location , size line appears between controls want. ...

android - How to keep always up-to-date reference to Activity -

i have 2 activities , want keep reference of second activity in first activity . best way keep reference up-to-date because far understand new instance of activity created each time activity launching. i want keep reference of second activity in first activity. you absolutely positively not want this. find solution whatever problem think trying solve. to clarify, introduce memory leaks.

ios - Differentiating between initial buy and free "re-buy" in StoreKit/In-App Purchase -

from storekit guide: if user attempts purchase nonconsumable product or renewable subscription have purchased, application receives regular transaction item, not restore transaction. however, user not charged again product. application should treat these transactions identically of original transaction. this presents huge problem in app working on. have licensed large body of content publisher sale through in-app purchase. require every time sell piece of content (i.e. user pays us), our server calls api on servers report transaction. accounting purposes , used determine how pay them @ end of month, per our agreement them. i have read several suggestions on , elsewhere calling restorecompletedtransactions rather , maintaining local understanding, on device, of user has purchased cannot allowed purchase again. me seems should able implemented on server side. however, receipts getting apple servers same buy , re-buy, promised storekit guide. if payment callbacks storekit cann...

c++ - Setprecision is Confusing -

i want ask setprecision because i'm bit confused. here's code: #include <iostream> #include <iomanip> using namespace std; int main() { double rate = x; cout << fixed << setprecision(2) << rate; } where x = following: the left side of equation values of x. 1.105 = 1.10 should 1.11 1.115 = 1.11 should 1.12 1.125 = 1.12 should 1.13 1.135 = 1.14 correct 1.145 = 1.15 correct but if x is: 2.115 = 2.12 correct 2.125 = 2.12 should 2.13 so why in value it's correct it's wrong? please enlighten me. thanks there no reason expect of constants in post can represented exactly using floating-point system. consequence, exact halves have may no longer exact halves once store them in double variable (regardless of how iostreams meant round such numbers.) the following code illustrates point: #include <iostream> #include <iomanip> using namespace std; int main() { double rate = 1.115; co...

silverlight 4.0 - Expanding item differs from selected item -

i trying implement mvvm, , having issues moving loadondemand viewmodel using triggers , relaycommands, have event firing , all, turns out possible expand node in tree without having selected (i have databound selecteditem property in viewmodel), breaking logic, since onload animation continue spin. if instead this: private void hierarchytreecontrol_loadondemand( object sender, telerik.windows.radroutedeventargs e){ radtreeviewitem clickeditem = null; clickeditem = e.originalsource radtreeviewitem; if (clickeditem != null) { ...do load logic in code behind file. have access expanding item (clickeditem). missing? is possible sort of binding on exandingitem? any appreciated :) since not using standard treeview, cannot sure relevant. have had success in binding treeviewitem's isexpanded property viewmodel property, in loaded items when value set true (and not loaded). here useful link: one more platform difference ...

Firefox KRL extension on yahoo mail -

it looks firefox extension might have issue yui 2.5.2 , 2.7 rich text editor. in platform rally when see text area, lot of html embedded it. rally uses yui 2.5.2. easier example see in yahoo mail. if install kynetx extension , go create new mail in yahoo account, see following output in compose box rendered html. looks bug either yui or kynetx app. ',' ',' ',' ',' ',' ','',' ',' ',' ',' ',' filters:',' trace',' debug',' info',' warn',' error',' fatal',' all',' ',' ',' search: ',' ',' regex',' match case',' disable',' ',' ',' ',' filter',' highlight all',' ',' ',' ',' options:',' log',' wrap',' newest @ top',' scroll latest',' ',' ',' ',' ',' ...

osx - AppleScript Runner exit status passed back to shell script -

i need able run applescript in shell script. using "applescript runner" in order in interactive mode, dialogs etc. supported. i've got working, need exit status of applescript runner app shell, can see if there errors in script. here shell script: output=$(/usr/bin/osascript << eot tell application "applescript runner" script "somescript.scpt" end eot) status=$? here variable $status ends exit status of osascript command (which 0 whether or not somescript.scpt ran successfully), , not exit status of app applescript runner. does 1 know how might accomplish this? thanks! the -e flag prints errors stderr , default. need read stderr. this answer might if aren't familiar that: bash variable capture stderr , stdout separately or exit value edit: added sample code. error=`osascript -e 'tell app "finder" adtivate' 2>&1` echo $error the above on system captures error messages.

objective c - Accessing Data While searchDisplayController is Active -

my iphone app using core data, uisearchbar, uisearchdisplaycontroller, uitableview , uiactionsheet. when no search being performed, can determine row selected user, if search active , selection made user of specific row, how 1 determine row selected user? example: following code works without error when no search active: - (void)actionsheet:(uiactionsheet *)actionsheet willdismisswithbuttonindex:(nsinteger)buttonindex { nsindexpath *selectedindexpath = [self.tableview indexpathforselectedrow]; event *event = (event *)[[self fetchedresultscontroller] objectatindexpath:selectedindexpath]; [self showurl:[nsurl urlwithstring:event.sitesite] withtitle:@""]; but, url null if use above method determine corresponding "event.sitesite" or url, while [self.searchdisplaycontroller isactive] equates true. when use uisearchdisplaycontroller second tableview super imposed on first. tabelview have query find out row selected. see uisearchdis...

jquery ajax not sending dates -

i hoping can me problem facing: i have ajax call follow: $(document).ready(function(){ $("#booking").submit(function() { var arrival = $('#arrival').attr('value'); var departure = $('#departure').attr('value'); var ap_id = $('#ap_id').attr('value'); $.ajax({ type: "post", url: "ajax/val_booking.php", data: "arrival="+ arrival +"&departure="+ departure +"&ap_id=" + ap_id, }); return false; }); }); all fields in html form have "name" attribute. when sending info ap_id sent arrival , departure empty (checked firebug). also used serialize() same result. does know might problem or might doing wrong? thank help. ps: using datepicker try this: $('#booking').submit(function() { var arrival = $('#arrival').val() va...

javascript - accessing variables outside ajax -

i have following code: var src, flickrimages = []; $.ajax({ type: "get", url: "http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=bf771e95f2c259056de5c6364c0dbb62&text=" + xmltitle.replace(' ', '%20') + "&safe_search=1&per_page=5&format=json", datatype: "json", statuscode: { 404: function() { alert('page not found'); } }, success: function(data) { $.each(data.photos.photo, function(i,item){ src = "http://farm"+ item.farm +".static.flickr.com/" + item.server + "/" + item.id + "_" + item.secret + "_s.jpg"; flickrimages[i] = '<img src="' + src + '">'; }); } }); // undefined returned here flickrimages map.setzoom(13); map.setcenter(new google.maps.latlng(xmllat,xmllng)); infowindow.setc...

c# - how to parse this Xml type string -

can 1 guide me how parse xml type string ? <data> <lastupdate></lastupdate> <ac1>12</ac1> <ac2>13</ac2> <ac3>14</ac3> <moter></moter> <fan1></fan1> <fan2></fan2> <tubelight1></tubelight1> <tubelight2></tubelight2> <moter></moter> <closeall></closeall> </data> i need result in string or list or dictionary ac1=12 , ac2=13 , on thnaks in advance this should work have remove duplicate moter element xml - can use dictionary: xdocument doc = xdocument.load("test.xml"); var dictionary = doc.descendants("data") .elements() .todictionary(x => x.name.tostring(), x => x.value); string ac1value = dictionary["ac1"];

Changing bar colors in bar graph - VBA Excel 2007 -

i've created vba excel 2007 program automatically creates bar graphs roi based on 52 different tabs in active workbook. i'm close done, , only thing cannot figure out how change colors of bargraphs. the graphs created in own subfunction, called call so. every variable changes around whenever it's called. call addchartobject(1, 1, "example", extraweeks, weekdifference) my sub calls looks this. sub addchartobject(j integer, k integer, passedcharttitle string, xtrawks integer, ttlwks integer) dim topofchart integer topofchart = 25 + (350 * j) 'adds bar chart total sales activesheet.chartobjects.add(left:=375, width:=475, top:=topofchart, height:=325) .chart.setsourcedata source:=sheets("consolidation").range("$a$" & 3 + ((17 + xtrawks) _ * j) & ":$c$" & (4 + ttlwks) + ((17 + xtrawks) * k)) .chart.charttype = xl3dcolumnclustered .chart.setelement (msoel...

c# - Sending data to 127.* : Unreachable Host -

i'm trying send loopback address space in .net 3.5 application running on windows xp. code simple: receiver = new ipendpoint(ipaddress.parse("127.0.0.2"), 8000); sock.sendto(data, len, socketflags.none, receiver); when run code unreachable host socket exception. seems strange me because loopback interface around, , shouldn't generate unreachable host exceptions. windows 7 executes code fine, making problem stranger. so -- if has tips on getting working in xp, i'd appreciate it. edit: some info: something listening on 127.0.0.2, netstat shows: udp 127.0.0.2:8000 : 5824 i running xp sp3, , there no firewall on test machine i'm noticing on xp when ping 127.0.0.2, replies come back: reply 127.0.0.1 on windows 7 reply comes address pinged: reply 127.0.0.2 i'm thinking issue , such it's not programming problem, it's more of problem xp itself... -- dan does work 127...

hyperlink - Provide direct download link on Android -

in application, want present button allows user download sister application. aware of market://details?id= type of custom urls , links. download begin user presses button, rather displaying app page , making user press install button there. going through http://developer.android.com/guide/publishing/publishing.html , seems not possible. want confirm doubts. thanks, akshay the link correct: want happen intentionally impossible. rather large security risk if simple link automatically install software onto device.

wcf - Ways to invoke a Windows application through a http URL? -

i have windows desktop application i'd users able invoke through url. main idea can launch installed app command-line parameters through, say, link in email. additionally, optimal implementation handle situation user doesn't already have app installed, fall-through download link. (likely download location machine on users network, not web address). at risk of making x , y problem here's i've considered: to invoke already-installed application, i've considered implementing custom protocol handler ( msdn article ), give them url myapp://whatever?blar=123 . if don't have application installed, url won't work, , won't redirected download application. i've considered wcf rest listener service runs in background, links can use http , formulated http://some-network-machine/whatever?blar=123 , if app installed, trap call , launch application, , if it's not installed, call fall through "some-network-machine" serve download page. i...

c# - Unusual behavior of text inputs on stock Android browser -

edit : tested on droid x running android version 2.2.1 . samsung galaxy s version unknown. i'm developing webpage designed run on mobile devices, android , ios. seems working fine on ios, i'm experiencing weird behavior on android. i'm using asp.net c# , jquery. specifically, have form several text inputs. there's nothing special these text inputs: <div class="line"> <input name="street" type="text" id="street" style="height:25px;width:194px;" /> </div> now, when viewed on android devices (specifically droid x) screen jumps erratically when inputting information. on samsung galaxy s, user isn't able input data because keyboard never appears when text area tapped. ideas? unfortunately, cannot share link external requests blocked our firewall.

c++ - Style of programming templates -

if having option, 1 choose? template<class checkeverynode<true>> struct x; or template<bool checkeverynode> struct x; that isn't obvious designers perspective, on 1 side have readability in actual code: //taking first approach //somewhere in code x<checkeverynode<false>> x; on second side there more type , prefer: //taking second approach //somewhere in code x<false> x;//but here don't see false means. so, looking forward opinions/suggestions often dabbling in metaprogramming, can recommend "verbose" approach, don't quite first approach propose. ideally, when using policies, don't pass flag, pass policy object, allow user customize @ will, rather relying on own predefined values. for example: struct nodecheckertag {}; struct checkeverynode { typedef nodecheckertag policytag; void check(list const& list); }; struct checkfirstnode { typedef nodecheckertag policytag; void che...

c - Building VFML Incremental Decision Tree Segmentation Fault -

i'm attempting compile vfml toolkit on ubuntu 10.04. built using gcc , hasn't been maintained in 7 years, it's open source implementation of incremental decision tree algorithm (vfdt), i'd evaluate it. after fixing couple minor bugs in makefile , vfml/src/core/beliefnet.c, able compile it. however, attempting run vfdt or cvfdt binaries on example "banana" dataset (vfml/examples/c45interface/test.data) results in segmentation fault. localhost:vfml$ vfdt -batch -f test segmentation fault my c little rusty, , it's been while since i've debugged these kinds of errors. can recommend best way fix such old code? route dig gdb or there other way update code work modern version of gcc? the 'best way' fix old code start known working environment , migrate environment want. find popular stable distribution last release date. if last release july 2003, try red hat linux 9 (shrike-i386-disc1.iso, shrike-i386-disc2.iso, shrike-i386-d...

r - Apparent time-travelling via python's multiprocessing module: surely I've done something wrong -

i use python video-game-like experiments in cognitive science. i'm testing out device detects eye movements via eog , , device talks computer via usb. ensure data being continuously read usb while experiment other things (like changing display, etc), thought i'd use multiprocessing module (with multicore computer of course), put usb reading work in separate worker process, , use queue tell worker when events of interest occur in experiment. however, i've encountered strange behaviour such when there 1 second between enqueuing of 2 different messages worker, when @ worker's output @ end, seems have received second after first. surely i've coded awry, can't see what, i'd appreciate can provide. i've attempted strip down code minimal example demonstrating behaviour. if go gist: https://gist.github.com/914070 you find "multiprocessing_timetravel.py", codes example, , "analysis.r", analyzes "temp.txt" file results runni...

multithreading - CPU usage of Java + JDBC -

while testing webapp under load got following top excerpt under linux: pid user pr ni virt res shr s %cpu %mem time+ command 3964 nobody 20 0 4965m 622m 6048 s 8.5 11.0 6:02.49 java 1985 mysql 20 0 294m 125m 3804 s 2.1 2.2 0:05.39 /usr/sbin/mysqld i need explanation on java's %cpu column. understand it, during web request 1 of java 's thread performing pure java logic, consuming of cpu time (let 5ms). connects database via jdbc, sends sql query , waits, 10ms , response. these 10ms counted /usr/sbin/mysqld cpu usage. java thread resumes it's operation , finishes, consuming 20ms , amounting 5+10+20=30ms total execution time. and newbie question is: don't think these db-related 10ms counted twice: 1 time java thread waiting db process query , second time database cpu usage itself? don't understand here? when process waiting on socket not using significant amounts of cpu. basically, kernel knows in waiting state...

security - browsers built-in public key -

while searching security issues hear "browsers , jdk come built-in certificates , public keys several cas".. can 1 me find out process identify browsers built-in public key.. question reasonable? make sure have pristine new install of browser in question. use browser preferences/options menus find list of pre-installed ca certificates: on firefox 3.6.15 browser @ edit->preferences->advanced->encryption->view certificates->authorities on chromium it's @ preferences->under hood->security->manage certificates->authorities any other browser should similar in respect, although list of pre-installed ca differ when comes of more minor cas.

iphone - Showing a subview temporary -

Image
what trying achieve showing view during couple of seconds without user intervention. same effect ringer volume view appears when pressing volume controls on iphone: i have scroll view image, taping in image, sound begin play, tap , pauses. implement above effect inform of action (showing play/pause images). i hope have explained problem perfectly. many help. regards javi assume have class inherited uiviewcontroller . can use code below: const int myviewtag = 10001; const int myinterval = 1; // define time want view visible - (void)someaction { //this `ibaction` implementation [self showmyview]; [nstimer scheduledtimerwithtimeinterval:myinterval target:self selector:@selector(hidemyview) userinfo:nil repeats:no]; } - (void) showmyview { //you can use here view declared instance var uiview *myview = ...

asp.net - Digitally sign a PDF on the server -

i have project generate pdfs on server using asp.net (c #). need customer able digitally sign these pdf. saw, documents must signed @ client side, using applet, in server have no access private key of certificate, said above, pdfs generated on server , keep them there. so, need digitally sign pdfs on server, taking client's certificate. thanks since not possible or anyway safe extract , send client's private key, sign pdfs on server need establish "session" client , let them calculate signature. the steps should like: 1- client sends public certificate embedded in signed pdf 2- server generates pdf, embeds certificate , calculates hash (eg: sha1) 3- server sends hash client applet 4- applet calculates digital signature private key 5- applet sends signature server 6- server embeds digital signature , closes pdf. to itext have use preclose method after ambedding certificate, able alculate sha1 hash on final document. after pre-closin...

asp.net - Unable to call webmethod in autocomplete textbox -

aspx page code: <ajax:scriptmanager id="scriptmanager1" runat="server"> <services > <ajax:servicereference path="myservice.asmx" /> </services> </ajax:scriptmanager> <asp:textbox id="txtmaterialno" width="100%" runat="server" ></asp:textbox> <cc1:autocompleteextender id="autocompleteextender1" runat="server" completioninterval="20" minimumprefixlength="1" servicemethod="getmaterialid" servicepath="myservice.asmx" targetcontrolid="txtmaterialno"> </cc1:autocompleteextender> myservice.asmx [scriptservice] [webservice(namespace = "http://tempuri.org/")] [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)] public class myservice : system.web.services.webservice public myservice() { //uncomment following line if usin...

email - How to send a mail with a specific template to users from a file in Linux (template contains info from the file)? -

basically have take surname, lastname, username, , grade file , have send email user ('username') looks this: "dear 'surname' 'lastname'! grade on 'class name' exam 'grade'." the 'class name' given via parameter list of shell, rest of info in file. so went step step. first printed out awk desired layout awk '{print "dear",$1,$2 "!","\nyour grade on '$class' exam ",$4;}' in.txt works fine. tested if mailing works , does: $ mail -s 'subj' bando < /tmp/msg.txt so need write output textfile can send specific user. this problems kicked in. i've tried several versions, tried printing string file there wrong , don't know what. same echo , cat. tried chopping in smaller pieces still nothing. try awk command read in.txt , send email: class='9th' awk '{msg="dear " $1 " " $2 "!,\nyour grade on '$...

Delete Blocks of Whitespace in Emacs -

i end blocks of code this: public class customfile { public string path; public string name; public customfile (string pathtofile, string dbname) { path = pathtofile; name = dbname; } } i want able put cursor on line above public customfile , able delete of whitespace not including public string name; . there command or macro allow me this? this looks want: c-x c-o runs command delete-blank-lines, interactive compiled lisp function in `simple.el'. bound c-x c-o. (delete-blank-lines) on blank line, delete surrounding blank lines, leaving one. on isolated blank line, delete one. on nonblank line, delete following blank lines.

php - Can programatically PUT to Amazon S3 bucket but not DELETE -

my users can programically upload images aws s3 bucket fine. using same php s3 class include (which contains put case delete case below) -- can't delete file: case 'delete': curl_setopt($curl, curlopt_customrequest, 'delete'); break; so i'm wondering if sharp eye out there can see i'm missing in scripts. i'm not getting error messages. -thanks //this works //include s3 class if (!class_exists('s3'))require_once('s3.php'); //get keys include_once "scripts/s3k.php"; //instantiate class $s3 = new s3(awsaccesskey, awssecretkey); //assigns file location var $filetempname = $destinationfile; //assigns s3 path/file name $filename = $path.$user_id."/".$filename; //move file on s3 if ($s3->putobjectfile($filetempname, $mybucket, $filename, s3::acl_public_read)) { echo " file uploaded"; } ...

java - MVP, JFrame, JDialog : GUI is freezing -

i have main frame (with jframe field) asi view , presenter (created in view's constructor) adds listeners buttons , stuff. this: public static void main(final string[] args) { eventqueue.invokelater(new runnable() { @override public void run() { try { mywindow window = new mywindow(); window.frame.setvisible(true); } catch (exception e) { e.printstacktrace(); } } }); } mywindow invokes in it's constructor 1 method - intialize - creates gui fields. (literally last line of it's code) creates presenter. presenter should show new jdialog on events in main view. has 1 method, that makes gui freeze . looks this: protected double[] getparams(final class<?> indicatorclass) { parametrizabledialog dialog = dialogs.get(indicatorclass); // works list<double> params = new arraylist<...

Add a class to the parent li using jquery -

i add "active" class li when clicked. "active" class should present when click on sub-page of li. for example: <ul class="primarynav"> <li id="first"> <a href="#" id="link1" class="">link1</a> <ul class="megamenu" id=""> <li class="column"><h4 class="special"><a href="#">sub-link</a</h4></li> </ul> </li> <li id="second">link2</li> <li id="third"><a href="#" id="link3" class="">link3</a> <ul class="megamenu" id=""> <li class="column"><h4 class="special"><a href="#">sub-link3</a></h4></li> </ul> </li> </ul> p...

Android unit testing and interfaces -

i have been having quite bit of trouble implementing unit testing on android. simple test, i've been trying match string retrieved string resources: string mystring = myactivity.getresources().getstring(r.string.teststring)); however, when unit testing invariably results in null pointer exception. includes robolectric junit implementation delivered android sdk. one possible solution approach retrieval of resources in manner similar data access object. is, create interface through string resources accessed. allow me mock access string resource. similarly, separate non-android dependent behavior of, say, activity, separate pojo class. allow me run unit tests using standard java testing tools. in fact, potentially delegate android infrastructure related activity interface. this seems lot of jumping through hoops unit testing. worth it? there more viable approach? it turned out, problem activity has gotten in actual test method. so, example, method looks this: pu...

testing - How to access views defined with a specific [plone.]browserlayer in test cases -

i'm new testing , i'm trying create test plone product first time. i'm on plone 3.3. the basic test suite works, can execute without errors. followed documentation : http://plone.org/documentation/kb/testing ...except i'm writing tests in python classes instead of doctests. my problem cannot seem access views defined in app (i componentlookuperror). the problem seems "browserlayer" defined applications. when remove layer="..." attribute configure.zcml, test can access views without problem. however, if add back, doesn't work. guess that's because de browserlayer interface doesn't applied request. the reference problem found in tests googlesitemap : http://dev.plone.org/collective/browser/googlesitemap/googlesitemap.common/trunk/googlesitemap/common/tests?rev= the author seems have made custom zcml file test, in layer="..." attribute has been removed. (which work seems bad having maintain separate zcml file tests) ...

c++ - problem blending properly in openGL -

i'm trying draw 2d character sprite on top of 2d tilemap, when draw character he's got odd stuff behind him. isn't in sprite, think blending. this how opengl set up: void initgl(int width, int height) // call right after our opengl window created. { glviewport(0, 0, width, height); glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); // clear background color black glcleardepth(1.0); // enables clearing of depth buffer gldepthfunc(gl_less); // type of depth test gldisable(gl_depth_test); // enables depth testing //glshademodel(gl_smooth); // enables smooth color shading glenable(gl_texture_2d); // enable texture mapping ( new ) glshademodel(gl_flat); glmatrixmode(gl_projection); glenable(gl_blend); glblendfunc(gl_one , gl_one_minus_src_alpha); glhint(gl_perspective_correction_hint, gl_nicest); glalphafunc(gl_greater, 0.5f); glmatrixmode(gl_p...

process - Maintaining a long-running task on Linux -

my system includes task opens network socket, receives pushed data network, processes it, , writes out disk or pings other machines depending on messages. task intended run forever, , service designed have task running. crashes. what's best practice keeping task alive? assume it's okay task dead 30 seconds before restart it. some obvious ideas include having watchdog process checks make sure process still running. watchdog triggered cron . how know if process alive or not? write pidfile? touch heartbeat file? ideal solution wouldn't continuously spin more processes if machine gets bogged down point watchdog running faster heartbeat. are there standard linux tools this? can imagine solution uses message queue, i'm not sure if that's idea or not. depending on nature of task wish monitor, 1 method write simple wrapper start task in fork(). the wrapper task can waitpid() on child , restart if terminated. this depend on modifying source ...

ios - What collection class should I use? -

at moment, iphone app uses nsmutablearrays hold onto nsstrings. have more information want associate each entry in each array. example, had 1 thing put in array1[0], string. now, however, along string want associate string , integer. guess like: old: [string] new [string, string, integer] i thinking of using dictionary i'm not sure if it's right. advice? the elements in nsarray dictionaries, c structs , or objective-c objects. a dictionary works, can cumbersome if you’re storing primitive data type values (need boxed, e.g. nsnumber ) or there’s potential extending data in deeper levels (dictionary containing dictionary containing dictionary). also, dictionary objects not implicitly typed. a c struct works needs boxing, , don’t benefit cocoa collection semantics regard memory management — have on own. also, there’s no implicit support copy/retain semantics struct members. i declare objective-c class aggregate data types stored in collections such nsa...

database - Uploading Large Video Files to server, solution? -

i have spent hours reading how upload large files server. these video files in hundreds of megabytes, , in .mp4 format. my first attempt using php processing post, not working files above 2 megabytes due restrictions in php.ini , httpd.conf. some users increasing these limits levels needed, , hoping upload work. some websites seem using flash uploaders, ones have tried have been difficult, , never explicitly mentioned if solved upload size problem. i have looked @ ftp using php client, examples found transferring file ftp server after had been posted. ftp using separate client out of question, file name , related data stored in database. currently, operating on localhost, , site served box have physical access to, still wary of increasing max_upload_size , related requirements because want move hosted service. what best solution? there way upload large files strictly through php , html? if not, best solution upload large files while still being able pass filename databa...

Rails + Devise - Is there a way to BAN a user so they can't login or reset their password? -

i have lot of users devise , want ban few problem makers. devise have support built in? thanks i implemented in project myself. did similar kleber above, defined in app/controllers/sessions_controller.rb (overriding devise)... class sessionscontroller < devise::sessionscontroller protected def after_sign_in_path_for(resource) if resource.is_a?(user) && resource.banned? sign_out resource flash[:error] = "this account has been suspended violation of...." root_path else super end end end and added boolean column users called 'banned,' moderators check checkbox when editing user in backend, , boolean return true. but there 1 flaw...if user logged in , banned, still had access doing stuff on site (comments, etc) @ least until session expired or logged out. did in app/controllers/application_controller.rb... class applicationcontroller < actioncontroller::base before_filter :banned? def ba...

android - Emulator Schmemulator -

the more developer android apps, more discover inconsistencies between emulators , real devices, have others, i'm sure. (the latest frustration comes after spending hours chasing app widget ghosts. ghosts appear on emulator, don't otherwise appear on of real devices have access to.) has come across repositories (e.g., wikis, blogs, forums) of known emulator shortcomings? i'd rather spend little time reading known problems, many hours more chasing them in circles. -- part of answer: one can query the android issues database "emulator", not matches emulator problems - have word "emulator" in title or description.

flash - square bracket before class definition in as3 -

i've seen embed tag used before class definition, saw keith using these.. [event(name="select", type="flash.events.event")] [event(name="close", type="flash.events.event")] [event(name="resize", type="flash.events.event")] public class window extends component{ can tell me does? most importantantly, flex compiler uses when interpreting mxml. metadata, asdocs & code completion implementations use show available events, thats it. its in docs here: http://livedocs.adobe.com/flex/3/html/help.html?content=createevents_3.html hope helps! (answer edited more accurate)

android - is there one way to turn on code assist in animation xml -

eclipse give me experience in code assistence.but when comes animation xml files , enter alt+/,it pop nothing.so make me easy type wrong attribute name because of poor english.can give me hand? thanks. make sure animation xml file location in anim folder not animation folder

mysql - dynamic or pre calculate data -

a bit new programming , had general question thought of. say, have database bunch of stock information , 1 column price , earnings. price/earning ratio, better calculate everyday or calculate on demand? think performance wise, it'd quicker read i'm wondering if math type functions worth batch job pre-calculate it(is noticeable?). so how professionals it? have application process data them or have available in database? the professionals use variety of methods. depends on you're going for. new real ratios need displayed immediately ? how core data changing? ideally calculate ratio time price or earning changes, takes development, , it's not worth if don't have substantial amount of activity on site. on other hand, if you're receiving hundreds of visits every minute, you're going want cache whatever you're calculating, time required re-display cached result less recreating result (in scenarios). however, general rule of thumb, don...

Can't create iPad XIB with Xcode 4 -

Image
alright, have problem on hands. i'm trying convert project universal app iphone , ipad. i'm trying make ipad-specific versions of xib files. it's not possible create ipad version using autoresizing masks in xcode 4, assumed i'd able pop xib xcode 3's version of ib, , let magic. no dice. here's error when try open xib file in ib: to honest don't know proceed here. guess resize views manually, that's quite tedious , don't have time doing that. ideas? alright, figured out rather convoluted workaround. first of all, duplicate original project , select project info. right-click on target, , select "duplicate". xcode pop message. select "duplicate , transition ipad". now xcode converts xib files you, , presents ipad resources folder. now open these xib files in finder, , append ~ipad after file name. after doing so, copy these xib files original project, , turn project universal project se...

pascal - How to convert machine code to assembly code? -

please suggest me how convert machine code assembly code? excluding intel reference manual , dos debugger method? you can use debugger, such gdb, or disassembler, such ida pro advanced. there opensource ones, such agner fog's objtool. ida pro advanced has hexrays plugin, can decompile code.

access vba - Null values for variables in VBA -

how define null string, date or integer in vba? i need able assign null value fields records when data incomplete or irrelevant, if declare variable string, date or integer, errors when trying assign null value. is solution use variant? if so, point of other datatypes in vba? dim x variant x = null only variant data type can hold value null . a variant special data type can contain kind of data [...] variant can contain special values empty, error, nothing, , null . the "point" of other data types precisely cannot contain ol' kind of data. has 2 advantages can think of: it's more difficult programmer assign data of unintended type variable mistake, since detected @ compile time. can prevent bugs , make things clearer , next person maintaining code. narrow data types save storage space. putting integers in variant (16 bytes) takes way more memory putting them in int (2 bytes). becomes significant if have large arrays. of course, varia...

cocoa touch - settings bundle - default value behaviour? -

i have created settings bundle single preference value, text field default value. when application launches , retrieve value null. have manually code value use before user has provided value? also if user preferences screen , enters text field leave without making changes value not set ... user has change value saved, correct? no, don't that. there's function this: id userdefaults = [nsuserdefaults standarduserdefaults]; [userdefaults registerdefaults: defaultsettings]; you can build parameter iterating sub keys of preferencespecifiers in settings plist file. something this: - (nsdictionary *)readdefaultsettingsfromplist: (nsstring *)inpath; { id mutable = [nsmutabledictionary dictionary]; id settings = [nsdictionary dictionarywithcontentsoffile: inpath]; id specifiers = [settings objectforkey: @"preferencespecifiers"]; (id prefitem in specifiers) { id key = [prefitem objectforkey: @"key"]; id valu...

flash - Calling ActionScript from Python. Is that possible? -

if swf file embedded in html easy call actionscript methods via externalinterface using javascript. want use swf file outside of browser , still able access methods, want use python call actionscript. possible? there little information in internet. can use amf (pyamf) this, can i? thanks in advance. if want use swf in such manner outside browser investigate air or localconnection. [edit] can use python listen externalinterface events. osflash.org has into, albeit little outdate: http://osflash.org/ext_howto or example python: def externalcall(self,evt): print "externalcall", evt.request ret = "<object><property><string>sample data</string></property></object>" self.movie.setreturnvalue(ret)

entity framework - EF Code First Parent-Child insertions with identity columns -

i have following model. class parent { int parentid (identity column) { get; set; } string parentname { get; set; } virtual icollection<child> children { get; set; } } class child { int childid (identity column) { get; set; } string childname { get; set; } int parentid { ; set; } //foreign key parent(parentid) } how insert few rows parent , child in single transaction? want identity generated on parent(say insert row in parent) , insert child rows value? how can achieved using code first? you shouldn't worry value id of parent in order insert child rows. should enough: var parent = new parent { // fill other properties children = new list<child>() } parent.children.add(new child { /*fill values */); dbcontext.parents.add(parent); // whatever context named dbcontext.savechanges(); for record, id's assigned after calling savechanges() , if really need id before inserting child entity can call savechanges() ...

objective c - iPhone: Reading a string from a file is returning the wrong results -

what i'm doing: i reading data off file several times while app runs. use following code so: nsstring *datapath = [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:@"data.txt"]; nsstring *data = [nsstring stringwithcontentsoffile:datapath encoding:nsstringencodingconversionexternalrepresentation error:null]; nsarray *components = [data componentsseparatedbystring:@"|||||"]; the first time called, works expected - array of length 5, each section containing relevant string. what goes wrong: this file never modified. yet, when call same procedure second time (or third, fourth etc) don't same result. instead, array of length 1 returned, containing part of necessary data. why? can't see reason go wrong... appreciated! since file in appbundle means can't modify file @ all. sure that, ever code called, autorelease object retained correctly? if call block of code every time want data, might idea save results of f...

ios4 - Direct Message to more than one person : twitter MGTwitterEngine -

i want send direct message more 1 person single call i using mgtwitterengine and calling function this [requestdict setobject:@"direct_message" forkey:[twitterobj senddirectmessage:@"this test iphone app" to:@"user_id"]]; this sending ok but not able send multiple people , how can tried comma separated user_ids not works thanks amit battan regardless of whether mgtwitterengine supports call looks allows send direct message (dm) more 1 user, twitter api doesn't support call that. the api method behind scenes ( direct_messages/new ) allows authenticating user send dm 1 user only. so, if single call working you, iterate on list of twitter users , send them dm call specified. also, don't have worry rate limiting when sending dm.

.net - Accessing Microsoft hosted CRM 4 using web services -

i'm trying perform proof of concept of integration crm 4.0 project designing. rather installing trial version require setting active directory well, setup trial hosted version here: http://crm.dynamics.com/en-gb/trial-overview i trying establish web services connection getting 401 unauthorised error. of code samples found involve using discoveredservice cannot add web reference in visual studio doesn't find it. asmx file there when accessed in web browser there execute method init. i suppose question is: can hosted microsoft crm solution accessed using crm web services? thanks help, john absolutely, download microsoft crm sdk. contains code samples set this.

python - How to Convert Tuple to Dictionary? -

i'm using python 2.5 , win xp. have tuple below: >>> (none, '{1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12}') >>> a[1] '{1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12}' >>> i want convert tuple a[1] dictionary because want use key , value. pls advise. tq >>> import ast >>> ast.literal_eval(a[1]) {1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12}

html - CSS Height:100% issue -

Image
i'm trying div wrapper surround divs within depending on amount of content height of wrapper grow. i guessed way of doing set height: 100% can see screen grab below, not case. where says 'no :-(' having height: 100% doing ideally wrapper @ bottom says 'yes' , have drawn red line. any appreciated. if using floats, giving container overflow:hidden might fix problem. if no fixed size given div, makes stretch on floated elements. if have absolutely positioned elements inside container, see html/css solution.

silverlight - W7P ListBox doesn't stay scrolled in the emulator -

i have listbox in xaml page windows phone 7 app. starts out empty, populate items once retrieved web service. far works fine - items show in list , seems fine. problem have when try drag list scroll bottom (in emulator): can scroll down, release mouse button list springs top though hadn't scrolled @ all. insights why behave way? <grid x:name="contentpanel" grid.row="2" margin="0,0,0,0" canvas.zindex="0"> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="auto"/> <!-- edit: problem "auto" here should have been "*" --> </grid.rowdefinitions> <!-- removed other element brevity --> <listbox name="infoboardlistbox" grid.row="1" selectionchanged="infoboardlistbox_selectionchanged" margin="0,0,0,0" fontsize="26.667" /> </grid> a...

html - css or xpath selector: elements which have any attribute with specific value -

i want match elements in html dom tree have attribute value "foo". should either css or xpath selector. my naive approach css selector: *[*='foo'] how correct syntax? css not define attribute selector takes wildcard name. xpath, however, does. following expression should work: //*[@*="foo"]

javascript - Dynamic script for submitting a form -

how can write dynamically use on number of forms? function submitform() { if(document.hotelfrm.onsubmit && !document.hotelfrm.onsubmit()) { return; } document.hotelfrm.submit(); } form name="hotelfrm" id="hotelfrm" method="post" action="page1.asp" have @ document.forms . you might want tryout this: function submitforms() { for(var = 0; < document.forms.length; i++) { if(document.forms[i].onsubmit && !document.forms[i].obsubmit()) { return; } document.forms[i].submit(); } } please note didn't check code validity , reasonableness.

jquery - call to php file via ajax not working -

this seems relatively simple question, , pretty new using ajax, saw post being able call php script when onclick event has been triggered. trying destroy session upon user clicking "log out" link, want call logout.php file when onclick event has occurred. problem nothing happens when link clicked. here's code: $(document).ready(function() { // expand panel $("#open").click(function(){ //when user clicks logout button $.ajax({ url: "logout.php" )}; }); }); <div class="tab"> <ul class="login"> <li class="left">&nbsp;</li> <li><?php if(isset($_session['username'])){echo $_session['username'];}else{echo 'hello guest!';}?></li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#...