instruction
stringlengths
0
30k
How to control the capitalization of month and day names returned by DateFormat?
|java|internationalization|date|
Here is a quick test program: public static void main( String[] args ) { Date date = Calendar.getInstance().getTime(); System.out.println("Months:"); printDate( "MMMM", "en", date ); printDate( "MMMM", "es", date ); printDate( "MMMM", "fr", date ); ...
According to FXCop, and I agree: > **Avoid namespaces with few types** > A namespace should generally have more than **five** types. also (and this applies to the "single namespace" suggestion -- which is *almost* the same to say as no namespace) >**Declare types in namespaces** >A type should be defined...
.contains() is the best method for lists, but for maps you will need to use .containsKey() or .containsValue() [a:1,b:2,c:3].containsValue(3) [a:1,b:2,c:3].containsKey('a')
He's probably testing you on a relatively common mistake most people make when implementing a shuffling algorithm (this was also actually at the center of a <a href="http://itmanagement.earthweb.com/entdev/article.php/11070_616221_2">controversy</a> involving an online poker site a few years back) Incorrect way to s...
I suggest using a script wrapper for svn co. #!/bin/sh svn co path://server/R svn-R git clone path://server/l git-l Or similar.
Is it possible to advance an enumerator and get its value in a lambda?
|c#|functional-programming|lambda|
If I have an IEnumerator variable is it possible to have a lambda function that takes it, advances it with MoveNext() and returns the Current value every single time its called?
|c#|lambda|
It does make sense that a successful execution returns true. Handling generic errors will be much easier: if (!createUser($username)) { // the dingo ate my user. // deal with it. } But it doesn't make sense at all to associate meaning with different types of false. False should mean one thing...
How do I capitalize first letter of first name and last name in C#?
|c#|
Is there an easy way to capitalize the first letter of a string and lower the rest of it? Is there a built in method or do I need to make my own?
|c#|homework|
|c#|
|c#|homework|
No, I don't think that you have to use a state machine for this workflow. But, I propose to change the Suspend activity because: > The SuspendActivity activity > temporarily stops the execution of the > current workflow. Typically, you use > the SuspendActivity activity to > reflect an error condition that > re...
You could try to use something REST based (e.g. [ADO.NET Data Services][1]) and wrap it transpariently into your client code. [1]: http://msdn.microsoft.com/en-us/data/bb931106.aspx
Major.Minor.Bugs (Or some variation on that) Bugs is usually bug fixes with no new functionality. Minor is some change that adds new functionality but doesn't change the program in any major way. Major is a change in the program that either breaks old functionality or is so big that it somehow changes how u...
Depends a bit on the language, Delphi and C# for example have different meanings. Usually, the first two numbers respresent a major and a minor version, i.e. 1.0 for the first real release, 1.1 for some important bugfixes and minor new features, 2.0 for a big new feature release. The third number can refer to a "...
The section [String Concatenation Operator +][1] of the Java Language Specification gives you some more background information on why the + operator can be so slow. [1]: http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.18.1
If you are intending on reading a large number of columns or records it's also worth caching the ordinals and accessing the strongly-typed methods, e.g. using (DbDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { int idxColumnName = dr.GetOrdinal("columnName"); int idxSomethingElse ...
FWIW, here's the same solution from the MSDN article suggested by Prakash in Python using the wonderful [ctypes](http://python.net/crew/theller/ctypes/): from ctypes import * # get handle to c:\boot.ini to test handle = windll.kernel32.CreateFileA("c:\\boot.ini", 0x80000000, 3, 0, 3, 0x80, 0) hfi...
Generally then number are in the format of version.major.minor.hotfix, not individual internal components. So v1.9.0.1 would be version 1, major release 9 (of v1), minor release (of v1.9) 0, hot fix 1 of (v1.9.0).
The most natural and efficient way to do paging is using the LIMIT/OFFSET (TOP in Sybase world) construct. A DBindependent way would have to know which engine it's running on and apply the proper SQL construct. At least, that's the way I've seen it done in DB independent libraries' code. You can abstract away the pa...
The most natural and efficient way to do paging is using the LIMIT/OFFSET (TOP in Sybase world) construct. A DBindependent way would have to know which engine it's running on and apply the proper SQL construct. At least, that's the way I've seen it done in DB independent libraries' code. You can abstract away the pa...
The most natural and efficient way to do paging is using the LIMIT/OFFSET (TOP in Sybase world) construct. A DBindependent way would have to know which engine it's running on and apply the proper SQL construct. At least, that's the way I've seen it done in DB independent libraries' code. You can abstract away the pa...
The very same Jeff Atwood coded a nice solution (albeit in VB.NET) which I had to modify and "fix" but that I am happily using since then. You can view his solution [Here][1] Enjoy. :) [1]: http://www.codeproject.com/KB/exception/ExceptionHandling.aspx
On OS X starting in 10.4, `/etc/resolv.conf` is no longer the canonical location for DNS IP addresses. Some Unix tools such as `dig` and `nslookup` will use it directly, but anything that uses Unix or Mac APIs to do DNS lookups will not. Instead, configd maintains a database which provides many more options, like usi...
what is the easiest way to lookup function names of a c binary in a cross-platform manner?
|c|symbols|
I want to write a small utility to call arbitrary functions from a C shared library. User should be able to list all the exported functions similar to what objdump or nm does. I checked these utilities' source but they are intimidating. Couldn't find enough information on google, if dl library has this functionality ei...
I want to write a small utility to call arbitrary functions from a C shared library. User should be able to list all the exported functions similar to what objdump or nm does. I checked these utilities' source but they are intimidating. Couldn't find enough information on google, if dl library has this functionality ei...
You'll find that's a very interesting topic. The best approach relies on the ReadWriteResourceLock which use to have big performance issues due to the so called Convoy Problem. The best article I've found treating the subject is [this one][1] by Jeffrey Richter which exposes its own method for a high performance ...
It depends on whether you want to be able to upgrade Subversion in future using Debian's package management tools. Building it from source should be easy enough, and lets you configure it the way you want, but then each time you want to upgrade, you'll need to build it from source again, rather than a simple apt-get.
Final Results: $size_x = imagesx($img); $size_y = imagesy($img); $temp = imagecreatetruecolor($size_x, $size_y); imagecolortransparent($temp, imagecolorallocate($temp, 0, 0, 0)); imagealphablending($temp, false); imagesavealpha($temp, true); $x = imagecopyresampled($te...
what is the difference between file modification time and file changed time?
|file-modification-time|file-changed-time|
I am confused between the term file modification time and file changed time. Can anyone help to make it clearer?
|filesystems|operating-system|
Call DirectXSetupGetVersion: http://msdn.microsoft.com/en-us/library/bb219716(VS.85).aspx You'll need to include dsetup.h Here's the sample code from the site: DWORD dwVersion; DWORD dwRevision; if (DirectXSetupGetVersion(&dwVersion, &dwRevision)) { printf("DirectX version is %d.%d....
Did you consider [AutoIt][1] ? It is a scripting language, and you can quickly transform a script into an exe... [1]: http://www.autoitscript.com/autoit3/
What ever you do, keep the old repositories in read-only mode some where.
Need javascript code for button press and hold.
|javascript|mouse|button|press|click|
I'd like a short smallest possible javascript routine that when a mousedown occurs on a button it first responds just like a mouseclick and then if the user keeps the button pressed it responds as if the user was continously sending mouseclicks and after a while with the button held down acts as if the user was acceler...
|javascript|mouse|
using System.Reflection; using System.Collections.Generic; //... static List<string> GetClasses(string namespace) { Assembly asm = asm.GetExecutingAssembly(); List<string> namespacelist = new List<string>(); List<string> classlist = new List<string>(); ...
using System.Reflection; using System.Collections.Generic; //... static List<string> GetClasses(string nameSpace) { Assembly asm = asm.GetExecutingAssembly(); List<string> namespacelist = new List<string>(); List<string> classlist = new List<string>(); ...
Are you able to manage permissions on this database? Would adding a separate user who only has read access to a database be sufficient for this type of scenario? i.e. Add a new user, readerMan5000 who is only given select access, to the database in question. Then require users to authenticate through that new cr...
I'm pretty sure you can't disable the visual studio default here, and even if you did, the value would then be just whatever was in memory before the memory was allocated. Your best off just getting in the habit of setting them to 0 in the first place, it's only 2 extra charecters. int *ptr=0; You can also...
Animater Gif's will mostly be faster than Flash/Silverlight. But Flash/Silverlight are in a different league. WRT Flash Vs Silverlight: Based on the demo's I have seen, flash seems to be faster/less CPU intensive than silverlight. It may be because Flash has matured a lot and there is a lot of known optimization co...
As with most problems, it depends on what you want to achieve. If you want to create a db grid that will allow all columns in any table, then "Select *" is the answer. However, if you will only need certain columns and adding or deleting columns from the query is done infrequently, then specify them individually. I...
It depends a lot on which version of the framework you are targeting. I believe 1.1 (and even 2.0) are widely deployed. The later versions are not. You should also visit this site for some very good information on .Net Framework Deployment: <http://www.hanselman.com/smallestdotnet/>
When you concatenate two strings, you actually create a third String object in Java. Using StringBuffer (or StringBuilder in Java 5/6), is faster because it uses an internal array of chars to store the string, and when you use one of its add(...) methods, it doesn't create a new String object. Instead, StringBuffer/Bui...
Try dynamically extending the bases that way you can take advantage of the mro and the methods are actual methods: class Parent(): def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): return type(name, bases + (Parent,), dict) class...
Try dynamically extending the bases that way you can take advantage of the mro and the methods are actual methods: class Parent(object): def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): return type(name, (Parent,) + bases, dict) ...
I've been a daily user of TFS for about 1.5 years now. * Source control is stable * You can't easily work disconnected. File check out goes to the server. * Auto-merge works great, except sometimes it corrupts the source file (encoding problem). * TFS has a sluggish feel!? Especially the test manager. Manage...
As this outputs a list would you not : find /path/to/jpgs -type f -exec jhead -v {} \; | grep 123 or find /path/to/jpgs -type f -print -exec jhead -v {} \; | grep 123 Put your grep on the results of the find -exec.
I find it telling that, in spite of how well-known the pimpl idiom is, I don't see it crop up very often in real-life (e.g. in open source projects). I often wonder if the "benefits" are overblown; yes, you can make some of your implementation details even more hidden, and yes, you can change your implementation wit...
Try this find /path/to/jpgs -type f -exec sh -c 'jhead -v {} | grep 123 \; -print' \; Alternatively you could try to embed your exec statement inside a sh script and then do: find -exec some_script {} \;
Edit UrlMappings.groovy Add for example add this rule, to handle the root with a HomeController. "/"(controller:'home')
MySQL Interview Questions
|mysql|
I've been asked to screen some candidates for a MySQL DBA / Developer position for a role that requires an enterprise level skill set. I myself am a SQL Server person so I know what I would be looking for from that point of view with regards to scalability / design etc but is there anything specific I should be aski...
Floating points have unexpected irrational numbers. For instance you can't store 1/3 as a decimal, it would be 0.3333333333... (and so on) Floats are actually stored as a binary value and a power of 2 exponent. So 1.5 is stored as 3 x 2 to the -1 (or 3/2) Using these base-2 exponents create some odd irratio...
[svn:externals][1] is the way svn can be made to check out sources from more than one repository into one working copy. But it is only meant for dealing with svn repositories - it doesn't know how to check out a git repository. You might be able to do it the other way 'round, by including an svn repository inside a ...
This looks disturbingly familiar to a character encoding issue dealing with the Windows character set being stored in a database using the standard character encoding. I see someone voted Will down, but he has a point. You may be solving the immediate issue, but the combinations of characters are limitless if this is t...
Like edg indicated, you'll need a more complex algorithm to handle special names (this is probably why many places force everything to upper case). Something like this untested c# should handle the simple case you requested: public string SentenceCase(string input) { return input(0, 1).ToUpper +...
I would strongly advise against putting .net assemblies in your database server, think n-tier applications. Persistence <- Business Logic <-Presentation Logic <- client Keep your Logic in your Business Logic layer. The only reason I can think of to put .net in your database would to add a new complex data type, I ...
I have tackled these kind of issues before, if you haven't already found the answer, I suggest the following: - Enable tracing/logging in all third party apps and libraries you are using such that the errors are logged to files instead of stdout or stderr. Often times, you will find a clue from these. - Your Wi...
Possible to set tab focus in IE7 from JavaScript
|javascript|internet-explorer-7|focus|
Is it possible to launch a new window in JavaScript using the window.Open function, then set the focus to that tab? Here's what I'm doing today: <code> <pre> var winRef = window.open(outUrl,wName,'left='+ wX +',top=' + wY + ',height=' + wH + ',width=' + wW + args); try { // Not all window types suppor...
How to create a triple-join table with Django
|python|model-view-controller|django|model|
Using Django's built in models, how would one create a triple-join between three models. For example: * Users, Roles, and Events are the models. * Users have many Roles, and Roles many Users. (ManyToMany) * Events have many Users, and Users many Events. (ManyToMany) * But for any given Event, any User may hav...
VC++'s behaviour shouldn't cause havoc with any **valid** check you can do. If you are seeing the 0xfeeefeee then you haven't written to the memory (or have freed it), so you shouldn't be reading from the memory anyway.
[Managing Gigabytes](http://www.amazon.com/Managing-Gigabytes-Compressing-Multimedia-Information/dp/1558605703/) by Alistair Moffat, Timothy C. Bell ![Managing Gigabytes cover](http://ecx.images-amazon.com/images/I/41HKJYHTQDL._SL500_BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg)
If you build in Release mode instead of Debug mode, the runtime does not fill uninitialized memory at all, but it will still not be zeros. However, you should <b>not</b> depend on this behavior - you should either explicitly initialize the memory yourself with memset(), ZeroMemory(), or SecureZeroMemory(), or set a fl...
The first number is typically referred to as the major version number. It's basically used to denote significant changes between builds (i.e. when you add many new features, you increment the major version). Components with differing major versions from the same product probably aren't compatible. The next number is...
If you're reading uninitialized memory, your checks are most certainly not "valid". The memory is freed. It might already be in use for something else. You can't make any assumptions about the contents of uninitialized memory in C/C++. Java (and C#, I believe) will guaranteed that allocated memory is zeroed befor...
How can I add reflection to C++?
|c++|templates|
I'd like to be able to introspect a C++ class for it's name, contents etc. I'm talking native C++ here, not managed C++, which has reflection. References to classes, along with code examples, or just code examples would be beneficial. I'm not scared of templates! :)
|c++|templates|reflection|
|c++|reflection|templates|
Using the repository namespace to convey information like branches / tags / etc is fundamentally the SVN model; if what you want is a different model, you probably really want something other than SVN. The lack of metadata like CVS-style labels in SVN is an intentional design decision. No matter what arrangement of ...
Java Servlet 404 errors
|java|web-applications|jakarta-ee|servlets|
What culprits are the most likely to cause a `404 resource not found` error when a page in a given .WAR, autocreated by Sun's J2EE `deploytool`, is trying to load a Servlet in the same .WAR file? <br/> Eg: > <style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2...
For Constants, Enum is a better choice IMHO. Here is an example public class myClass { public enum myEnum { Option1("String1", 2), Option2("String2", 2) ; String str; int i; myEnum(String str1, int i1) { this.str = str1 ; this.i1 = i } }
The IV allows for plaintext to be encrypted such that the encrypted text is harder to decrypt for an attacker. Each bit of IV you use will double the possibilities of encrypted text from a given plain text. For example, let's encrypt 'hello world' using an IV one character long. The IV is randomly selected to be 'x'...
Using C#, what is the most efficient method of converting an ASCII byte string to an array of bytes
|c#|arrays|
While there are 100 ways to solve the conversion problem, I am focusing on performance. Give that the string only contains binary data, what is the fastest method, in terms of performance, of converting that data to a byte[] (not char[]) under C#?
Using C#, what is the most efficient method of converting a string containing binary data to an array of bytes
|c#|arrays|