instruction
stringlengths
0
30k
'Inside the Enter event TextBox1.SelectAll(); Ok, after trying it here is what you want: On the Enter event start a flag that states that you have been in the enter event On the Click event, if you set the flag, call .SelectAll() and reset the flag. This selected all the text on entry, but allowed me t...
'Inside the Enter event TextBox1.SelectAll(); Ok, after trying it here is what you want: - On the Enter event start a flag that states that you have been in the enter event - On the Click event, if you set the flag, call .SelectAll() and reset the flag. - On the MouseMove event, set the entered f...
'Inside the Enter event TextBox1.SelectAll(); Ok, after trying it here is what you want: - On the Enter event start a flag that states that you have been in the enter event - On the Click event, if you set the flag, call .SelectAll() and reset the flag. - On the MouseMove event, set the entered f...
'Inside the Enter event TextBox1.SelectAll(); Ok, after trying it here is what you want: - On the Enter event start a flag that states that you have been in the enter event - On the Click event, if you set the flag, call .SelectAll() and reset the flag. - On the MouseMove event, set the entered f...
[Devel::Size](http://search.cpan.org/perldoc?Devel::Size) is the answer to your question. (Note that Devel::Size will temporarily allocate a significant amount of memory when processing a large data structure, so it's not really well suited to this purpose.) However, [Cache::SizeAwareMemoryCache](http://search.cpan...
GWT-EXT - What is the best way to widgets to a specific ContentPanel after an event?
|gwt|gwt-ext|
first post don't hurt me :) I am using a `BorderLayout` with the usual North, West, Center, South Panels. On the **West** `ContentPanel`, I've got a `Tree`. If an event (`OnClick`)occurs I want a particular dialog box displayed on the **Center** `ContentPanel`. What is the best way for me to do this? Currently I'...
I prefix member variables with 'm' and parameters (in the function) with 'p'. So code will look like: class SomeClass { private int mCount; ... private void SomeFunction(string pVarName){...} } I find that this quickly tells you the basic scope of any variable - if no pre...
I don't think there is a direct way to do this using the OS - it's a feature that may (or may not) be present on the sound card. Some sound cards have a loopback interface - Creative calls it "What U Hear". You simply select this as the input rather than the microphone, and record from it using the normal waveInOpen(...
Although not directly an answer to the OP question, there is a pretty sweet way of finding out what variables are in scope in a function. take a look at this code: >>> def f(x, y): z = x**2 + y**2 sqrt_z = z**.5 return sqrt_z >>> f.func_code.co_varnames ('x', 'y', 'z', 'sqrt_z')...
From http://opengroup.org/onlinepubs/007908775/xsh/fclose.html > The fclose() function will perform a > close() on the file descriptor that is > associated with the stream pointed to > by stream. If you've wrapped your socket in a stream it probably no longer makes sense to shutdown(), at least not without flu...
From http://opengroup.org/onlinepubs/007908775/xsh/fclose.html > The fclose() function will perform a > close() on the file descriptor that is > associated with the stream pointed to > by stream. If you've wrapped your socket in a stream it probably no longer makes sense to shutdown(), at least not without flu...
As per most other servlets, a separate thread is created to process each request. You have to implement the `SingleThreadedModel` interface to get a new instance of the servlet for each request.
Flex - best strategy for keeping client data in synch with backend database?
|apache-flex|remoting|blazeds|
In an Adobe flex applicaiton using BlazeDS AMF remoting, what is the best stategy for keeping the local data fresh and in synch with the backend database? In a typical web application, web pages refresh the view each time they are loaded, so the data in the view is never too old. In a Flex application, there i...
I like CLOS and multimethods. Most, if not all, object-oriented programming languages have the basic notions of classes and methods. The following snippet in Python defines the classes PeelingTool and Vegetable (something similar to the Visitor pattern): class PeelingTool: """I'm used to peel things...
I was under the impression that 2 is just syntax sugar. They should be _exactly_ the same thing.
Number one is just shorthand that will generate the same MSIL as the 2nd one, at compile type it'll look at this.Handle and infer the delegate to instantiate. But you should never unsubscribe by using new. So there is no difference between the 2, just some syntactic sugar to make our code cleaner.
I use Exceptions in python in both Exceptional, and non-Exceptional circumstances. It is often nice to be able to use an Exception to indicate the "request could not be performed", as opposed to returning an Error value. It means that you /always/ know that the return value is the right type, instead of arbitarily N...
In objective-C you can use protocols to achieve the aims of generics. Since the language is weakly typed however, it's generally not as much of a concern as when you are fighting the type system to use one code path for many types.
It's quite likely to just be a stock install. Even then, I'd still want to make the local development environment subtly different to the live php.ini, to ensure that it showed all errors that were being produced (as opposed to hiding, or just logging them on the live site).
If your application has users in multiple time zones, you should always store your times in UTC (any timezone would work, but you should stick with the most common convention). Let the user input in local time, but convert to UTC to store (and compare, and manipulate). Then, convert back from UTC to display in each...
If I remember correctly, the first alternative is merely syntactic sugar for the second.
I don't have any viper or vimpulse tweaks for you, but I do recommend that you try follow-mode. Of course I'd also recommend that you start learning Emacs too. I mean, if you're in this far you might as well go through the tutorial and maybe have a look at emacswiki.
I'll second Capistrano. It's incredibly powerful and flexible. Our current project uses Capistrano for deploying to different servers as well as multiple servers. We pass two arguments to the cap command: 1) the name of the set of machine specific config options to run and 2) the name of the action to run ends up ...
if you use classes, you should free the resources they allocate in their destructors instead, of course. Use the try: on entire application just if you want to free resources that aren't already liberated by your classes' destructors. And instead of using a catch-all except:, you should use the following block: ...
if (x) { print "x is true"; } else { do something else; } I always type braces. It's just a good habit. Compared to thinking, typing is not "work". Note the space before the conditional. That helps it look not like a method call.
[Mox](http://code.google.com/p/pymox/), from Google
**This looks like what you need...** from: [http://msdn.microsoft.com/en-us/library/aa381969(VS.85).aspx][1] ---------- To import a Diffie-Hellman public key and calculate the secret session key 1. Call the `CryptAcquireContext` function to get a handle to the Microsoft Diffie-Hellman Cryptographic Provider....
How do I parse a PHP serialized datastructure in Java?
|java|php|serialization|
ViewState is an option. It is only valid for the page that you are on. It does not carry across requests to other resources like the Session object. Hidden fields work too, but you are leaking and little bit of information about your application to anyone smart enough to view the source of your page. You could ...
LEFT OUTER JOIN Tables2-N on Table1 SELECT Table1.*, Table2.*, Table3.*, Table4.*, Table5.* FROM Table1 LEFT OUTER JOIN Table2 ON Table1.ID = Table2.ID LEFT OUTER JOIN Table3 ON Table1.ID = Table3.ID LEFT OUTER JOIN Table4 ON Table1.ID = Table4.ID LEFT OUTER JOIN Table5 ON Table1.ID = Ta...
I find it easiest to just stay away from all the frameworks and other helpers and just do basic Javascript. This not only lets you understand what's going on under the covers, it also lets you do it in the simplest way possible. There's really not much to it. User the JS XML DOM objects to create an xml document cli...
Ah! Procedural! My SQL would look like this, if you needed to order the results from the other tables after the results from the first table. > Insert Into #rows Select id from Table1 where date between '12/30' and '12/31' > Select * from Table1 t join #rows r on t.id = r.id > Select * from Table2 t jo...
There are two checkboxes in the "Exceptions..." box, I usually have to have them both checked to get it to break on unhandled exceptions. Regardless that it only reads like you need to have one checked.
Ctl-D, E brings up the Exceptions window. You can set what exceptions you want to, and don't want to, break on.
How do you move from the Proof of Concept phase to working on a production-ready solution?
|process|proof-of-concept|
I'm working on a project that's been accepted as a proof of concept and is now on the schedule as an actual production project. I'm curious how others approach this transition. I've heard from various sources that when a project starts as a proof of concept it's often a good idea to trash all of the code written du...
Using a single parameter, EventArgs, for the data passed by an event allows you to add data to your event in future versions of your software without breaking existing consumers. You simply add new members to an existing EventArgs-derived class, or create a derived class with the new members. Otherwise consistency ...
Assuming it is possible, I'd suggest adjusting your SCM standards to allow test harnesses and unit test runners to exist in other projects. Simply mandate that any library project must include a companion test project.
Sorry I should have clarified that I am building debug mode with inlining and all optimization off. Besides, the code is getting removed before inlining even occurs since it's never referenced to even be considered for inlining.
mutable is mainly used on an implementation detail of the class. The user of the class doesn't need to know about it, therefore method's he thinks "should" be const can be. Your example of having a mutex be mutable is a good canonical example.
Try erwin (CA AllFusion ERwin Data Modeler). It supports quite a lot of different DBs, including SQL Anywhere, and is quite good in reverse/forward engineering and schema comparison. However, you may find it a bit too complex to use for the comparison...
I do not unit test private methods. A private method is an implementation detail that should be hidden to the users of the class. Testing private methods breaks encapsulation.
I do not unit test private methods. A private method is an implementation detail that should be hidden to the users of the class. Testing private methods breaks encapsulation. If I find that the private method is huge or complex or important enough to require its own tests, I just put it in another class and make it...
Where does this image "live?" Is it accessible in the local file system or on the web? If so, would suggest having your WebService accepting a URI (can be a URL or a local file) and opening it as a Stream, then using a StreamReader to read the contents of it. Example: public static FetchImage(Uri url) { ...
I have a system that combines the best and worst of Java and PHP. I am trying to migrate a component that was once written in PHP into a Java One. Does anyone have some tips for how I can parse a PHP serialized datastructure in Java? By serialized I mean output from php's serialize function.
With Apache look into mod_proxy. [Apache 2.2 mod_proxy docs][1] [Apache 2.0 mod_proxy docs][2] [1]: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html [2]: http://httpd.apache.org/docs/2.0/mod/mod_proxy.html
It's standard class for storing a pair of values. It's returned/used by some standard functions, like std::map::insert. boost::pair claims to be more efficient: [see here][1] [1]: http://www.boost.org/doc/libs/1_36_0/libs/utility/compressed_pair.htm
It's standard class for storing a pair of values. It's returned/used by some standard functions, like `std::map::insert`. `boost::compressed_pair` claims to be more efficient: [see here][1] [1]: http://www.boost.org/doc/libs/1_36_0/libs/utility/compressed_pair.htm
[Rob Conery's MVC Storefront](http://www.codeplex.com/mvcsamples) As others have said, linq-to-sql is no different to any other ORM so the architecture is the same as you would use for NHibernate and others.
[Cascade][1] supports doing a build on every single change committed to the repository. I would not recommend doing only nightly builds -- that's a pretty long window where a build break can slip in before it's reported. [1]: http://www.conifersystems.com/cascade/
Yes, because when you select a literal it does not need to read from disk (or even from cache).
http://www.charlesproxy.com/ Although not free, will decode AMF binary data and allows to trace SSL connections too.
The common thread in the "architecture" of projects that use functional languages is that they tend to be separated into layers of algebras rather than subsystems in the traditional systems architecture sense. For great examples of such projects, check out [XMonad][1], [Yi][2], and [HappS][3]. If you examine how the...
Some good tips here. One mistake I made earlier on in my career was turning the usability test into a teaching exercise. I'd spend a fair amount of time explaining how to use the app rather than letting the user figure that out. It taught me a lot about whether my applications were easy or hard to use by how puzzl...
I like CLOS and multimethods. Most, if not all, object-oriented programming languages have the basic notions of classes and methods. The following snippet in Python defines the classes PeelingTool and Vegetable (something similar to the Visitor pattern): class PeelingTool: """I'm used to peel things...
This is a technique I found very useful.. [Prevent Denial of Service (DOS) attacks in your web application][1] [1]: http://weblogs.asp.net/omarzabir/archive/2007/10/16/prevent-denial-of-service-dos-attacks-in-your-web-application.aspx
You have 2 things here you need to clean up: the stream represented by `FILE` and the file descriptor represented by the socket. You need to close the stream first, then the file descriptor. So, in general you will need to `fclose()` any `FILE` objects, then `close()` any file descriptors. Personally I have never u...
You have 2 things here you need to clean up: the stream represented by `FILE` and the file descriptor represented by the socket. You need to close the stream first, then the file descriptor. So, in general you will need to `fclose()` any `FILE` objects, then `close()` any file descriptors. Personally I have never u...
I'm not actually targeting chrome, but I have added chrome to my browsers to test sites on. I've found some odd quirks in this product where some plugins cause the browser to hang, or run really slow in some environments, but they are still in beta in active development. But I definately now make sure sites I work on...
I believe this is what you're looking for: http://www.cambiaresearch.com/c4/7cb36a7b-3731-48f6-b91b-1d8c503f140e/What-are-the-aspnet-Named-Colors.aspx
Why <b>not</b> just give up and build/install your own or port versions of perl, apache2, and mod_perl2? Probably easier than fighting with it. (Worked for me.)
Why <b>not</b> just give up and build/install your own or port versions of perl, apache2, and mod_perl2? Probably easier than fighting with it. (Worked for me.) <hr> (as per comment)<br/> Mmmkay! Sorry, I didn't intend that to be snarky or imply that it's not a valid question. I guess I'll delete this (if I can.) ...
When I'm faced with an enormous log file, I don't try to look at the whole thing, I use [Free File Splitter][1] [1]: http://www.filesplitter.org
You may be best off to use a reporting tool like Crystal or Jasper, or even XSL-FO if you are feeling bold. They have things built in to handle specifically this. This is not something the would work well in raw SQL. If the format of all of the rows (the headers as well as all of the details) is the same, it woul...
Where to start with source-control
|svn|version-control|cvs|visual-sourcesafe|
Anyone have any suggestions on where to start for a newbie wanting to try out some sort of source-control along with a new journey into ASP.NET? SVN, VSS, CVS...I dont even know where to start!
Textpad also works well at opening files that size. I have done it many times when having to deal with extremely large log files in the 3-5gb range. Also, using grep to pull out the worthwhile lines and then look at those works great.
Are you trying to add up all the ages? You could calculate it in your controller and only display the result in the jsp. You can write a custom tag to do the calculation. You can calculate it in the jsp using jstl like this. <c:set var="ageTotal" value="${0}" /> <c:forEach var="person" items="${p...
PHP serializes to a simple text-based format. [PHPSerialize](http://hurring.com/scott/code/java/serialize/v0.1/PHPSerialize.java) looks like a parser written in Java. You can also port the [Python implementation](http://pypi.python.org/pypi/phpserialize/1.1) to Java -- I doubt it's very complex.
I'm afraid there is no such wrapper out-of-box. However it's not hard to create one: class Comparer<T>: IEqualityComparer<T> { private readonly Func<T, T, bool> _comparer; public Comparer(Func<T, T, bool> comparer) { if (comparer == null) throw new ...
Sprintf in Java
|java|
Printf got added to Java with the 1.5 release but I can't seem to find how to send the output to a string rather than a file (which is what sprintf does in C). Does anyone know how to do this?
|java|format|
If you are using PostgreSQL, then it looks in `~/.pgpass` for passwords automatically. See <a href="http://www.postgresql.org/docs/8.3/interactive/libpq-pgpass.html">the manual</a> for more information.
Good example of use of AppDomain
|.net|
I keep getting asked about AppDomains in interviews, and [I know the basics][1]: <ul><li>they are an isolation level within an application (making them different from applications)</li> <li>they can have threads (making htem different from threads)</li> <li>exceptions in one appdomain do not affect another</li> <...
I keep getting asked about AppDomains in interviews, and [I know the basics][1]: <ul><li>they are an isolation level within an application (making them different from applications)</li> <li>they can have threads (making htem different from threads)</li> <li>exceptions in one appdomain do not affect another</li> <...
Some profiler like profiler4j can show the manged and the unmanged memory (live curve). Then you can see if you has a leak and when the leak occur. But you does not find more informations. After this there are 2 possible solutions: 1. You can with the live curve isolate the problem and create a simpler test unti...
The thing that I like most about Lisp (and Smalltalk) systems, is that they feel alive. You can easily probe & modify Lisp systems while they are running. If this sounds mysterious, start Emacs & type some lisp code. Type `C-M-x` and voilà! You just changed Emacs from within Emacs. You can go on and redefine all Ema...
I love valgrind (http://valgrind.org/) if you are executing it on a system it supports. It rocks. Sam
I think you need to move the check for whether an ID is a TYPEID from c_lexer.py to c_parser.py. As you said, since the parser is looking ahead 1 token, you can't make that decision in the lexer. Instead, alter your parser to check ID's to see if they are TYPEID's in declarations, and, if they aren't, generate an...
I think you need to move the check for whether an ID is a TYPEID from c_lexer.py to c_parser.py. As you said, since the parser is looking ahead 1 token, you can't make that decision in the lexer. Instead, alter your parser to check ID's to see if they are TYPEID's in declarations, and, if they aren't, generate an...
In some situations you may also want to ignore some files globally. For me, .DS_Store is one of them. Here's how: git config --global core.excludesfile = /Users/mat/.gitignore (Or any file of your choice) Then edit the file just like a repo's .gitignore. Note that I think you have to use an absolute path.
Even something simple such as webmail can be considered to hold our information "in the cloud". That is to say that the data isn't held locally, it's stored on that magical cloud thing called the internet. It's basically just a buzzword for storing stuff remotely. This list summarises why it's used. FTP backup ...
I'm not a .NET guy, but, can't you use: HttpUtility.UrlEncode Method (String) Which is described here: http://msdn.microsoft.com/en-us/library/4fkewx0t.aspx Andrew
For example, find all instances of "#include" in the c files in this directory and all sub-directories. gci -r -i *.c | select-string "#include" gci is an alias for get-childitem
I suggest playing with the :before attribute and seeing what you can achieve with it. It will mean your code really is limited to nice new browsers, and excludes the (annoyingly large) section of the market still using rubbish old browsers, Something like the following, which forces a fixed with on the items. Yes, I...
HttpUtility.UrlEncode("url") in System.Web.
I don't use Putty for my ssh+svn connections. I use TortoisePlink, which is a wrapper around Putty, I think. It is provided by TortoiseSVN in the install directory under bin. Basically go to the Settings dialog, by right clicking in a windows explorer window -> TortoiseSVN -> Settings Click on the Network item ...
use the static HttpUtility.UrlEncode method.
You'll want to use System.Web.HttpUtility.urlencode("url") Make sure you have system.web as one of the references in your project. I don't think it's included as a reference by default in console applications.