instruction stringlengths 0 30k ⌀ |
|---|
Too complicated, and forgets nulls, etc. This is used for things like bucketing, so you can get away with something like
if(null !=str1) {
return str1.GetHashCode();
}
if(null !=str2) {
return str2.GetHashCode();
}
//Not sure what you would put here, some constant value will do
return 0;
This is biased ... |
System.Globalization.TextInfo.ToTitleCase().
[MSDN Link][1]
[1]: http://msdn2.microsoft.com/en-us/library/system.globalization.textinfo.totitlecase.aspx |
ToTitleCase() should work for you.
http://support.microsoft.com/kb/312890 |
One thing to keep in mind is that BSTR strings can (and do in practice) contan embedded nulls - in other words a null does not mean the end of the string. |
Perl also has the very nice (and very *fast*) [Text::CSV_XS](http://search.cpan.org/search?query=text%3A%3Acsv_xs&mode=module) which allows you to easily make Excel-friendly CSV files, which may be a better solution than creating proper XLS files.
For example (over-commented for instructional value):
#!/usr/bin/... |
CultureInfo.CurrentCulture.TextInfo.ToTitleCase("hello world"); |
ASP.Net Redirect Response to a IFrame |
|asp.net| |
How can I redirect the response to an IFrame?
|
I would pick Delphi, but that is probably because I have programmed it before. It seems there are still a number of companies which use it, and almost everyone who has 8+ years expierence has encountered it somewhere. It seems that most programmers can relate to using it or at least learning Pascal. Not to mention t... |
What's going on here: Git is optimized to switch between branches as quickly as possible. In particular, `git checkout` is designed to not touch any files that are identical in both branches.
Unfortunately, RCS keyword substitution breaks this. For example, using `$Date$` would require `git checkout` to touch every... |
How can I turn a string of HTML into a DOM object in a Firefox extension? |
|firefox|javascript| |
I'm downloading a web page with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object? |
|firefox|javascript|dom| |
I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?
It appears that the general solution is to create a hidden iframe and throw the contents of the string into ... |
I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?
It appears that the general solution is to create a hidden iframe and throw the contents of the string into ... |
|javascript|firefox|dom| |
|javascript|firefox|dom| |
I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?
It appears that the general solution is to create a hidden iframe and throw the contents of the string into ... |
definetly
+1 for VisualAssistX (cannot work without it anymore & it's worth all the money)
and
+1 for VisualSVN |
If you are targeting Windows, C++/CLI (Microsoft's .NET 'managed' dialect of C++) is an interesting possibility, particularly if you want to leverage your C++ experience. You can mix native code (e.g. calls to C-style libraries) with .NET managed code quite seamlessly, and take advantage of .NET GC and libraries.
As... |
Drobo!
A USB hard drive RAID array that uses normal - off the shelf hard drives. 4 bays, when you need more space, buy another hard drive. Out of bays? Buy bigger hard drives and replace your smallest in the array.
http://www.drobo.com/ |
Use **services.msc** or (Start > Control Panel > Administrative Tools > Services) to find the service in question. Double-click to see the service name and the path to the executable.
Check the exe version information for a clue as to the owner of the service, and use Add/Remove programs to do a clean uninstall if p... |
You can leverage a built in control called NotifyIcon. This creates a tray icon when shown. @Phillip has a code example that is somewhat complete.
There is a gotcha though:
You must override your applications main form Dispose method to call Dispose on NotifyIcon, otherwise it will stay in your tray after applica... |
[Consolas font](http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&displaylang=en)
Free font from MS designed for reading code.
|
SSL encrypts the entire communications path from the client to the server and back, so yes - the headers will be encrypted. |
SSL encrypts the entire communications path from the client to the server and back, so yes - the headers will be encrypted.
By the way, if you develop networked applications and care about data security, the least you should do is read a book like Practical Cryptography, by Niels Ferguson and Bruce Schneier, and pro... |
PowerShell's Adaptive Type System doesn't let you create concrete types you can test against the way you did in your parameter. If you don't need that test, you're fine with any of the methods mentioned above.
If you want an actual type that you can cast to or type-check with, as in your example script ... it can't... |
The only example I can think of where it makes sense to call System.gc() is when profiling an application to search for possible memory leaks. I believe the profilers call this method just before taking a memory snapshot. |
You can download the latest source code as a tar file from [here][1]. The C# runtime (binary) is also available directly, [here][2].
Which solution are you looking for?
[1]: http://antlr.org/download/antlr-3.0.1.tar.gz
[2]: http://antlr.org/download/DOT-NET-runtime.zip |
The Hibernate annotations docs (http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/) suggest that this should be a class-level annotation rather than occurring inline within your code. And indeed when I paste that code into my IDE and move it around, the compile errors are present when the annotati... |
After struggling to find a simpler solution, I gave up and wrote a routine to parse my SQL query for variable names:
Dim FieldRegEx As New Regex("@([A-Z_]+)", RegexOptions.IgnoreCase)
Dim Fields As Match = FieldRegEx.Match(Query)
Dim Processed As New ArrayList
While Fields.Success
Dim K... |
Using the Apple OS X Cocoa framework, how can I post a *sheet* (slide-down modal dialog) on the window of another process?
Clarified a bit:
My application is a Finder extension to do Subversion version control (http://scplugin.tigris.org/). Part of my application is a plug-in (a Contextual Menu Item for Finder);... |
I use the following method to zero out tables, with the added bonus that it leaves me with an archive copy of the table.
CREATE TABLE `new_table` LIKE `table`;
RENAME TABLE `table` TO `old_table`, `new_table` TO `table`;
|
you can use the $argv array. like this:
<?php
echo $argv[1];
?>
remember that the first member of the $argv array (which is $argv[0]) is the name of the script itself, so in order to use the parameters for the application, you should start using members of the $argv[] from the '1'th index.
when cal... |
Actually, you have to assume that Flash is probably already installed on the user's browser, and SilverLight probably not. So the cost of installing silverlight (though a small download) has to be taken in to consideration as well.
Silverlight, however, does have some pretty neat out of the box multimedia support. |
It depends what content you're serving. If the image can be vector data and not a raster (like a .gif) then either flash or silverlight would be immensly smaller in size than the equivalent .gif.
It's hard to compare Silverlight to Flash, as it's still in beta. If you choose to use Silverlight, realize that Flash is... |
Java turns string1 + string2 into a StringBuffer construct, append(), and toString(). This makes sense.
However, in Java 1.4 and earlier, it would do this for *each* + operator in the statement *separately*. This meant that doing a + b + c would result in *two* StringBuffer constructs with *two* toString() calls. ... |
.Net Gridview alpha sorting, it needs to be numberically sorting |
|.net|c#|gridview| |
This is my first real question of need for any of thsoe Gridview experts out there in the .NET world.
I an creating a Gridview from codebehind and I am holding a bunch of numerical data in the columns. Although, I do add the comma in the number fields from codebehind. When I load it to the Gridview, I have the sor... |
.Net Gridview alpha sorting, it needs to be numerically sorting |
.Net Gridview alpha sorting, it needs to be numerically sorted |
|c#|.net|gridview| |
This is my first real question of need for any of those Gridview experts out there in the .NET world.
I an creating a Gridview from codebehind and I am holding a bunch of numerical data in the columns. Although, I do add the comma in the number fields from codebehind. When I load it to the Gridview, I have the sor... |
Eclipse isn't bad, but you have to do things Eclipse's way. Eclipse has some built in ideas on directory layout. For a new project, Eclipse is a reasonable choice. Importing an existing project into Eclipse may require some restructuring.
I used to use Eclipse under QNX for C++. The QNX people actually developed... |
i'd probably use a the sql server 2005 row_number() over (order by score ) / (select count(*) from scores) or something along those lines. |
template <int precision = 8> class FixedPoint {
private:
int val_;
public:
inline FixedPoint(int val) : val_ (val << precision) {};
inline operator int() { return val_ >> precision; }
// Other operators...
}; |
I realize that the question is about online sources, but I taught myself Perl in about three weeks thanks to the following books:
[Learning Perl][1]
[Intermediate Perl][2]
[1]: http://oreilly.com/catalog/9780596520106/
[2]: http://oreilly.com/catalog/9780596102067/
I already had a little bit of background ... |
i'd do something like:
select @n = count(*) from tbl1
select @median = @n / 2
select @p75 = @n * 3 / 4
select @p90 = @n * 9 / 10
select top 1 score from (select top @median score from tbl1 order by score asc) order by score desc
is this right? |
1. If you want to implement some basic animation jQuerry is ok.
2. Also personally I like the prototype.js
3. For more difficult thing we using some features of Microsoft AJAX client library
Cheers. |
Verified channel to server from app on iPhone |
|iphone|http|security| |
I'm working on a game for the iPhone and would like it to be able to submit scores back to the server. Simple enough, but I want the scores to be verified to actually come from a game-play. With the (defacto) prohibition on real crypto with the export conditions, what would be the best way to get information back in ... |
<pre>
for i in apple orange kiwi
do
echo $i
done
</pre> |
Date object last modified |
|sql-server| |
How can I find out the date an SQL object was last modified?
I need to get a list of all the views, procs, functions etc that were modified since Aug 15th. In sysObjects I can see the date objects were created but I need to know when they were last altered. |
|sql-server|sql-server-2000| |
How can I find out the date a MS SQL Server object was last modified?
I need to get a list of all the views, procs, functions etc that were modified since Aug 15th. In sysObjects I can see the date objects were created but I need to know when they were last altered. |
How can I find out the date a MS SQL Server 2000 object was last modified?
I need to get a list of all the views, procs, functions etc that were modified since Aug 15th. In sysObjects I can see the date objects were created but I need to know when they were last altered.
NB: this is an SQL 2000 database. |
read var1 var2 < <(echo "hello world") |
I thing that another good way could be to create Interface for view with some Property like ParentView of some interface, so you can use it both for controls which need a reference to the page(parent control) and for master views which should be accessed from views. |
Yes you have to synchronize access to collections objects.
Alternatively, you can use the "concurrent" wrappers around any existing object. For example:
List<String> safeList = Collections.concurrentList( originalList );
However all code needs to use the safe version, and even so iterating while another t... |
Yes you have to synchronize access to collections objects.
Alternatively, you can use the "concurrent" wrappers around any existing object. For example:
List<String> safeList = Collections.synchronizedList( originalList );
However all code needs to use the safe version, and even so iterating while another... |
I actually bought The Sans Mono Condensed, which is (was) the goto code font in O'Reilly titles. It's by the same guy as did Consolas for Microsoft (but Consolas wasn't available when I bought it).
It's a really nice, tight, clear face - works really well on slides if you're doing that sort of thing as well. |
[Cocoa Programming][1] for Mac OS X by Aaron Hillegass
[1]: http://www.amazon.co.uk/Cocoa-Programming-Mac-OS-X/dp/0321503619/ |
How do I invoke an exe that is an embedded resource in a .Net assembly? |
|.net| |
I have an executable file that is included in my .net assembly as an embedded resource. Is there a way to run this executable that does not involve writing it out to disk and launching it?
This is .Net 2.0. |
I have a non-.Net executable file that is included in my .net assembly as an embedded resource. Is there a way to run this executable that does not involve writing it out to disk and launching it?
This is .Net 2.0. |
According to [this page][1] you may use preprocessor directives in your *.rc file. You should write something like this
#ifdef _DEMO_VERSION_
IDR_MAINFRAME ICON "demo.ico"
#else
IDR_MAINFRAME ICON "full.ico"
#endif
[1]: http://msdn.microsoft.com/en-us/library/aa381033(VS.85).aspx |
What I would do is setup a pre-build event (Project properties -> Configuration Properties -> Build Events -> Pre-Build Event). The pre-build event is a command line. I would use this to copy the appropriate icon file to the build icon.
For example, let's say your build icon is 'app.ico'. I would make my fullic... |
Yup, the check-in action can only be associated to a state transition (i.e. Active to Resolved). In my blog post that Fredrick linked to ([http://www.woodwardweb.com/vsts/top_tfs_tip_3_r.html][1]) I talk about how to remove that. You'll need to customize the work item for everyone in your team project to make this ha... |
Yup, the check-in action can only be associated to a state transition (i.e. Active to Resolved). In my blog post that [Fredrick][1] linked to ([http://www.woodwardweb.com/vsts/top_tfs_tip_3_r.html][2]) I talk about how to remove that. You'll need to customize the work item for everyone in your team project to make th... |
What is a "reasonable" length of time to keep a SQL cursor open? |
|sql|cursor| |
In your applications, what's a "long time" to keep a transaction open before committing or rolling back? Minutes? Seconds? Hours?
and on which database? |
|sql|cursors| |
Where do you get good icons/images for applications & web apps? |
|image|media|resources|icon|favicon| |
I'm interested in finding good icons/images that can be used in both 'free' and proprietary programs. |
|resources|image|favicon|icon|media| |
I'm interested in finding good icons/images that can be used in both 'free' and proprietary programs.
Please include a description of any license restrictions associated with the source of the icons you suggest. |
|image|resources|icons|media|favicon| |
Compare Version Identifiers |
|c#|.net|version|compare| |
|c#|.net|versions|compare| |
Here is my code, which takes two version identifiers in the form "1, 5, 0, 4" or "1.5.0.4" and determines which is the newer version.
Suggestions or improvements, please!
/// <summary>
/// Compares two specified version strings and returns an integer that
/// indicates their relationshi... |
Check out the [Google Maps Image Cutter][1] It can take any image or digital photo and cut it into tiles which are displayed on a Google Map. Might be a quick way to do what you need...
[1]: http://www.casa.ucl.ac.uk/software/googlemapimagecutter.asp |
Set a flag variable, then check for it in the finally clause, like so:
boolean exceptionThrown = true;
try {
mightThrowAnException();
exceptionThrown = false;
} finally {
if (exceptionThrown) {
// Whatever you want to do
}
}
|
Do you mean you want the finally block to act differently depending on whether the try block completed successfully?
If so, you could always do something like:
boolean exceptionThrown = false;
try {
// ...
} catch(Throwable t) {
exceptionThrown = true;
// ...
} finall... |
For that (rendering hierarchical menu, treeview, etc) i use recursive calls of custom component (ascx, or aspx in new preview5).
I give component first level of items (List of items), and component then check for each item in list if there's any child items and call itself with list of that child items.
You can... |
I have done this in the past by adding:
ob_start();
In the top of the pages and then in the footer:
$page_html = ob_get_contents();
ob_end_clean();
file_put_contents($path_where_to_save_files . $_SERVER['PHP_SELF'], $page_html);
You might want to convert .php extensions to .html before bak... |
First, look here: http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C
My company has a C library our customers use. We use CxxTest (a C++ unit test library) to test the code. CppUnit will also work. If you're stuck in C, I'd recommend RCUNIT (but CUnit is good too).
|
No I do not believe so. The catch block will run to completion before the finally block.
Otherwise you can add a synchronize() object that the exception code will use, that you can check in the finally block, which would help you identify if in a seperate thread you are running an exception. |
No I do not believe so. The catch block will run to completion before the finally block.
try {
// code that may or may not throw an exception
} catch {
// catch block must exist.
finally {
SomeCleanupFunctionThatThrows();
// this portion is ran after catch block finishes
... |
What do the numbers in a version typically represent (i.e. v1.9.0.1)? |
|versions| |