Posts

Showing posts from May, 2011

asp.net - In javascript how to find the height and width -

i having .aspx , masterpage page. in masterpage loading aspx page . in aspx page design using generating table structure using code-behind server in javascript how find height , width . regards, kumar if you're looking table height , width, should it var tbl = document.getelementbyid('tbldemo'); alert(tbl.offsetwidth + '\n' + tbl.offsetheight);

multithreading - BackgroundWorker thread in ASP.NET -

is possible use backgroundworker thread in asp.net 2.0 following scenario, user @ browser's end not have wait long time? scenario the browser requests page, sendemails.aspx sendemails.aspx page creates backgroundworker thread, , supplies thread enough context create , send emails. the browser receives response composeandsendemails.aspx, saying emails being sent. meanwhile, background thread engaged in process of creating , sending emails take considerable time complete. my main concern keeping backgroundworker thread running, trying send, 50 emails while asp.net workerprocess threadpool thread long gone. if don't want use ajax libraries, or e-mail processing long , timeout standard ajax request, can use asynchronouspostback method "old hack" in .net 1.1 days. essentially have submit button begin e-mail processing in asynchronous state, while user taken intermediate page. benefit can have intermediate page refresh as needed, without worrying ...

asp.net - When to use HtmlControls vs WebControls -

i htmlcontrols because there no html magic going on... asp source looks similar client sees. i can't argue utility of gridview, repeater, checkboxlists, etc, use them when need functionality. also, looks weird have code mixes , matches: <asp:button id='btnok' runat='server' text='ok' /> <input id='btncancel' runat='server' type='button' value='cancel' /> (the above case in event wanted bind server-side event listener ok cancel runs javascript hides current div) is there definitive style guide out there? should htmlcontrols avoided? it might useful think of html controls option when want more control on mark ends getting emitted page. more control in sense want every browser see same markup. if create system.web.ui.htmlcontrols like: <input id='btncancel' runat='server' type='button' value='cancel' /> then know kind of code going emitted. though of t...

iphone - How do I display data in a UITableView cell from an NSDictionary? -

