instruction
stringlengths
0
30k
If you want a portable solution that will work on any ANSI [SQL-92](http://en.wikipedia.org/wiki/SQL-92) RDBMS, you will need to add a new column to your table. Joe Celko is the original author of the **[Nested Sets](http://www.intelligententerprise.com/001020/celko.jhtml)** approach to storing hierarchies in SQL. Y...
For screen shots, I use a mix between ScrapBook and ScreenGrab. They are both firefox plugins that are pretty amazing when you need to get a screenshot of a page for editing. Works great for consulting. <https://addons.mozilla.org/en-US/firefox/addon/427><br/> <https://addons.mozilla.org/en-US/firefox/addon/1146>
In general, a non-administrator user has this access to the registry: Read/Write to: * HKEY_LOCAL_USER Read Only: * HKEY_LOCAL_MACHINE * HKEY_CLASSES_ROOT (which is just a "link" to HKEY_LOCAL_MACHINE\Software\Classes) It is possible to change some of these permissions on a key-by-key basis, but it's e...
Quicktime has the notion of Tween Tracks. A tween track is a track that allows you to modify the properties of another set of tracks properties (such as the volume). See [Creating a Tween Track](http://developer.apple.com/documentation/QuickTime/RM/MediaTypesAndHandlers/MHFundamentals/G-Chapter%20copy%203/chapter_1...
This is how I've done it using parameterized commands. MSSQL INSERT INTO MyTable (Field1, Field2) VALUES (@Value1, @Value2); SELECT SCOPE_IDENTITY(); MySQL INSERT INTO MyTable (Field1, Field2) VALUES (?Value1, ?Value2); SELECT LAST_INSERT_ID();
We use mysql replication to replicate data to close to 30 servers. We monitor them with nagios. You can probably check the replication status and use an event handler to restart it with 'SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; Start Slave;'. That will fix the error, but you'll lose the insert that caused the error. Ab...
We use mysql replication to replicate data to close to 30 servers. We monitor them with nagios. You can probably check the replication status and use an event handler to restart it with 'SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; Start Slave;'. That will fix the error, but you'll lose the insert that caused the error. Ab...
Valgrind is a nice option for Linux. Under MacOS X, you can enable the MallocDebug library which has several options for debugging memory allocation problems (see the malloc manpage, the "ENVIRONMENT" section has the relevant details). The OS X SDK also includes a tool called MallocDebug (usually installed in /Develope...
Python libdwarf module
|python|
I'm working on a utility which needs to resolve hex addresses to a symbolic function name and source code line number within a binary. The utility will run on Linux on x86, though the binaries it analyzes will be for a MIPS-based embedded system. The MIPS binaries are in ELF format, using DWARF for the symbolic debuggi...
> From the horse's mouth: [Explicit line > joining ][1] > > Two or more physical lines may be > joined into logical lines using > backslash characters (\), as follows: > when a physical line ends in a > backslash that is not part of a string > literal or comment, it is joined with > the following forming a si...
Found this article by Rick Strahl recently <http://www.west-wind.com/presentations/PayPalIntegration/PayPalIntegration.asp>. Have not implemeted anything from it yet, Rick has quite a few articles around the web on ecommerce in aspnet, and he seems to show up everytime I'm searching for it.
Continually remove the low order bit comes to mind... int highest_order_bit( int x ) { int y = x; do { x = y; y = x & (x-1); //remove low order bit while( y != 0 ); return x; }
Continually remove the low order bit comes to mind... int highest_order_bit( int x ) { int y = x; do { x = y; y = x & (x-1); //remove low order bit } while( y != 0 ); return x; }
Correctly written Windows apps that want to save their location from run to run will save the results of GetWindowPlacement() before shutting down, then use SetWindowPlacement() on startup to restore their position. Frequently, apps will store the results of GetWindowPlacement() in the registry as a REG_BINARY for e...
Where do you store your connectionstring? Should it be cached?
|asp.net|
I usually store my connectionstring in web.config or in the application settings of my Visual Studio project. The application I'm currently working on makes a lot of trips to the database which means it will look up the connectionstring every time. Should I be putting the connectionstring in the cache or should I be lo...
Where do you store your database connectionstring?
I usually store my connectionstring in web.config or in the application settings of my Visual Studio project. The application I'm currently working on makes a lot of trips to the database which means it will look up the connectionstring every time. Should I be putting the connectionstring in the cache or should I be lo...
Lots of other good solutions here, but in the interest of completeness: echo *
How do I click a button on a vb6 form?
|vb6|
I have a vb6 form with an ocx control on it. The ocx control has a button on it that I want to press from code. How do I do this? I have: Dim b As CommandButton Set b = ocx.GetButton("btnPrint") SendMessage ocx.hwnd, WM_COMMAND, GetWindowLong(b.hwnd, GWL_ID), b.hwnd but it doesn't seem to work.
The speed initially seemed substantially improved. One interesting thing is that it keeps locking up the Google REader tab, it's gotten the sad-face at least 5 times over this morning...
@hamishmcn Generally that's a bad idea.. Temporary tables in oracle should just be created and left (unless its a once off/very rarely used). The contents of the temporary table is local to each session and truncated when the session is closed. There is little point in paying the cost of creating/dropping the tempo...
Lutz Roeder (of Reflector fame) has a WYSIWYG HTML editor in .NET on his site here: [http://www.lutzroeder.com/dotnet/][1]. Check out the download called "writer". I haven't used it myself, but it was the first thing that popped into my mind. [1]: http://www.lutzroeder.com/dotnet/
@hamishcmcn Your assertion that '' == Null is simply not true. In the relational world Null should only ever be read to mean "I don't know". The only result you will get from Oracle (and most other decent databases) when you compare a value to Null is 'False'. Off the top of my head the major differences between ...
1. Put file in one folder. 2. Add &#95;&#95;init&#95;&#95;.py file to the folder. Do necessary imports in &#95;&#95;init&#95;&#95;.py 3. Replace multiple imports by one: import folder_name See [Python Package Management][1] [1]: http://docs.python.org/tut/node8.html#SECTION00840000000000000000...
1. Put files in one folder. 2. Add &#95;&#95;init&#95;&#95;.py file to the folder. Do necessary imports in &#95;&#95;init&#95;&#95;.py 3. Replace multiple imports by one: import folder_name See [Python Package Management][1] [1]: http://docs.python.org/tut/node8.html#SECTION0084000000000000000...
You might want to try using [SQL Server Management Objects][1]. This MSDN article has a good sample for prompting and connecting to a SQL server. [1]: http://msdn.microsoft.com/en-us/magazine/cc163409.aspx
[@castaway][1] A select with the same "where" condition works just fine, just not delete. Neither runstats nor reorg table have any affect on the problem. [1]: http://stackoverflow.com/questions/52981/cannot-delete-from-the-database#53169
It really depends on what you need to do. Generally speaking, the bigger the niche is that your company is in, the better chance that you'll find a framework to properly support you. For smaller niches, you'll more than likely need to roll your own. The company I work for has several apps all geared twoards estima...
ADO.NET has the handy ConnectionStringBuilder which will construct and validate a connection string. This would at least take the grunt work out of one part, allowing you to create a simple dialog box for the input.
The only "built in" connection string functionality that I could think of is the one that comes up when you run a CMD script (essentially a batch file) that runs SQL scripts. However I'm not sure if it's something built into Visual Studio. It's really simple to make one anyway. If you don't want the user to be able ...
From Hacker's Delight: int hibit(int i) { i |= (i >> 1); i |= (i >> 2); i |= (i >> 4); i |= (i >> 8); i |= (i >> 16); return i - (i >> 1); }
From Hacker's Delight: int hibit(unsigned int n) { n |= (n >> 1); n |= (n >> 2); n |= (n >> 4); n |= (n >> 8); n |= (n >> 16); return n - (n >> 1); } This version is for 32-bit ints, but the logic can be extended for 64-bits or higher.
@Harley From [Style Guide for Python Code][1]: > **The preferred way of wrapping long lines is by using Python's implied > line continuation inside parentheses, > brackets and braces.** If necessary, > you can add an extra pair of > parentheses around an expression, but > sometimes using a backslash looks ...
I would not suggest to learn a "modern assembler language". However knowing a little about [MOS 6510][1] Assembler and browsing through the disassembled [C64][2] Kernel, a.k.a. it's OS and BASIC Interpreter, helped me a lot to understand what's going on inside a computer - stuff like interrupts and memory pages. ...
You should look at the following article: http://en.wikibooks.org/wiki/C%2B%2B_Programming/Type_Casting. It contains a good description of all of the different cast types. The following taken from the above link: const_cast const_cast<T>(expression) The const_cast<>() is used to add/remove const(ness) (or volat...
How to get rid of VSMacros80 folder from project root?
|visual-studio|
How can I have it so Visual Studio doesn't keep re-creating this folder that I never use. It's annoying ot keep looking and unnecessary.
>> Therefore I am assuming JavaScript needs access to your cookies. All HTTP requests from your browser transmit your cookie information for the site in question. JavaScript can both set and read cookies. Cookies are not by definition required for Ajax applications, but they are required for most web applications to...
As clarification - from the server's perspective, the page that is requested by an AJAX request is essentially no different to a standard HTTP get request done by the user clicking on a link. All the normal request properties: user-agent, ip, session, cookies, etc. are passed to the server.
We have a SProc that adds audit columns to a given table, and (optionally) creates a history table and associated triggers to track changes to a value. Unfortunately, company policy means I can't share, but it really isn't difficult to achieve.
I don't think a GUID gives you many benefits. Users hate long, incomprehensible URLs. Create a shorter ID that you can map to the URL, or enforce a unique user name convention (http://example.com/user/brianly). The guys at [37Signals][1] would probably mock you for worrying about something like this when it comes to...
Log4Net configuring log level
|log4net|
How do I make Log4net only log Info level logs? Is that even possible? Can you only set a threshold? This is what i have, and it logs Info and above as i would expect. Is there anything i can do to make it only log info. <logger name="BrokerCollection.Model.XmlDocumentCreationTask"> <appender-ref ref="...
How do I make [Log4net][1] only log Info level logs? Is that even possible? Can you only set a threshold? This is what i have, and it logs Info and above as i would expect. Is there anything i can do to make it only log info. <logger name="BrokerCollection.Model.XmlDocumentCreationTask"> <appender-ref ...
How do I make [Log4net][1] only log Info level logs? Is that even possible? Can you only set a threshold? This is what i have, and it logs Info and above as i would expect. Is there anything i can do to make it only log info. <logger name="BrokerCollection.Model.XmlDocumentCreationTask"> <appender-ref...
"*However, the VS designer doesn't seem to implement such Getters/Setters for those public objects that are components on a form (and therefore does not comply with good programming practice).*" If you mean the controls you're dragging and dropping onto the form, these are marked as private instance members and are ...
"*However, the VS designer doesn't seem to implement such Getters/Setters for those public objects that are components on a form (and therefore does not comply with good programming practice).*" If you mean the controls you're dragging and dropping onto the form, these are marked as private instance members and are ...
As long as Google can find finalcog.com/uk and finalcog.com/au, it'll index all three versions of the site. Your domain's Google juice should apply to all three URLs just fine if they're on the same domain.
i believe [open office][1] can create .doc files [1]: http://www.openoffice.org/
i believe [open office][1] can both open .html files and create .doc files [1]: http://www.openoffice.org/
We currently use C-style casts everywhere. I asked the other [casting question](http://stackoverflow.com/questions/28002), and I now see the advantage of using static_cast instead, if for no other reason than it's "greppable" (I like that term). I will probably start using that. I don't like the C++ style; it looks ...
I believe this should do the trick: $srcImage = imagecreatefrompng($uploadTempFile); imagealphablending($srcImage, false); imagesavealpha($srcImage, true); *edit:* Someone in the PHP docs claims `imagealphablending` should be true, not false. YMMV.
Thanks for all the answers. So RAM is the key. As far as dual monitor capability, I found that I could use dual monitors, as long as one of those monitors was my actual machine. And that was what I wanted anyway. Mike
XSLT Array Length
|xslt|
In XLST how woud you find out the length of an array?
XSLT nodesets Length
|xslt|nodesets|
In XLST how woud you find out the length of an nodesets?
The only way to do that would be to run each section of the word through a dictionary. "mynameisfred" is just an array of characters, splitting it up into my Name Is Fred means understanding what the joining of each of those characters means. You could do it easily if your input was separated in some way, e.g. "m...
I tried to remove the reportStream Attachment: //if (reportStream != null) //emailMessage.Attachments.Add(new Attachment(reportStream, reportName)); And now it works fine. So it is something to do with the reportStream.
Passing null to a method
|java|null|assert|
I am in the middle of reading the excellent [Clean Code](http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) One discussion is regarding passing nulls into a method. public class MetricsCalculator { public double xProjection(Point p1, Point p2) { return (p2.x ...
My experience is fairly limited to somewhat simple games (developed with SDL and C++) but I have found that it is quite easy just to implement a static frame rate. Are you working with 2d or 3d games? I would assume that more complex 3d environments would benefit more from a variable frame rate and that the difficult...
I talked to a few co-workers and they don't have anything aside VIM for fasta files. Most of the time you don't search for a string though, but an EST (for substrings, obviously alignments and trees), so this isn't that common of a thing to attempt
I talked to a few co-workers and they just use VIM/Grep to search when they need to. Most of the time I wouldn't expect someone to search for a substring like this though. But I don't see why MS Desktop search or spotlight or google's equivalent can't help you here. My recommendation is splitting the file up --by...
Conditional formating - percentage to color conversion
|c#|colors|
I'm a little bit stuck here - I know this is basics, but it's Sunday and I figured this would be the type of question that get answered in 10min on Stack Overflow, and it might even be a fun one to answer... What's the easiest way to convert a percentage to a color ranging from Green (100%) to Red (0%), with Yellow ...
I'm a little bit stuck here - I know this is basics, but it's Sunday and I figured this would be the type of question that get answered in 10min on Stack Overflow, and it might even be a fun one to answer... What's the easiest way to convert a percentage to a color ranging from Green (100%) to Red (0%), with Yellow ...
|c#|colors|rgb|conversion|
Conditional formatting -- percentage to color conversion
|c#|colors|rgb|
|c#|colors|rgb|
What's the easiest way to convert a percentage to a color ranging from Green (100%) to Red (0%), with Yellow for 50%? I'm using plain 32bit RGB - so each component is an integer between 0 and 255. I'm doing this in C#, but I guess for a problem like this the language doesn't really matter that much. Based on Mari...
You want to segment your code. Part of it should be a 16-bit CRC of the rest of the code. If all you want is a verification number then just use a sequence number (assuming you have a single point of generation). That way you know you are not getting duplicates. Then you prefix the sequence with a CRC-16 of...
Refactored? Delete a From Table a Inner Join ( Select Top (Select Count(tableID) From Table) - 10) From Table Order By tableID Desc ) b On b.tableID = A.tableID _edit: tried them both in the query analyzer, current answer is fasted (damn order by...)_
Using JQuery may not be the route you want to take since this would be on the client side... Is there a reason you're not encrypting on server side?
As project manager you have to remember that the best you will ever we be able to do *on your own* is give your best guess as to how long a given project will take. How accurate you are. depends on your experience and the scope of the project. The only way I know of to get a reasonably accurate estimate that is it t...
Another option would be to investigate using a Powershell script There are a lot powershell community snap ins to support VMs and active directory. [Active Directory Script Rescources][1] [Powershell Script Library][2] [Microsoft Script Resources][3] [VMWARE VI Toolkit (for Windows)][4] [1]: http://w...
**Yes** and **No**. **No**, you cannot limit the results within the LinqDataSource control. Because Linq uses deferred execution, the expectation is that the presentation control will do the recordset limits. **Yes**, you can do this with a ListView control. The trick is to use the [DataPager](http://msdn.microso...
**Yes** and **No**. **No**, you cannot limit the results within the LinqDataSource control. Because Linq uses deferred execution, the expectation is that the presentation control will do the recordset limits. **Yes**, you can do this with a ListView control. The trick is to use the [DataPager](http://msdn.microso...
> And I seem to be completely overlooking where the system tells me about resizes. Likewise the hit testing. For the resizing you're indeed missing the [SizeChanged][1] event. AFAIK there is sadly no OnSizeChanging, OnLocationChanging and OnStateChanging event on a [Window][2] in .NET [1]:http://msdn.microsoft.com...
> And I seem to be completely overlooking where the system tells me about resizes. Likewise the hit testing. For the resizing you're indeed missing the [SizeChanged][1] event. AFAIK there is sadly no OnSizeChanging, OnLocationChanging and OnStateChanging event on a [Window][2] in .NET [1]:http://msdn.microsoft.com...
mailto link for large bodies
|mailto|
I have a page upon which a user can choose up to many differ paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can bee too long for a mailto link. Any way around this? Thanks
I have a page upon which a user can choose up to many differ paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can bee too long for a mailto link. Any way around this? Thanks.
For what it's worth, I've seen a long running stored procedure (9+ seconds) drop to just a few hundred milliseconds of run time simply by switching from GUID primary keys to integers. That's not to say *displaying* a GUID is a bad idea, but as others have pointed out, joining on them, and indexing them, by definition, ...
Default Form Button in FireFox
|asp.net|vb.net|