instruction
stringlengths
0
30k
Can you just use the full UNC path to the file? copy \\myserver\myshare\myfolder\myfile.txt c:\myfiles
Does anyone here have a favorite memory profiling/memory leak tool they like to use for their java webapps?
I'm writing a C# application which downloads a compressed database backup via FTP. The application then needs to extract the backup and restore it to the default database location. Since I won't know what version of SQL will be installed on the machine where the application runs, I need to be able to find the defau...
I'm writing a C# application which downloads a compressed database backup via FTP. The application then needs to extract the backup and restore it to the default database location. Since I won't know what version of SQL will be installed on the machine where the application runs, I need to be able to find the defau...
No, there isn't. Indentation is syntax for Python. You can: 1. Use tabnanny.py to check your code 2. Use a syntax-aware editor that highlights such mistakes (vi does that, emacs I bet it does, and then, most IDEs do too) 3. (far-fetched) write a preprocessor of your own to convert braces (or whatever block deli...
I can recommend Bruce Eckel's "Thinking in Java" 4th edition. He goes over a bunch of basic stuff you can skip, but his treatment of new 1.5 features is very thorough, especially the chapter on generics. And it is a good Java reference to own.
[Dietel : How to program Java][1] [1]: http://www.amazon.com/Java-How-Program-Harvey-Deitel/dp/0132222205/ref=pd_bbs_1?ie=UTF8&s=books&qid=1221487024&sr=8-1 This book is highly recommended. Teaches everything, does it well. Starts with simple Hello World and ends up in you writing your own BASIC compiler. ...
PHP is dynamically typed, so like Chris Fournier said, "If you use it like a string it becomes a string". If you're looking for more controll over the format of the string then printf is your answer.
There's a couple of small cleanups you can make... <pre><code> package { import flash.filesystem.File; public class UserUtil { public static function get currentOSUser():String { var userDir:String = File.userDirectory.nativePath; var userName:String = userDir.substr(userDir.lastIndexOf(File...
There's a couple of small cleanups you can make... package { import flash.filesystem.File; public class UserUtil { public static function get currentOSUser():String { var userDir:String = File.userDirectory.nativePath; var userName:String = userDir.subs...
There's a couple of small cleanups you can make... package { import flash.filesystem.File; public class UserUtil { public static function get currentOSUser():String { var userDir:String = File.userDirectory.nativePath; var userName:String = userDir.subs...
I think Oxygen (http://www.oxygenxml.com/) does it as well, but that's another commerical product. It's a nice one, though... I'd strongly recommend it for anyone doing a lot of XML work. It comes in a nice Eclipse plugin, too. I do believe there is a free, fully-featured 30 day trial.
|java|web-applications|profiling|
I'm looking for a good tool to profile a java webapp. I'd like to get performance information and memory usage if possible. Any suggestions?
You can specify the drive letter for net use. Put this in the command prompt for more info: net use /?
<html> <head> <title>untitled</title> <style type="text/css"> #wrapper { width: 100%; border: 1px solid #333; } #content { width: 200px; background: #00FF00; } </style> </head> <body> ...
The [ACCU][1] mags, [Overload][2] and [C-Vu][3]. I like [Game Developers Magazine][4], but since the ECTS no longer runs I no longer get free ones anymore:-( [1]: http://accu.org/ [2]: http://accu.org/index.php/journals/c78/ [3]: http://accu.org/index.php/journals/c77/ [4]: http://www.gdmag.com/
I don't know of one off the top of my head, but you might look into the way that Rails handles it if you don't find anything else, and try porting it over. Rails utilizes POST, GET, PUT, and DELETE, but it apparently has to do some fakery for PUT. Could be worth looking into if you come up dry here.
I suggest building an HttpWebRequest to programmatically execute your POST and then redirect after reading the Response if applicable.
One modern GOTO usage is by the C# compiler to create state machines for enumerators defined by yield return. GOTO is something that should be used by compilers and not programmers.
[JProfiler][1] is a really good one. It integrates with all the major IDEs and application servers. [1]: http://www.ej-technologies.com/products/jprofiler/overview.html
If you print using \r and don't use a function that will generate a newline or add \n to the end, the cursor will go back to the beginning of the line and just print over the next thing you put up.
If you print using \r and don't use a function that will generate a newline or add \n to the end, the cursor will go back to the beginning of the line and just print over the next thing you put up. Generating the complete string before printing might reduce flicker as well.
If you print using \r and don't use a function that will generate a newline or add \n to the end, the cursor will go back to the beginning of the line and just print over the next thing you put up. Generating the complete string before printing might reduce flicker as well. UPDATE: The question has been changed to ...
If you print using \r and don't use a function that will generate a newline or add \n to the end, the cursor will go back to the beginning of the line and just print over the next thing you put up. Generating the complete string before printing might reduce flicker as well. ***UPDATE***: The question has been chang...
|php|database|image|gd|png|
I want to allow users to upload avatar-type images in a variety of formats (GIF,JPEG,PNG at least), but to save them all as PNG database BLOBs. If the images are oversize, pixelwise, i want to resize them before DB-insertion. What is the best way to use GD to do the resizing and PNG conversion? Edit: Sadly, only ...
|php|database|image|png|gd|
What is the "best" way to create a thumbnail using ASP.NET?
|asp.net|image|thumbnails|
Story: The user uploads an image that will be added to a photo gallery. As part of the upload process, we need to A) store the image on the web server's hard drive and B) store a thumbnail of the image on the web server's hard drive. "Best" here is defined as * Relatively easy to implement, understand, and mai...
|asp.net|image|thumbnails|
Followup: "Sorting" colors by distinctiveness
|colors|language-agnostic|algorithm|
[Original Question](http://stackoverflow.com/questions/180/function-for-creating-color-wheels) If you are given N maximally distant colors (and some associated distance metric), can you come up with a way to sort those colors into some order such that the first M are also reasonably close to being a maximally distin...
Followup: "Sorting" colors by distinctiveness
|language-agnostic|algorithm|colors|
[Original Question](http://stackoverflow.com/questions/180/function-for-creating-color-wheels) If you are given N maximally distant colors (and some associated distance metric), can you come up with a way to sort those colors into some order such that the first M are also reasonably close to being a maximally distin...
Surrogate key will NEVER have a reason to change. I cannot say the same about the natural keys. Last names, emails, ISBN nubmers - they all can change one day.
All of the whitespace issues I had when I was starting Python were the result mixing tabs and spaces. Once I configured everything to just use one or the other, I stopped having problems. In my case I configured UltraEdit & vim to use spaces in place of tabs.
While developing your application your file and folder structure shouldn't really matter as you're probably going to want to minimize the release code and stick it in a single JS file when you're done. An automated handler or build script is probably going to be the best bet for this (see <http://extjs.com/forum/showth...
You should disable tab characters in your editor when you're working with Python (always, actually, IMHO, but especially when you're working with Python). Look for an option like "Use spaces for tabs": any decent editor should have one.
Any recommendation for a good enough Winforms GUI design?
|winforms|user-interface|design-patterns|
I am developing a mid-size application with VB2008. To better test my application I am following a MVP/Supervising Controller approach. My question is: What are your recommendations to separate responsibilites? So far I've come up with a winform with an instance of a controller and with an instance of my class. The ...
You should design websites with Javascript in mind--but not implemented. Consider, build it where every click, every action, performs a round trip to the server. That's the default functionality for older browsers, and those without JS turned on. Then, after it's all built, and everything is working properly, add i...
Byte size for types is not too interesting when you only have to deal with single language (and for codes which you don't have to remind yourself about math overflows). The part that becomes interesting is when you bridge between one language to another or C# to COM object, etc, or you're doing some bit-shifting or ma...
I would do it the simpliest way: 1. rename ComputeResult method to ComputeResultX 2. rename DoSomething method to ComputeResult 3. remove DoSomething method (which is now ComputeResult) 4. rename ComputeResultX method back to ComputeResult Maybe VS will show some conflict because of the last rename, but ig...
You can also right click the method name and click "Find all References" in Visual Studio. I personally would just do a CTRL + SHIFT + H to Find & Replace.. or am I missing something here? :D
I believe that you can use Monitor.TryEnter(). Here is the MSDN entry http://msdn.microsoft.com/en-us/library/system.threading.monitor.tryenter(VS.71).aspx The lock statement just translates to a Monitor.Enter() call and a try catch block.
I believe that you can use Monitor.TryEnter(). Here is the MSDN entry <http://msdn.microsoft.com/en-us/library/system.threading.monitor.tryenter(VS.71).aspx> The lock statement just translates to a Monitor.Enter() call and a try catch block.
I believe that you can use Monitor.TryEnter(). Here is the MSDN entry <http://msdn.microsoft.com/en-us/library/system.threading.monitor.tryenter(VS.71).aspx> The lock statement just translates to a Monitor.Enter() call and a try catch block. @Jeff: Thanks for the edit, I need to go and look at the markdown sy...
Extension methods should be used as just that: extensions. Any crucial structure/design related code or non-trivial operation should be put in an object that is composed into/inherited from a class or interface. Once another object tries to use the extended one, they won't see the extensions and might have to reimp...
I personally would recommend _NOT_ doing it.. If its is responding to some sort of action and it needs to change its appearance, I would preference raising an event and letting it sort itself out.. This kind of coupling between forms always makes me nervous. I always try to keep the UI as light and _independent_ as ...
[ReSharper][1] is definitely the VS 2008 plug in to have for refactoring. However it does not do this form of refactoring in one step; you will have to Refactor->rename DoSomething to ComputeResult and ignore the conflict with the real ComputeResult. Then delete the definition which was DoSomething. It's almost one ste...
Ouch. Please don't extend Interfaces. An interface is a clean contract that a class should implement, and your usage of said classes **must** be restricted to what is in the core Interface for this to work correctly. That is why you always declare the interface as the type instead of the actual class. IInt...
Try to use it, and trap for the error. The allowed set may change across file systems, or across different versions of Windows. In other words, if you want know if Windows likes the name, hand it the name and let it tell you.
Add Custom TextboxCell to a DataGridView control that contains a button to open the FileDialog
|.net|.net-2.0|
I would like to add a DataGridViewTextBoxCell cell to a DataGridViewCell control, but as well as being able to type in the text cell as normal it must also contain a '...' button that once clicks brings up the OpenFileDialog window to allow the user to select a file. Once selected, the text cell will be populated with ...
You should test everything. Right now you have getters and setters, but one day you might change them somewhat, maybe to do validation or something else. The tests you write today will be used tomorrow to make sure everything keeps on working as usual. When you write test, you should forget considerations like "right ...
The solution presented by @JRoppert is almost the same as what I do. The only difference is that I put the following lines in the local AssemblyInfo.cs file as they can vary with each assembly: #if DEBUG [assembly: AssemblyConfiguration("Debug")] #else [assembly: AssemblyConfiguration("Release")] ...
pop_back() invalidates only iterators that point to the last element. From C++ Standard Library Reference: > Inserting or removing elements > invalidates references, pointers, and > iterators that refer to the following > element. If an insertion causes > reallocation, it invalidates all > references, iterators...
@Krishna Kumar The bitwise solution is even more fun than the recursive solution. MSN
> How do I convert the value of a PHP > variable to string? A value can be converted to a string using the (string) cast or the strval() function.
> How do I convert the value of a PHP > variable to string? A value can be converted to a string using the [(string) cast][1] or the [strval()][2] function. (Edit: As [Thomas][3] also stated). It also should be automatically casted for you when you use it as a string. [1]: http://us3.php.net/manual/en/lan...
calculating user defined formulas (with c++)
|c++|
We would like to have user defined formulas in our c++ program. e.g. The value *v = x + ( y - (z - 2)) / 2*. Later in the program the user would define x,y and z -> the program should return the result of the calculation. <br />Somewhen later the formula may get changed, so the next time the program should parse the f...
Huffman coding would be mine, I had originally made my own dumb version by minimizing the number of bits to encode text from 8 down to less, but had not thought about variable number of bits depending on frequency. Then I found the huffman coding described in an article in a magazine and it opened up lots of new possib...
Using [Spirit][1] (for example) to parse (and the 'semantic actions' it provides to construct an expression tree that you can then manipulate, e.g., evaluate) seems like quite a simple solution. You can find a grammar for arithmetic expressions [there][2] for example, if needed... (it's quite simple to come up with you...
If it will be used frequently and if it will be extended in the future, I would almost recommend adding either python or LUA into your code. [LUA][1] is a very lightweight scripting language which you can hook into and provide new functions, operators etc. If you want to do more robust and complicated things, use Pytho...
In a class you can definie what is output by using the magical method `__toString`. An example is below: class Example private $output; public function __construct() { $this->output = 'Ninety nine green bottles'; } public fun...
If you're running privileged scripts in Windows (either in an HTA or WSH), you can access ODBC data sources using an "ADODB.Recordset" ActiveXObject. If you're talking about client side on a web page, the above post re: Google Gears is your best bet.
Ruby: def i()i()end;i() (17 chars)
One simple solution is to use the dot product of character n-gram vectors. This is robust over ordering changes (which many edit distance metrics are not) and captures many issues around stemming. It also prevents the AI-complete problem of full semantic understanding. To compute the n-gram vector, just pick a val...
On a datawarehouse scenario I belive is better to follow the surrogate key path. Two reasons: - You are independent of the source system, and changes there --such as a data type change-- won't affect you. - Your DW will need less phisical space since you will use only integer data types for your surrogate keys....
"int" is an alias for "System.Int32", as defined in this table: [http://msdn.microsoft.com/en-us/library/ya5y69ds.aspx][1] [1]: http://msdn.microsoft.com/en-us/library/ya5y69ds.aspx
Using a surrogate key is better in my opinion as there is zero chance of it changing. Almost anything I can think of which you might use as a natural key could change (disclaimer: not always true, but commonly). An example might be a DB of cars - on first glance, you might think that the licence plate could be used...
The Reuse/Release Equivalence Principle (REP) says: > The unit of reuse is the unit of release. Effective reuse requires tracking of releases from a change control system. The package is the effective unit of reuse and release. <b>The unit of reuse is the unit of release</b> Code should not be reused by copyin...
Why does Python's __iter__ on a mapping return keys() instead of iteritems()?
|python|mapping|iteration|
It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the _whole_ mapping (constituted by a set of key-value pairs). Is there a historical reason for this?
Why does Python's iter() on a mapping return iterkeys() instead of iteritems()?
|python|iteration|mapping|
GOTO is like a table saw, extremely useful when appropriate safety measures are taken. I consider it harmful, because most beginners loose fingers with both table saws, and GOTOs. There are some situations where its the only way to control flow, but those situations can be avoided.
DotNetNuke may not be a good current example. When we did the integration, DotNetOpenID was not currently supporting OpenID 2.0 spec. I hacked together a fork to get the 2.0 support and have not had a chance to rip it back out for the official DotNetOpenID 2.0 release.
How do you send email from a Java app using Gmail?
|java|gmail|
Is it possible to send an email from my Java application using a Gmail account? I have it configured to send using my company mail server, but that's not going to cut it when I distribute the application. Answers using Hotmail or Yahoo mail are also acceptable.
IBM DB2 Type 4 driver?
|db2|
Where can I find the redistributable version of the IBM DB2 Type 4 driver? I suppose this is the driver I would use to connect from a Java app (on windows) to DB2 on the mainframe?
This traverses into the concept of REST and how the web was kinda intended on being used. There is an excellent podcast on Software Engineering radio that gives an in depth talk about the use of Get and Post. Get is used to pull data from the server, where an update action shouldn't be needed. The idea being is th...
In my opinion the greatest problem with using project references is that it does not provide consumers with a common baseline for their development. I am assuming that the libraries are changing. If that's the case, building them and ensuring that they are versioned will give you an easily reproducible environment. ...
|language-agnostic|algorithm|colors|
Click an image, get coordinates
|javascript|
I know it can be done and I even have a vague idea of how to do it but it stops at being vague. I have a standard HTML image tag with an image in it, 100 by 100 pixels in size. I want people to be able to click the image and for that to pass the X and Y that they click into a function. The coordinates need to be ...
|javascript|html|image|