hi received 2000 of datas udp , display values in tableview .what easiest method ? now using 2 nsthreads , 1 thread receive data via udp , stores in nsmutabledictionary.another thread update tableview using these dictionary values. crashes app. here code used i stored received values this nsmutabledictionary *dictitem customitem *item = [[customitem alloc]init]; item.sno =[nsstring stringwithformat:@"%d",sno]; item.time=currenttime; [dictitem setobject:item forkey:[nsstring stringwithformat:@"%d",sno]]; [item release]; delegate method used , used customtablecells display data column vice. - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { return 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [dictitem count]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *identifier = @"customta...

Output all possible SQL statementes in a Rails Application -

i have inherited medium sized rails application , want try optimize right away. want start database ensure indexes placed need forth. therefore need find out possible sql statements activerecord might make can compare database schema , see immediate optimization can made. in short: there equivalent rake routes output possible sql templates? the hard way the rails development log file should contain of sql used during execution of server. grep file select statements - perhaps getting little smarter using regexp. unfortunately you're unlikely ever able process of information therein manage exception a better way use simple monitoring solution alert when request runs (e.g. scout ). @ rails log file see if problem related db. use db tools most dbs alert via log file somewhere if query runs - mysql example has 'slow queries log'.

java - Eclipse: Working with Systemresources -

based on feedback url load resources classpath in java have changed project, include image resources images.jar my project setup now /program.jar /images.jar in code load images using inputstream connectedimage = classloader.getsystemresourceasstream("images/logo.png"); my eclipse setup is /src/... /images/logo.png my problem eclipse cannot find systemresource based on url. in order work, have manually create images.jar containing image folder add images.jar file eclipse project what need how can configure eclipse can use same code load image either images.jar (if run commandprompt) or images folder(if run eclipse)? is there way make eclipse include /images/ folder when creating runnable jar file of program? not include besides refereced jar files , source code. this do: set directory source folder: right click -> build path -> use source folder change structure of images.jar image files on root (not under directory) chang...

python - How would you design a very "Pythonic" UI framework? -

i have been playing ruby library "shoes". can write gui application in following way: shoes.app t = para "not clicked!" button "the label" alert "you clicked button!" # when clicked, make alert t.replace "clicked!" # ..and replace label's text end end this made me think - how design nice-to-use gui framework in python? 1 doesn't have usual tyings of being wrappers c* library (in case of gtk, tk, wx, qt etc etc) shoes takes things web devlopment (like #f0c2f0 style colour notation, css layout techniques, :margin => 10 ), , ruby (extensively using blocks in sensible ways) python's lack of "rubyish blocks" makes (metaphorically)-direct port impossible: def shoeless(shoes.app): self.t = para("not clicked!") def on_click_func(self): alert("you clicked button!") self.t.replace("clicked!") b = button("the label", click=se...

design - Haskell: Custom types with conditions -

i'm haskell newbie , couldn't find answer question. can define types conditions? example, simple user-defined data type be: data mylist = mylist [a] can somehow modify code mylist constructor can take lists number of elements? data mylist = mylist [a] (even (length a)) thank you! no, can't. if it's necessary, write constructor-like function yourself. tomylist :: [a] -> mylist tomylist l | (length l) = mylist l | otherwise = error "length of list has even" or if error-checking occur: tomylist :: [a] -> maybe mylist but depending on use-case, maybe can express through types (e.g. tuples or 2 lists) through runtime-checks.

Open source PDF library for C/C++ application? -

i want able generate pdf ouput (native) c++ windows application. there free/open source libraries available this? i looked @ answers this question , relate .net. libharu haru free, cross platform, open-sourced software library generating pdf written in ansi-c. can work both static-library (.a, .lib) , shared-library (.so, .dll). didn't try myself, maybe can you

com interop - Loading a 32-bit or 64-bit side-by-side COM DLL depending on the bitness with which the application runs -

i have .net application uses com dll, of there both 32bit , 64bit version. have written 2 application manifests make side-by-side com interop work on either 32 bit or 64 bit. here 32-bit version: <?xml version="1.0" encoding="utf-8"?> <assembly manifestversion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyidentity name="myapp" version="1.0.0.0" type="win32" /> <dependency> <dependentassembly> <assemblyidentity type="win32" name="mycomdll_32.dll" version="1.2.3.4" processorarchitecture="x86" publickeytoken="0000000000000000" language="*" /> </dependentassembly> </dependency> </assembly> however, maintaining 2 manifests leads loss of portability: need decide version use when install application. , 6...

c# - Print datagrid values -

in c# win app displayed data's in datagridview, in need print datagrid values same form without using report or crystal report if codes you loop throught rows , collumns send printer?

C#/.NET wrapper for serial port WIN32 Comm API -

Image
i looking way have control possible on serial port in c# application. problem need communicate device has no documentation except old c++ program written control it. i've tried use serialport class communicate device behaviour quite odd (i have repeat of commands, other commands dont work @ all). copy unmanaged program's behaviour, seems impossible serialport class, not provide access low-level functions , structures dcb example. are there low-level wrappers serial communication available .net? maybe use reflection manipulate serialport innacessible members @ runtime? for suggesting @ .net serialport class; frequent stack overflow answer provider on serial related issues, ben voigt, provides excellent insights on why wrapper around winapi turn out better idea using framework provided serialport: ben voigt on .net serialport a must read. he refers winapi wrapper might reveal in future blog posts. if happen, answer original question. also, there seems @ lea...

ImageButton in Android -

can tell me how resize imagebutton fit image exactly..this code tried, image placed @ position locating using android:scaletype can't able reduce size of imagebutton, pls me out in rectifying issue...the code tried ... <imagebutton> android:id="@+id/button01" android:scaletype="fitxy" // have tried values attr android:layout_width="wrap_content" android:layout_height="wrap_content" android:croptopadding="false" android:paddingleft="10dp" android:src="@drawable/eye"> // image(eye) </imagebutton> kinda late, im 'better late never' had same question today, found explained here: http://www.anddev.org/tutorial_buttons_with_niceley_stretched_background-t4369.html

mysql - SQL Recursion -

i have next tables. groups table contains hierarchically ordered groups , group_member stores groups user belongs to. groups --------- id parent_id name group_member --------- id group_id user_id id parent_id name --------------------------- 1 null cerebra 2 1 cats 3 2 cats 2.0 4 1 cerepedia 5 4 cerepedia 2.0 6 1 cms id group_id user_id --------------------------- 1 1 3 2 1 4 3 1 5 4 2 7 5 2 6 6 4 6 7 5 12 8 4 9 9 1 10 i want retrieve visible groups given user. groups user belongs , children of these groups. example, above data: user visible_groups 9 4, 5 3 1,2,4,5,6 12 5 i getting these values using recursion , several database queries. know if possible single sql query improve app performance. using mysql. two things come mind: 1 - can repeatedly outer-join table recursively walk tree, in: select * ...

asp.net - AJAX Partial Page Load? -

i have page results page (you there after submitting search query elsewhere) whit whole bunch of gridviews different type of data objects. obviously, of queries take longer others. how can make each gridview render has data needs? this has been tricky me because must work on postback pageload. also, object data sources fire automatically on page load/postback; i'm not calling methods programatically data. have change this? @gareth jenkins the page execute of queries before returning first update panel, won't save time there. the trick move each of complex gridviews user control, in user control, rid of object datasource crap, , binding in code behind. write bind code binds in situation: if (this.ispostback && scriptmanager.isinasyncpostback) then, in page, programaticly refresh update panel using javascript once page has loaded, , you'll each individual gridview rendering once ready.

c - When are static function variables allocated? -

i have question in allocation of memory static variables. please @ following snippet. #include<stdio.h> #include<conio.h> void fun(); static int a; void main() { fun(); getch(); } void fun() { static int b; } can please explain me when memory allocated static int b in function fun (before main executed or when function located). knew memory static allocated once, want knew when memory allocated it. please explain. i using 64 bit processor, turbo c compiler, windows 7 operating system. memory static variables allocated when program loaded. static variables in function initialized before function called first time.

compact framework - Can another application access a private key stored in a key container using RSACryptoServiceProvider? -

i using rsacryptoserviceprovider generate public/private key pair , using cspparameters object store in key container. my problem after store private key in key container, can application access key container , retrieve private key generated? if yes, security of key compromised isn't it? how avoid this? should encrypt generated private key symmetric encryption algorithm? without using hardware security module, protection set cspparameters.flags field: cspparameters.flags = cspproviderflags.usenonexportablekey | cspproviderflags.useuserprotectedkey; the first flag prevents software "honestly" exporting private key. second requires user interaction gui perform private key operations.

jquery - Code runs multiple times in IE/Opera -

i have problem on page code executing multiple times in ie , opera, though works in ff, chrome , safari. using latest jquery, validation plugin , form plugin. code originates following html: <form action="/case_study/php/survey_submit.php" id="mt_survey" method="post"> ... ... <fieldset id="submit_button_box"> <input id="submit_button" type="submit" value="submit case data" /> </fieldset></form> when click submit button should run following jquery: $('#mt_survey').submit(function() { if ( ($("#mt_survey").valid() == true) || confirm("unfinished form, continue saving temporary?")) { $('#mt_survey').ajaxsubmit({ data: {table: "mt_data"}, target: '#messages', success: function() { $('#messages').fadein('slow'); $( 'html, body'...

c# - Unable to load System.Data.Linq.dll for CodeDom -

i trying dynamicaly compile code using codedom. can load other assemblies, cannot load system.data.linq.dll. error: metadata file 'system.data.linq.dll' not found my code looks like: compilerparameters compilerparams = new compilerparameters(); compilerparams.compileroptions = "/target:library /optimize"; compilerparams.generateexecutable = false; compilerparams.generateinmemory = true; compilerparams.includedebuginformation = false; compilerparams.referencedassemblies.add("mscorlib.dll"); compilerparams.referencedassemblies.add("system.dll"); compilerparams.referencedassemblies.add("system.data.linq.dll"); any ideas? that may because assembly stored in different location mscorlib is. should work if provide full path assembly. convenient way full path let .net loader work you. try this: compilerparams.referencedassemblies.add(typeof(datacontext).assembly.location);

Installing Curl IDE/RTE on AMD processors -

trying move development environment linux. , new curl. can't install ide & rte packages on amd hp pc running ubuntu x64. tried install debian package via package installer , "error: wrong architecture - i386". tried using --force-architecture switch errors out. i'm assuming curl ide run under intel processors? have luck issue , can advise? it's been while since ran linux, try looking x64 version. there x64 x86 compatibility libraries available should make 32 bit programs work situations. the ubuntu forums better place question, however.

iphone - UIWebView and an Encoded HTML String? -

i'm working on iphone project. getting html fragment rss feed , attempting load uiwebview using loadhtmlstring method. the string receiving feed html encoded. when pass webview, displays decoded html, meaning shows tags along content of page. is there way in objective-c decode html prior passing uiwebview? edit: adding example of encoded html: it's long passage, here's snippet: &lt;li&gt;wireless data: wi-fi (802.11b/g), nike + ipod support built in, maps location-based service, bluetooth 2.1 + edr&lt;/li&gt; &lt;li&gt;audio frequency response:&amp;#160;20hz 20,000hz&lt;/li&gt; &lt;li&gt;audio formats supported: &lt;span&gt;aac &lt;/span&gt;(16 320 kbps), protected &lt;span&gt;aac &lt;/span&gt;(from itunes store), &lt;span&gt;mp3 &lt;/span&gt;(16 320 kbps), &lt;span&gt;mp3 vbr&lt;/span&gt;, audible (formats 2, 3, , 4), apple lossless, &lt;...

python - How to iterate across lines in two files simultaneously? -

i have 2 files, , want perform line-wise operation across both of them. (in other words, first lines of each file correspond, second, etc.) now, can think of number of cumbersome ways iterate across both files simultaneously; however , python, imagine there syntactic shorthand. in other words, there simple way adapt the for line in file: so pulls data both files simultaneously? use itertools.izip join 2 iterators. from itertools import izip line_from_file_1, line_from_file_2 in izip(open(file_1), open(file_2)): if files of unequal length, use izip_longest .

Are there any JavaScript live syntax highlighters? -

i've found syntax highlighters highlight pre-existing code, i'd type wysiwyg-style editor. don't need auto-completed functions, highlighting. as follow-up question, wysiwyg editor stackoverflow uses? edit: answer below, found 2 might suit needs: editarea , codepress edit: see question also: https://stackoverflow.com/questions/379185/free-syntax-highlighting-editor-control-in-javascript here interesting article how write one: (even better, gives full source javascript formatter , colorizer.) implementing syntax-higlighting javascript editor in javascript or brutal odyssey dark side of dom tree how 1 decent syntax highlighting? simple scanning can tell difference between strings, comments, keywords, , other code. time wanted able recognize regular expressions, didn't have blatant incorrect behaviour anymore. importantly, handles regex correctly. of interest used continuation passing style lexer/parser instead of more typical ...

How do I get my Java application to shutdown nicely in windows? -

i have java application want shutdown 'nicely' when user selects start->shutdown. i've tried using jvm shutdown listeners via runtime.addshutdownhook(...) doesn't work can't use ui elements it. i've tried using exit handler on main application ui window has no way pause or halt shutdown far can tell. how can handle shutdown nicely? the mentioned jni approach work. you can use jna wrapper around jni make easier use. added bonus (in opinion @ least) faster , more maintainable raw jni. can find jna @ https://jna.dev.java.net/ if you're starting application in start menu because you're trying make behave service in windows, can use java service wrapper found here: http://wrapper.tanukisoftware.org/doc/english/download.jsp

asp.net - Browser WYSIWYG best practices -

i using rich text editor on web page. .net has feature prevent 1 posting html tags, added javascript snippet change angle brackets , alias pair of characters before post. alias replaced on server necessary angle bracket , stored in database. xss aside, common ways of fixing problem. (i.e. there better way?) if have comments on xss(cross-site scripting), i'm sure someone. there's way turn "feature" off. allow user post whichever characters want, , there no need convert characters alias using javascript. see article disabling request validation . means you'll have own validation, sounds of post, seems looking anyway. can disable per page following the instructions here .

sql server - Use Float or Decimal for Accounting Application Dollar Amount? -

we rewriting our legacy accounting system in vb.net , sql server. brought in new team of .net/ sql programmers rewrite. of system completed dollar amounts using floats. legacy system language, programmed in, did not have float have used decimal. what recommendation? should float or decimal data type used dollar amounts? what of pros , cons either? one con mentioned in our daily scrum have careful when calculate amount returns result on 2 decimal positions. sounds have round amount 2 decimal positions. another con displays , printed amounts have have format statement shows 2 decimal positions. noticed few times not done , amounts did not correct. (i.e. 10.2 or 10.2546) a pro float takes 8 bytes on disk decimal take 9 bytes (decimal 12,2) should float or decimal data type used dollar amounts? the answer easy. never floats. never ! floats according ieee 754 binary, new standard ieee 754r defined decimal formats. many of fractional binary parts can neve...

iphone - Does using Quartz layers slow down UITableView scrolling performance? -

i have uiimageview being rounded on custom drawn uitableviewcell: rect = cgrectmake(13, 10, 48, 48); avatar = [[uiimageview alloc] initwithframe:rect]; [self.contentview addsubview: avatar]; calayer * l = [avatar layer]; [l setmaskstobounds:yes]; [l setcornerradius:9.0]; i noticed uitableview scrolling performance decreased little bit. not sure if related rounded corners though? rounded corners slow down drawing lot. mask layers faster. "baking" corners content (as image or using clipping path in drawrect: ) faster still. allocating new views/layers slow down scrolling--reuse them wherever can (creating uitableviewcell subclass creates subviews in init , destroys them in dealloc works well) that being said, adding additional views shouldn't reduce performance noticeably.

JavaScript sqlite -

best recommendations accessing , manipulation of sqlite databases javascript. well, if working on client side javascript, think out of luck... browsers tend sandbox javascript environment don't have access machine in kind of general capacity accessing database. if talking sqlite db on server end accessed client end, set ajax solution invokes server side code access it. if talking rhino or other server side javascript, should host language's api access sqlite (such jdbc rhino). perhaps clarify question bit more...?

version control - How to modify the default Check-in Action in TFS? -

the default check-in action work-item "resolve". i'd set "associate" work item isn't automaticaly closed if check-in stuff fast. how can that? yup, check-in action can associated state transition (i.e. active resolved). in blog post fredrick linked ( http://www.woodwardweb.com/vsts/top_tfs_tip_3_r.html ) talk how remove that. you'll need customize work item in team project make happen. on see http://msdn.microsoft.com/en-us/library/ms243849(vs.80).aspx

Knowing which java.exe process to kill on a windows machine -

when java based application starts misbehave on windows machine, want able kill process in task manager if can't quit application normally. of time, there's more 1 java based application running on machine. there better way randomly killing java.exe processes in hope you'll hit correct application eventually? edit: thank people pointed me sysinternal's process explorer - i'm looking for! download sysinternal's process explorer . it's task manager more powerfull windows's own manager. one of it's features can see resources each process using (like registry keys, hard disk directories, named pipes, etc). so, browsing resources each java.exe process holds might determine wich 1 want kill. find out looking 1 that's using log file directory.

php - File_get_contents not working? -

i using cakephp. trying data facebook using file_get_contents. warning. warning (2): file_get_contents() [function.file-get-contents]: url file-access disabled in server configuration warning (2): file_get_contents( https://graph.facebook.com/xxxxxxx/?access_token=111978178xxxxxx|2.lg65a3c0atficnsfcf7rog__.3600.12799xxxx-1000 is there way data? i appreciate help. thanks. this configuration issue on server. in php.ini have allow_url_fopen = off if want allow this, set on. aware though reason it's turned off default it's more secure. a common alternative use curl instead; might want check if hosting environment offers that.

c# - .Net 2+: why does if( 1 == null ) no longer throw a compiler exception? -

i'm using int example, applies value type in .net in .net 1 following throw compiler exception: int = somefunctionthatreturnsint(); if( == null ) //compiler exception here now (in .net 2 or 3.5) exception has gone. i know why is: int? j = null; //nullable int if( == j ) //this shouldn't throw exception the problem because int? nullable , int has implicit cast int? . syntax above compiler magic. we're doing: nullable<int> j = null; //nullable int //compiler smart enough if( (nullable<int>) == j) //and not if( == (int) j) so now, when i == null get: if( (nullable<int>) == null ) given c# doing compiler logic calculate anyway why can't smart enough not when dealing absolute values null ? i don't think compiler problem per se ; integer value never null, idea of equating them isn't invalid; it's valid function returns false. , compiler knows; code bool oneisnull = 1 == null; compiles, gives comp...

c# - Posted files not able to get the file name with path -

the problem having on when compile , run locally works fine (i.e "file.filename" give me file file name path) when run same code local iis doesnt work (i.e "file.filename" give me file name). can please tell me whats going on. foreach (string inputtagname in request.files) { httppostedfilebase file = request.files[inputtagname]; //file file; if (file.contentlength > 0) { string filepath = file.filename; .......... } ........ } msdn says: when overridden in derived class, gets qualified name of file on client. if want save file, following might help, inside if check. var filename = path.combine(request.mappath("~/app_data"), path.getfilename(file.filename)); file.saveas(filename);

delphi - Microsoft speech api 5.1 GetVoices returns voices that don't exist on Windows 7 -

i'm migrating xp windows 7 64 bit. app compiled on xp machine works on xp. when run exe on w7 machine, list of voices returned getvoices follows: microsoft anna microsoft mary microsoft mike sample tts voice. checking w7 speech properties dialog shows microsoft anna loaded on machine. checking registry @ hkey_local_machine/software/microsoft/speech/voices confirms this. recompiling app on new windows 7 development machine creates exe duplicate above behavior. (the xp compiled code , w7 compiled code reproduce same error when executed under w7) i'm developing in delphi 7 on windows 7 64 bit , i'm using microsoft speech object library (version 5.4) (note: 5.4 shows in import type library list). i installed speechsdk51.exe onto w7 machine. came from: http://www.microsoft.com/downloads/details.aspx?familyid=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en the following code produces list of 4 voices on windows 7 though there should 1 voice: proc...

c# - Padding (left, top, right, bottom) in WPF -

what want have button bit of left , right padding. can set minwidth val, if content changed may not enough. <button minwidth="75" padding="2" content="it speaks!" /> is possible simulate padding.left/right in wpf? i believe both margins , padding work thickness, can either described single integer or list of four: padding="3, 10, 30, 10" instance. the order left, top, right, bottom - annoyingly not same css.

Joomla URL: Using format: www.xyz.com/section/category/article -

i'm new joomla, , have switched on sef urls. however, issue returns links in format: www.site.com/category/article i'd return articles in format: www.site.com/section/category/article i've searched stack overflow , haven't found answer...wondering if help. thanks in advance. like i've read @ http://docs.joomla.org/sef_urls_in_joomla!_1.5 had change htaccess.txt .htaccess. clear, because url-format formatted mod_rewrite module. if want yourself, recommend reading http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html , learn how use rewrite-rules. can customize urls how like. rewrite-rules in .htaccess file.

python - What's a good resource for starting to write a programming language, that's not context free? -

i'm looking write programming language fun, of resource have seen writing context free language, wish write language that, python, uses indentation, understanding means can't context free. a context-free grammar is, simply, 1 doesn't require symbol table in order correctly parse code. context-sensitive grammar does. the d programming language example of context free grammar. c++ context sensitive one. (for example, t*x declaring x pointer t, or multiplying t x ? can tell looking t in symbol table see if type or variable.) whitespace has nothing it. d uses context free grammar in order simplify parsing it, , simple tools can parse (such syntax highlighting editors).

browser - Java Applet crashes .NET Webbrowsercontrol -

in our application have java applet running inside .net browser control. know issue sun running applet way may crash control. has come across same problem , solved it? atm running applet in webbrowser need run in browser control. thx help. after time problem solved itself. indeed bug in java runtime fixed sun. make sure jre > 1.6.10.

java - Filter on current date within Castor OQL -

i'm running java cocoon 2 , castor oql. i'm trying filter oql query today's date, can't seem figure out (or find in google) syntax of date. database mysql, oql mapped java classes... doing search on field_date >= now() doesn't work. ideas? can't stand limitations of site, it's have work with. it's been while since used cocoon, can't have great answer you. since question has been stagnating, couple of points suggest;-) syntax should matter if coding literal sql string. under impression castor can bind variables (and let oql select appropriate format). i.e. " field_date >= ?", mydateval the castortransformer seemed make brief appearance in 1 specific version of cocoon, , afaik not in latest. if have control on cocoon version running, might want @ upgrading , alternatives castortransformer

numpy - adjusting heights of individual subplots in matplotlib in Python -

Image
if have series of subplots 1 column , many rows, i.e.: plt.subplot(4, 1, 1) # first subplot plt.subplot(4, 1, 2) # second subplot # ... how can adjust height of first n subplots? example, if have 4 subplots, each on own row, want of them have same width first 3 subplots shorter, i.e. have y-axes smaller , take less of plot y-axis of last plot in row. how can this? thanks. there multiple ways this. basic (and least flexible) way call like: import matplotlib.pyplot plt plt.subplot(6,1,1) plt.subplot(6,1,2) plt.subplot(6,1,3) plt.subplot(2,1,2) which give this: however, isn't flexible. if you're using matplotlib >= 1.0.0, using gridspec . it's quite nice, , more flexible way of laying out subplots.

pointers - Manipulating data members (C++) -

i have method takes object argument. both caller , argument have same members (they instances of same class). in method, particular members compared , then, based on comparison, 1 member of argument object needs manipulated : class object { // members public: somemethod (object other) { int result; member1 - other.member1 = result; other.member2 = other.member2 - result; } the thing doesn't change other.member2 out of scope, , change needs permanent. so yes, sorry: need advice on pointers... have looked online , in books, can't working. figure 1 of @ , know answer in 30 seconds. have rftm , @ stupid loss. not encouraging. thanks everyone! this because passing value (which equates passing copy. think of making photocopy of document , asking them make changes, still have original changes make won't reflected in copy when back. but, if tell them copy located, can go , make changes see next time go access it). need pass either refer...

CSS Border Help -

using current css , not css3, there way of specifying raised type border style somehow emphasize menu. after border has has rounded edge, not rounded corners. thanks. with css 2.1 , prior can use double, ridge, groove, inset, or outset. i've put simple demo file play around , test various border styles available you. <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>border styles</title> <style type="text/css" media="screen"> body { background: #999; } div { background: #eee; float: left; margin: 10px; padding: 10px; height: 100px; width: 100px; } .double { border: 4px double #ccc; } .ridge { border: 4px ridge #ccc; } .groove { border: 4px groove #ccc; } .inset { border: 4px inset #ccc; } .outset { border: 4px outset #ccc; } </style> </head> <body> <div ...

MySQL Limit, Group, and AVG Query -

here's puzzler you: i'm keeping stats of cluster computing stuff in mysql table named 'jobs'. each job row has host job executed on (not unique), job execution time in seconds, , unique integer pk can order completed jobs ordering pk. as of right now, using average , group by, can find average execution time in seconds each host on of jobs completed. instead of averaging execution times per host, want average time of last 5 jobs per host. there's sorts of examples operations , group by, , lots of examples operations limit, there way of combining 2 in straightforward mysql query? edit: in event i'm not clear it, want average 5 execution times host 1, , average 5 execution times host 2, etc. my initial reaction use limit restrict average 5 results, led me suggest: select a.host, avg(a.execution_time) (select id, execution_time, host jobs order id desc limit 5) group a.host; but clear limits average recent 5 jobs, , not recent 5 jobs pe...

c++ - Control for getting hotkeys like tab and space -

i have dialog box allows users set hotkeys use in 3d program on windows. i'm using chotkeyctrl, pretty good, doesn't handle keys users use - specifically, tab , space. the hotkey handling smart enough able fire on keys, need ui let them set. control similar chotkeyctrl ideal, other workarounds appreciated. one workarounds option use stock standard edit control message hook function. this allow trap keyboard wm_keydown messages sent edit control. the hook function this: lresult callback messagehook(int code, wparam wparam, lpmsg lpmsg) { lresult lresult = 0; if ((code >= 0) && (code == msgf_dialogbox)) { if (lpmsg->message == wm_keydown) { //-- process key down message lresult = 1; } } // default processing if required if (lresult == 0) { lresult = callnexthookex(messagefilterhook, code, wparam, (lparam)lpmsg); } return lresu...

c++ - Allocate chunk of memory for array of structs -

i need array of struct allocated in 1 solid chunk of memory. length of "char *extension" , "char *type" not known @ compile time. struct mimetype { char *extension; char *type; }; if used "new" operator initialize each element itself, memory may scattered. how tried allocate single contiguous block of memory it: //numtypes = total elements of array //maxextension , maxtype needed lengths (char*) in struct //std::string ext, type; unsigned int size = (maxextension+1 + maxtype+1) * numtypes; mimetypes = (mimetype*)heapalloc(getprocessheap(), heap_zero_memory, size); but, when try load data in this, data out of order , scattered when try access later. for(unsigned int = 0; < numtypes; i++) { //get data file getline(fin, line); stringstream parser.str(line); parser >> ext >> type; //point pointers @ spot in memory allocated mimetypes[i].extension = (char*)(&mimetypes[i]); mimetypes[i].type = (char*)((&mimetypes[i]...

How to get Https URL content -

i have https link requires user login & password. if run in fx this: https://usernameassword@www.example.com/link/sublink it return xml data expected. however, i'm trying do, automate process. try use file_get_contents in php fsocket in php i try ajax, still.. doesn't work. and try content (xml) either in server or in front-end (ajax), both don't work. does know need go in order content? need obtain ssl certificate? solution in ohter languages welcome too. use libcurl via java bindings .

winforms - How can I export the data in a DataGridView data to an Excel spreadsheet? -

in winforms application, want export data datagridview excel spreadsheet. is job of looping , outputting results comma seperated? is job of looping , outputing results comma seperated? yes. simpler way without dependencies. if need more control, can automate excel vb.net or c# ..

c# - MVC How to create dynamic DataTable? -

public string defstring { set; private get; } private string path = "http://someuri.org/search?par1=15&par2=55"; public string getanswer() { webrequest myrequest = webrequest.create(path); webresponse myresponse = myrequest.getresponse(); streamreader sr = new streamreader(myresponse.getresponsestream(), system.text.encoding.default); return sr.readtoend(); } my function getanswer() returns string this: (function(){if (typeof samo === "undefined") { samo = {}; }samo.root_url = '/search_tour?';samo.jquery(samo.controls.resultset).html('<table class=\"res\"><thead><tr><th>datacolum1</th><th>datacolum2</th><th class=\"c\">datacolum3</th><th>datacolum4</th><th class=\"c\">datacolum4</th></tr></thead><tbody><tr class=\"red_row\" samo:townfrominc=\"557\"><td nowrap>data1</...

javascript - Handling Scroll bars with jQuery event Drag and Drop -

i have room div toy divs arranged on it, see alt text http://i27.tinypic.com/2rwt4t5.jpg toys absolutly positioned , drag-able in walls of room . room container div has fixed height , height, room has horizontal vertical scrolls. use jquery event drag plug-in setting dnd. managed set toys drag in lomits of wall, when there scrolls, component moving little ouside wall (only actual width of wall). i want show portion of toy shown below alt text http://i30.tinypic.com/jac19i.jpg i tried setting z-index , has no effect, 1 has better idea? withouth seeing actual code, guess overflow:hidden solve this?

tsql - How to gain exclusive access to SQL Server 2005 database to restore? -

whenever restore backup of database in sql server presented following error: msg 3101, level 16, state 1, line 1 exclusive access not obtained because database in use. msg 3013, level 16, state 1, line 1 restore database terminating abnormally. usually around restart server. fine when developing on our local instance on our development machines. have few programmers need access database, , logistics of having script changes , drop them subversion becoming nightmare. regardless our simple solution put on shared server in office , backup server in case screwed data. well, screwed data , needed restore. unfortunately, have co-worker in office working on project , using same database server development. nice i'd restore without restarting sql server , possibly disrupting work. is there way script in t-sql able take exclusive access or drop connections? you can force database offline , drop connections with: exec sp_dboption n'yourdatabase', n'offline...

Splitting a semicolon-separated string to a dictionary, in Python -

i have string looks this: "name1=value1;name2=value2;name3=value3" is there built-in class/function in python take string , construct dictionary, though had done this: dict = { "name1": "value1", "name2": "value2", "name3": "value3" } i have looked through modules available can't seem find matches. thanks, know how make relevant code myself, since such smallish solutions mine-fields waiting happen (ie. writes: name1='value1=2';) etc. prefer pre-tested function. i'll myself then. there's no builtin, can accomplish generator comprehension: s= "name1=value1;name2=value2;name3=value3" dict(item.split("=") item in s.split(";")) [edit] update indicate may need handle quoting. complicate things, depending on exact format looking (what quote chars accepted, escape chars etc). may want @ csv module see if can cover format. here...

jquery - Flexigrid with IE6 show only headers -

i'm using flexigrid jquery-1.2.3.pack.js . works fine firefox when try ie6, shows headers. i've found discussion on same bug, , says comment line flexigrid.js : if (p.width!='auto') g.gdiv.style.width = p.width + 'px'; tried dont show grid. dont know why, downloading again flexigrid.js file , commenting line said above works perfectly... bit slow on ie6, no bugs feature.

how can i use mailComposer in iPad as well as iPhone? -

i have implemented mail composer iphone , it's working fine want use mail composer in ipad should change or please guide me how can implement mail composer in ipad?if possible please give me sample code that.thanks in advance.. hi!i have implemented code , can implement writing below code: mfmailcomposeviewcontroller *mailcontroller = [[mfmailcomposeviewcontroller alloc] init]; mailcontroller.mailcomposedelegate = self; mailcontroller.modalpresentationstyle = uimodalpresentationfullscreen; [mailcontroller setsubject:@"hello iphone"]; [mailcontroller setmessagebody:@"please find attachment...." ishtml:no]; mydata = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:[imgurl objectatindex:offsetx]]]; uiimage *pic = [[uiimage alloc] initwithdata:mydata]; nsdata *exportdata = uiimagejpegrepresentation(pic ,1.0); [mailcontroller addattachmentdata:exportdata mimetype:@"image/jpeg" filename:@"picture.jpeg"]; [self pres...

asp.net - Redirecting page depending on query string -

i have page a, b , c. in page load of c, have used query string parameter display tables depending on came from, either or b. page c has cancel button. when user clicks cancel, has check came , should redirect same page, mean either or b. not @ sure how use query string redirecting. please me out!! thanks! you can use redirect base on querystring: var pagetoredirectto = "default.aspx"; switch(request.querystring["param"]) { case "a": pagetoredirectto = "pagea.aspx"; break; case "b": pagetoredirectto = "pageb.aspx"; break; } response.redirect(pagetoredirectto);

python - Are object literals Pythonic? -

javascript has object literals, e.g. var p = { name: "john smith", age: 23 } and .net has anonymous types, e.g. var p = new { name = "john smith", age = 23}; // c# something similar can emulated in python (ab)using named arguments: class literal(object): def __init__(self, **kwargs): (k,v) in kwargs.iteritems(): self.__setattr__(k, v) def __repr__(self): return 'literal(%s)' % ', '.join('%s = %r' % in sorted(self.__dict__.iteritems())) def __str__(self): return repr(self) usage: p = literal(name = "john smith", age = 23) print p # prints: literal(age = 23, name = 'john smith') print p.name # prints: john smith but kind of code considered pythonic? have considered using named tuple ? using dict notation >>> collections import namedtuple >>> l = namedtuple('literal', 'name age')(**{'name': ...

nhibernate - Generic Functions in VB.NET -

i'm not familiar generics (concept or syntax) in general (short of using them in collections , not), wondering if following best way of accomplishing want. actually, i'm not entirely positive generics solve problem in case. i've modelled , mapped few dozen objects in nhibernate, , need sort of universal class crud operations instead of creating seperate persister class each type.. such as sub update(someobject object, objecttype string) dim session isession = nhibernatehelper.opensession dim transaction itransaction = session.begintransaction session.update(ctype(someobject, objecttype)) transaction.commit() end sub where someobject can different types. know isn't best way of doing (or if it'll work) i'm hoping can steer me in right direction. the key issue here is: session.update take parameter? if session.update allows generic object, i'd use that: sub update(of t)(byval someobject t) dim session isession = nh...

linux - how do you manage servers' root passwords -

in our administration team has root passwords client servers. should if 1 of team members not longer working us? still has our passwords , have change them all, every time leave us. now using ssh keys instead of passwords, not helpful if have use other ssh. the systems run have sudo -only policy. i.e., root password * (disabled), , people have use sudo root access. can edit sudoers file grant/revoke people's access. it's granular, , has lots of configurability---but has sensible defaults, won't take long set up.

iPhone Testing Microphone Using Emulator -

can test voice recording using iphone emulator or need actual device? yes - if have microphone on mac emulator audio microphone. imacs , macbooks have 1 built in - other models may have plug in external microphone.

Visual FoxPro 9 compatibility with Windows Vista -

what compatibility issues have found when developing visual foxpro 9 on windows vista? my company has no current plans move vista, haven't tested compatability issues yet. doug hennig has excellent article on subject however: http://my.advisor.com/articles.nsf/aid/18897 these links describe issues well: http://fox.wikis.com/wc.dll?wiki~vistaaeroissues~vfp http://fox.wikis.com/wc.dll?wiki~sp2problemwithvistaandborderstyle~vfp

How can I track a user events in Django? -

i'm building small social site, , want implement activity stream in users profile display event's commenting, joining group, posting something, , on. basically, i'm trying make similar reddit profile shows range of user activity. i'm not sure how i'd in django though. thought of maybe making "activity" model that's onetoone account, , update through middleware. anyone here have suggestion? away implement in nice way? in opinion, should you're saying, create model activity, has foreignkey user populate triggering things you'll find 'interesting'. this practice, if redundant, speed page generation, , can add custom field hold text want display, , can keep track of generate activity.

security - Have Java Web Service execute under different context -

we have java 1.4 web service running on aix 5. want have web service methods execute under context of caller, not hosting web server. how go this? you should able perform jaas authentication (just normal j2ee web application), establish principals associated subject. container automatically ensures current worker thread associated identified subject. subject , principals propagated down service/business tier case normal servlet. it might worthwhile determine web service security features of underlying application server, might offer more features basic/digest/form authentication functionality present in jaas. example, weblogic server allows certificate based authentication of web service clients (with configuration involved), , might true of application server you're using well. usually, container security features ride on top of jaas , related security features in j2ee 1.4, thereby ensuring j2ee security features used in other sections of application continue perfor...

jquery - Call action of another controller and return its result to View -

i have scenario need following functionality: in view have call as: $.ajax({ type: "post", async: false, datatype: 'json', url: "controllera/actiona", data: { var1: some_value }, success: function (data) { if (data == true) { form.submit(); } else if (data == false) { } }); // in controllera public jsonresult actiona(string var1) { /* manipulation , calculations */ _slist = redirecttoaction("actionc", "controllerb", new { var1 = some_value}); string = _slist.first().tostring(); return redirecttoaction("actionb", "controllerb", new { var1 = var2 }); } // in controllerb public jsonresult actionb(string var1) { /* manipulation , calculations */ return json(false, jsonrequestbehavior.allowget); } public selectlist actionc(string var1) { /* manipulation , calculations */ session["string"] = some_value; retur...

Can you include before/after filters in a Rails Module? -

i wanted add method 2 models, made module , included in both models. module userreputation def check_something ... end end that worked fine. wanted have method called :after_create on models. works if add manually models, wanted smart , include in module this: module userreputation after_create :check_something def check_something ... end end but doesn't work. there way accomplish , dry after_create well? try self.included , called when module mixed class base : module userreputation def self.included(base) base.after_create :check_something end end

aggregators - How do craigslist mashups get data? -

i'm doing research work content aggregators, , i'm curious how of current craigslist aggregators data mashups. for example, www.housingmaps.com , closed www.chicagocrime.org if there url can used reference, perfect! for adravage.com use combination of magpie rss (to extract data returned searches) , custom screen scraping class populate city/category information used when building searches. for example, extract categories could: //scrape category data $h = new http(); $h->dir = "../cache/"; $url = "http://craigslist.org/"; if (!$h->fetch($url, 300)) { echo "<h2>there problem http request!</h2>"; exit(); } //we need category abbreviations (data looks like: <option value="ccc">community) preg_match_all ("/<option value=\"(.*)\">([^`]*?)\n/", $h->body, $categorytemp); $catnames = $categorytemp['2']; //return array of abreviations if(sizeof($cat...

design patterns - How could I improve this C++ code -

i want suggestion on following pseudo-code. please suggest how improve it, whether or not use design patterns. // i'm receiving string containing : id operation arguments data = read(socket); tokens = tokenize(data," "); // tokenize string based on spaces if(tokens[0] == "a") { if(tokens[1] == "some_operation") { // here goes code some_operation , use remaining tokens arguments function calls } else if(tokens[1] == "some_other_operation") { // here goes code some_other_operation , use remaining tokens } ... else { // unknown operation } } else if(tokens[0] == "b") { if(tokens[1] == "some_operation_for_b") { // operation b } else if(tokens[1] == "yet_another_operation") { // yet_another_operation b } ... else { // unknown operation } } i hope point . thing have large number of id's , each has it's own operations , , th...

command line - How can I list files with their absolute path in linux? -

i want generate recursive file listings full paths /home/ken/foo/bar but far can see both ls , find give relative path listings ./foo/bar (from folder ken) it seems obvious requirement can't see in find or ls man pages. if give find absolute path start with, print absolute paths. instance, find .htaccess files in current directory: find `pwd` -name .htaccess find prepends path given relative path file path. greg hewgill suggested using pwd -p if want resolve symlinks in current directory.

design - Best programming methodology for very fast timeline and little requirements? -

what programming methodology custom applications need coded fast , customized? realize lack of requirements problem no matter what. how convince management change practices? next question how people stop writing 5000 line single file programs? there's more 1 question ask. fast development 'little' requirements => hacking using scripting language, assuming there small or few requirements, opposed there no stable or explicit requirements yet there tons in future fast development tons of unstable, or implicit requirements => scrum, xp, etc. focus on prototyping feedback customer wants possible get management change practices => let project crash possible ;-) seriously, requires more specific on want change. mileage depends of course on how dilbert-like environment is, , how cynical achieving goals. getting people stop writing 5k lines programs in single file => show them in way problem you, how equally easy write better structured programs, sh...

csv - python beginner questions -

i installed python i trying run script: import csv reader = csv.reader(open("some.csv", "rb")) row in reader: print row i running on windows. do have type each line individually python shell or can save code text file , run shell? where some.csv have in order run it? in same c:\python26 folder? what code supposed do? you can both! run code text file (such 'csvread.py', extension doesn't matter), type: python csvread.py @ command prompt. make sure path set include python installation directory. "some.csv" needs in current directory. this code opens python file descriptor designed read csvs. reader file descriptor prints out each row of csv in order. check documentation out more detailed example: http://docs.python.org/library/csv.html

database - Store large number of data points? -

what best way store large number of data points? for example temperature values measured every minute on lots of locations? sql databases 1 row per data points doesn't seem efficient. i know why reckon "not efficient". need explain data model , schema give better context of scenario. storing multiple data points single row, when not related each other, , should indeed stand on own, not approach. meshing result in counter-intuitive , quirky query statements pull out correct data points need given scenario. we have done work in power station before, collecting data various systems , metering equipment wide variety of gas , electrical parameters need monitored , aggregated. can come in every 3-5 minutes 30-60 minutes depending on type of parameters. these naturally results in millions of records per month. the key indexing tables physical order tied sequence in records came in. (clustered index) new pages , extents created , filled sequentially incomi...

biztalk - Approach to extract inner-schema XML values for mapping to orchestration's inbound schema -

there several application systems pass messages each other part of work process. due technical constraints revolving transactional integrity, application data , message delivery committed single mainframe db2 database. messages not directly passed biztalk server (2006 r2); bts pull message out db2 database later. the message-queue table in db2 database has several fields. key field message_data column - actual message; xml content itself. when 1 uses db2 adapter query out records table incoming schema like correction update: db2message schema attribute based; mistook element based. <db2message message_data="&lt;internalxml&gt; ........ &lt;/internalxml&gt;" message_date="2008-1-1 00:00:00" message_id="guid" txn_id="guid" .... other attrib /> the orchestration consumes schema <eaimessage> <header> <serviceid> <messageid> .... <mode> </header> <body> <raw...