instruction
stringlengths
0
30k
On MS SQL Server 2005 and above, [ROW_NUMBER()][1] seems to work: [http://blogs.x2line.com/al/archive/2005/11/18/1323.aspx][2] DECLARE @PageNum AS INT; DECLARE @PageSize AS INT; SET @PageNum = 2; SET @PageSize = 10; WITH OrdersRN AS ( SELECT ROW_NUMBER() OVER(ORDER BY O...
I am thinking that a generic framework would need to specify between two things: 1. What are the delimiting characters. 2. Under what condition do those characters not count (such as when they are between quotes). I think it may just be better off writing custom logic for every time you need to do something like t...
In modern browsers other fileformats than .ico works aswell. You can even put animated gif's in there!
To answer your general question, you can use [bit manipulation](http://en.wikipedia.org/wiki/Bit_twiddling) techniques: pid, status = os.wait() exitstatus, signum = status & 0xFF, (status & 0xFF00) >> 8 However, there are also [built-in funtions](http://docs.python.org/lib/os-process.html#l2h-2780) for i...
There are some good answers here: [Split a string ignoring quoted sections][1] [1]: http://stackoverflow.com/questions/6209/split-a-string-ignoring-quoted-sections You might want to rephrase your question to something more precise (e.g. **What code snippet or library I can use to parse CSV data in .NET**?).
Such as var elements = new List<string>(); var current = new StringBuilder(); var p = 0; while (p < internalLine.Length) { if (internalLine[p] == '"') ...
After performing large data manipulation operations, you frequently have to update the underlying indexes. You can do that by using the UPDATE STATISTICS [table] statement. The other option is to drop and recreate the index which, if you are doing large data insertions, will likely perform the inserts much faster. ...
@Greg Hewgill: thanks for the script! I had a couple of issues with it though, so here's what I'd change: line 21: < map <silent> <C-d> :call <SID>scmToggle()<CR> -- > map <silent> <C-h> :call <SID>scmToggle()<CR> I use Ctrl-d for page-down (too lazy to move all that way over to PdDn), so had to...
> The question is about the Active > Record design pattern. Not an orm > Tool. The original question is tagged with rails and refers to Twitter which is built in Ruby on Rails. The ActiveRecord framework within Rails is an implementation of Fowler's Active Record design pattern.
This can be the result of locale differences: $ echo 'CO2_ CO_' | env LC_ALL=C sort CO2_ CO_ $ echo 'CO2_ CO_' | env LC_ALL=en_US sort CO_ CO2_ Setting the LC_ALL environment variable to the same value should correct the problem.
.NET Compiler -- DEBUG vs. RELEASE
|.net|compiler-construction|debugging|
For years I have been using the DEBUG compiler constant in VB.NET to write messages to the console. I've also been using System.Diagnostics.Debug.Write in similar fashion. It was always my understanding that when RELEASE was used as the build option, that all of these statements were left out by the compiler, freeing...
It's because the database server has to do calculations each and every time you insert a new row. Basically, you end up reindexing the table each time. It doesn't seem like a very expensive operation, and it's not, but when you do that many of them together, you start to see the impact. That's why you usually want t...
I suggest using the built in Mixer in Vista... Why do you want to use an 3rd party program?
Using Custom MembershipProvider without a Login control in ASP.NET
|asp.net|authentication|
We have got a custom MembershipProvider in asp.net. Now there are 2 possible scenario the user can be validated: 1. User login via login.aspx page by entering his username/password. I have used Login control and linked it with the MyMembershipProvider. This is working perfectly fine. 2. A authentication token is ...
Keep the GUI layer as thin as possible. Michael Feathers article, [The Humble Dialog Box][1], is a classic. Also check out Martin Fowler's [Passive View][2]. I have also heard that the "automatic button clickers" are fragile, and that it's easy to spend more time maintaining the test than you spend maintaining the code...
C++ libraries to manipulate images
|c++|image|steganography|
Do you know any open source/free software C++ libraries to manipulate images in these formats: .jpg .gif .png .bmp ? The more formats it supports, the better. I am implementing a free program in C++ which hides a text file into one or more images, using [steganography][1]. I am working under Unix. Thanks for any...
Have you considered [GDI][1]? -- Kevin Fairchild [1]: http://www.codeproject.com/KB/GDI-plus/cgdiplusbitmap.aspx
The usage of `reduce` that I found in my code involved the situation where I had some class structure for logic expression and I needed to convert a list of these expression objects to a conjunction of the expressions. I already had a function `make_and` to create a conjunction given two expressions, so I wrote `reduce...
Simplest way is just to split the string into a char array and look for your string determiners and split char. It should be relatively easy to unit test. You can wrap it in an extension method similar to the basic .Spilt method.
I use String and not string, Int32 instead of int, so that my syntax highlighting picks up on a string as a Type and not a keyword. I want keywords to jump out at me.
Oracle Solution: select * from ( select a.*, rownum rnum from ( YOUR_QUERY_GOES_HERE -- including the order by ) a where rownum <= MAX_ROW ) where rnum >= MIN_ROW
Multithreading Design Question
|.net|multithreading|
Consider this problem: I have a program which should fetch (let's say) a 100 records from the database, and then for each one it needs to get updated information from a web service. There are two ways to introduce parallelism in this scenario: 1. I start of each request to the web service on a new Thread. The number...
On my project we're using Maven to build both our Flex RIA and the Java-based back end. In order to build and test the Flex app we use the [flex-mojos](http://code.google.com/p/flex-mojos/) maven plugins. They do a great job for us and I would highly recommend using Maven over Ant. That being said, if you're alrea...
Yes, it depends on language, since string storage differs between languages. - Pascal-type strings: Length = 0. - C-style strings: [0] == 0. - .NET: .IsNullOrEmpty. Etc.
In .Net: string.IsNullOrEmpty( nystr ); strings can be null, so .Length sometimes throws a NullReferenceException
Actually, IMO the best way to determine is the IsNullOrEmpty() method of the string class. <http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.> Update: I assumed .Net, in other languages, this might be different.
@Justin: When executing a macro, it's a little different... incremental searches will just happen once, and you will have to execute the macro again if you want to search again. You can do more powerful and complex things though, such as search for a keyword, jump to the beginning of the line, mark, go to end of th...
NAnt best practices
|.net|coding-style|nant|
How can I create Java, .NET, Ruby, PHP, Perl web user interface components that interact with each other?
|user|interface|components|integration|
How can I create Java, .NET, Ruby, PHP, Perl web user interface components that interact with each other? For example, one web ui component written in .NET selects a customer, and the other components written in Java, Ruby or PHP are able to refresh showing information about the selected customer from different syst...
How can I create Java, .NET, Ruby, PHP, Perl web user interface components that interact with each other? For example, one web ui component written in .NET selects a customer, and the other web user interface components are written in Java, Ruby or PHP are able to refresh showing information about the selected custo...
How can I allow others to create Java, .NET, Ruby, PHP, Perl web user interface components that interact with each other?
|integration|interface|user|components|
How can I allow others to create Java, .NET, Ruby, PHP, Perl web user interface components that interact with each other? For example, one web ui component written in .NET selects a customer, and the other web user interface components are written in Java, Ruby or PHP are able to refresh showing information about th...
Does the CSS 'font-size: medium' set font to .Body font size or to the *browser*'s base font size?
|css|
in "CSS: The missing manual" the author says that font-size: medium (or other size keywords) sets the font relative to the *browser's* base font size. But what I'm seeing in FF2 and IE6 is that it sets the font size to what I specified in the .CSS HTML or BODY style (which is much preferred). If it works the lat...
You should be getting the SPList object of that particular list using SharePoint Object Model. Once u get the same, you can render the list using the RenderAsHtml() Method. Please note that the RenderAsHtml() Method takes an SPQuery Object as parameter. You need to create an SPQuery object with the appropriate Query st...
Interesting, I'll give it a shot. The variations aren't slight, however. The newly encoded file is longer and when comparing the binary of the before and after, the data hardly matches up at all. Before (the first three lines) H4sIAAAAAAAAC+19eZOiyNb3/34K3r4RT/WEU40ssvTtrhuIuKK44Bo3YoJdFAFZ3D79C6hVVhUq dsnUVN/...
Well, there is a certain set of best practices for security. At a minimum, for database applications, you need to watch out for SQL Injection. Other stuff like hashing passwords, encrypting connection strings, etc. are also a standard. From here on, it depends on the actual application. Luckily, if you are wor...
Developing addins for World of Warcraft - Getting started?
|plugins|lua|warcraft|wow|
As a long time World of Warcraft player, and a passionate developer I have decided that I would like to combine the two and set about developing some addins. Not only to improve my gameplay experience but as a great opportunity to learn something new. Does anyone have any advice on how to go about starting out? ...
You have to always program defensively I would say even for internal apps, simply because users could just through sheer luck write something that breaks your app. Granted you probably don't have to worry about trying to cheat you out of money but still. Always program defensively and assume the app will fail.
In my line of work, our code has to be top quality. So, we focus on two mains things: 1. Testing 2. Code reviews Those bring home the money.
[This article][1] explains how to start pretty well. Your first bookmark is possibly the US Interface Forum, especially the Stickies for that: [http://forums.worldofwarcraft.com/board.html?forumId=11114&sid=1][2] Then, grab some simple addons to learn how XML and LUA interacts. The [WoWWiki HOWTO List][3] is a...
This is probably due to different settings of the [locale environment variables](http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.nls/doc/nlsgdrf/locale_env.htm). `sort` will use these settings to determine how to compare strings. By setting these environment variables the way you want befo...
This due to the fact that when SQL Server indexes table with data it is able to produce exact statistics of values in indexed column. At some moments SQL Server will recalculate statistics, but when you perform massive inserts the distribution of values may change after the statistics was calculated last time. The f...
The [man-page](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/sort.1.html) on OS X, at least, says > *** WARNING *** The locale specified by the environment affects sort order. Set LC_ALL=C to get > the traditional sort order that uses native byte values. which might explain things. If...
Think of it this way. > Given > unorderedList = {5, 1,3} > orderedList = {1,3,5} > add 2 to both lists. > unorderedList = {5, 1,3,2} > orderedList = {1,2,3,5} What list do you think is easier to add to? Btw ordering your input before load will give you a boost.
If you have an index on a table, as you add data to the table SQL Server will have to re-order the table to make room in the appropriate place for the new records. If you're adding a lot of data, it will have to reorder it over and over again. By creating an index only after the data is loaded, the re-order only need...
According to this simple test program, the JVM will still make its call to finalize() even if you explicitly called it: private static class Blah { public void finalize() { System.out.println("finalizing!"); } } private static void f() throws Throwable { Blah blah = new Blah(...
How about creating a RAM drive and loading the file into that ... assuming the RAM drive supports the BIGMEM stuff for you. You could use multiple processes: each process loads a view of the file as a shared memory segment, and the player process then maps the segments in turn as needed.
[FreeImage][1] is pretty solid. It has a C interface but is more C++-like in its implementation. [1]: http://freeimage.sourceforge.net/
After validation is successful, you need to sign in the user, by calling FormsAuthentication.Authenticate: http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.authenticate.aspx EDIT: It is FormsAuthentication.SetAuthCookie: [http://msdn.microsoft.com/en-us/library/twk5762b.aspx][1] Al...
Character 3F actually *is* the question mark, it isn't just displaying as one. I get the same results as Thomas, no question mark showing up. In theory it could be some problem with a web proxy but I am inclined to suspect a stray question mark in your PHP markup...which perhaps you have fixed by now so we don't ...
I see <code>hello, world</code> on the page you linked to. No problems that I can see...
I see <code>hello, world</code> on the page you linked to. No problems that I can see... I'm using Firefox 3.0.1 and Windows XP. What browser/OS are you running? Perhaps that might be the problem.
[ImageMagick][1] can manipulate about anything and has interfaces for a [dozen of languages][2], including the [Magick++][3] API for C++. [1]:http://www.imagemagick.org/ [2]:http://www.imagemagick.org/script/api.php [3]:http://www.imagemagick.org/Magick++/
Mute Specific Application in Vista
|windows-vista|audio|
I am in need of a way to mute a specific application in Vista. Example: Mute just Firefox, but not all of the other application. Much similar to muting a specific program from within the volume mixer in vista. If there is a program that will do this, i would appreciate that. Otherwise if there is a way to do t...
I am in need of a way to mute a specific application in Vista. Example: Mute just Firefox, but not all of the other application. Much similar to muting a specific program from within the volume mixer in vista. If there is a program that will do this, i would appreciate that. Otherwise if there is a way to do t...
Similar to abyx, the team I am on always developers using unit testing and code reviews. In addition to that, I also aim to make sure that I don't incorporate code that people *may* use - I tend to write code only for the basic set of methods required for the object at hand to function as has been spec'd out. I've foun...
To get FF to mimic IE's behavior when using the keyboard, you can use the keyup event on the select box. In your example (I am not a fan of attaching event handlers this way, but that's another topic), it would be like this: <select name="user" id="selUser" onchange="javascript:SetLocationOptions()" onkeyup="jav...
How is the input file sorted? Like, cat file|sort, or sorted via a single specific field, or multiple fields? If multiple fields, what fields and what order? It appears the hour fields are a 24 hour clock, not 12, right? Are all the date/time fields zero-padded (would 9am be "9" or "09"?) Without taking into acc...
Another vote for Consolas for code editing, and [Dina][1] for console output. [1]: http://www.donationcoder.com/Software/Jibz/Dina/index.html
The allocator in FreeBSD recently got an update for FreeBSD 7. The new one is called [jemaloc][1] and is apparently much more scaleable with respect to multiple threads. You didn't mention which platform you are using, so perhaps this allocator is available to you. (I believe [Firefox 3 uses jemalloc][2], even on ...
I've not seen this particular problem, but recently for us a "C1001: An internal error has occurred in the compiler" type crash from cl.exe was fixed after installing some random and unrelated (or so we thought) Windows security updates. We knew the code didn't crash the compiler on other machines using the same ver...
I believe from a performance perspective that $array["$index"] is faster than $array[$index] See [Best practices to optimize PHP code performance][1] [1]: http://www.chazzuka.com/blog/?p=163
I believe from a performance perspective that $array["$index"] is faster than $array[$index] See [Best practices to optimize PHP code performance][1] Another variation that I use sometimes when I have an array inside a string is: $str = "this is my string {$array["$index"]}" [1]: http://www.chazzuka.co...
In my experience choosing between Debug and Release in VB.NET makes no difference. You may add custom actions to both configuration, but by default I think they are the same. Using Release will certainly not remove the System.Diagnostics.Debug.Write statements.
I can enumerate the process (ie, the GetProcessById function works), and we have other code that gets the EXE name and other bits of information. I will give the test app a try. I'm also going to attempt to use WMI to get this information if I can't get the C# implementation working properly in short order (this is ...
If you create a clustered index, it affects the way the data is physically ordered on the disk. It's better to add the index after the fact and let the database engine reorder the rows when it knows how the data is distributed.
If you create a clustered index, it affects the way the data is physically ordered on the disk. It's better to add the index after the fact and let the database engine reorder the rows when it knows how the data is distributed. For example, let's say you needed to build a brick wall with numbered bricks so that thos...
Resize Infragistics GanttChart task with the mouse
|winforms|infragistics|
I loaded a custom DataTable into an UltraChart of type GanttChart. The data loads succesfully. Do you know if it possible to add support for mouse resize(drag) to the tasks that show up into the chart? I have not been able to figure out if this is supported by the Infragistics control. Thank you in advance for ...
|winforms|charts|infragistics|gantt-chart|
What I do is encapsulate the call to Debug in my own class and add a precompiler directive public void Debug(string s) { #if DEBUG System.Diagnostics.Debug(...); #endif }
I know Xenocode can merge assemblies into one but I am not sure if it will internalize other non-primary assemblies. I have found the /internalize switch in ILMerge that "internalize" all assemblies except the primary one. Pretty useful!
There is another way which avoids tempdata. The pattern I like involves creating 1 action for both the original render and re-render of the invalid form. It goes something like this: var form = new FooForm(); if (request.UrlReferrer == request.Url) { // Fill form with previous request's...
There was already a question about this: [http://stackoverflow.com/questions/3213/c-convert-integers-into-written-numbers][1] The answer is for C#, but I think you can figure it out. [1]: http://stackoverflow.com/questions/3213/c-convert-integers-into-written-numbers
Supports up to 999 million, but actually doesn't support an initial call of humanReadable(0): String humanReadable(int inputNumber) { int remainder; int quotient; quotient = inputNumber / 1000000; remainder = inputNumber % 1000000; if (quotient > 0) { return humanReada...
Supports up to 999 million, but no negative numbers: String humanReadable(int inputNumber) { if (inputNumber == -1) { return ""; } int remainder; int quotient; quotient = inputNumber / 1000000; remainder = inputNumber % 1000000; if (quotient > 0) { ...
I believe from a performance perspective that $array["$index"] is faster than $array[$index] See [Best practices to optimize PHP code performance][1] Another variation that I use sometimes when I have an array inside a string is: $str = "this is my string {$array["$index"]}"; [1]: http://www.chazzuka.c...
I believe from a performance perspective that $array["$index"] is faster than $array[$index] See [Best practices to optimize PHP code performance][1] Another variation that I use sometimes when I have an array inside a string is: $str = "this is my string {$array["$index"]}"; Edit: What I meant to say is $...
Another useful tools you might like is [WarcraftAddOnStudio][1] which lets you make plugins in the visual studio environment. [1]: http://www.codeplex.com/WarcraftAddOnStudio
I ran some quick performance benchmarks, and for 100,000 operations averaged over 10 runs, the first method (String Builder) takes almost half the time of the second (String Format). So, if this is infrequent, it doesn't matter. But if it is a common operation, then you may want to use the first method.
Oh also, the fastest would be: string cat = "cat"; string s = "The " + cat + " in the hat";