instruction
stringlengths
0
30k
.NET Production Debugging
|.net|debugging|
I've had a Windows app in production for a while now, and have it set up to send us error reports when it throws exceptions. Most of these are fairly descriptive and help me find the problem very quickly (I use the MS Application Exception Block). On a few occasions I have reports that are issues that I can't repro...
I've had a Windows app in production for a while now, and have it set up to send us error reports when it throws exceptions. Most of these are fairly descriptive and help me find the problem very quickly (I use the MS Application Exception Block). On a few occasions I have reports that are issues that I can't repro...
Best way to hide DB connection code in PHP5 for apps that only require one connection?
|php|oop|php5|
Below I present three options for simplifying my database access when only a single connection is involved (this is often the case for the web apps I work on). The general idea is to make the DB connection transparent, such that it connects the first time my script executes a query, and then it remains connected unt...
For Oracle SELECT * FROM messages WHERE messageTime > SYSDATE - 1 (The psuedo variable SYSDATE includes the time, so sysdate -1 will give you the last 24 hrs)
That `ptr` is displayed as nicely-formatted string and `cwd` as "byte buffer" is probably specific to gdb. In any case it shouldn't affect your application; according to `man 3 getcwd`, `ptr` should point to `cwd` (or it should be NULL if an error occurred). Can you use `ptr` without crashing the program?
Our repository looks like: /trunk /branches /sandbox /vendor /ccnet **/trunk** is your standard, bleeding edge development. We use CI so this must always build and pass tests. **/branches** this is where we put 'sanctioned' large changes, ie something we KNOW will make it into trunk b...
The short answer is that you're supposed to use the left/right arrow keys when focus is within the bar--this is a fairly standard GUI behavior (you also see this in other places like radio button groups). If you look into the [SDK source for ButtonBar][1], it explicitly disables tab focus for each child button as it's...
The component is written so the user must press the left/right arrow keys when focus is within the bar to traverse the buttons--this is a fairly standard GUI behavior (you also see this in other places like radio button groups). If you look into the [SDK source for ButtonBar][1], you can see where they've explicitly d...
I came from a Java background to Ruby to. I found this tutorial helpful <http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-java/>. When it comes to learning rails I cannot say how much I use script\console. It allows you to play with the code and learn how to do things that you are not ...
From the C++ standard, referring to the `sizeof` operator: > When applied to an array, the result is the total number of bytes in the array. This implies that the size of an array of `n` elements is `n` times the size of an element. From this, I'd say that `double[4][4]` and `double[16]` would have to have the same...
From the C++ standard, referring to the `sizeof` operator: > When applied to an array, the result is the total number of bytes in the array. This implies that the size of an array of `n` elements is `n` times the size of an element. From this, I'd say that `double[4][4]` and `double[16]` would have to have the same...
If you are willing to go the commercial route check out [FishEye](http://www.atlassian.com/software/fisheye/) from Atlassian (also see their [demo site](http://www.cenqua.com/fisheye/demo) ). FishEye also supports adding [plugins](http://confluence.atlassian.com/display/FISHEYE/Developing+Fisheye+and+Crucible+Plugins)...
Java Slightly shorter version of the Java solution. class X{public static void main(String[]a){main(a);}}
You'll just have to foreach through them and int.TryParse each one of them. after that just add to the list. Nevermind - @Splash beat me to it
Raising an exception is the fastest way if you just need to look at a value, but it's worth the time to learn how to use the debugger properly. It's rare that you would only need to just see the value of a variable, you are likely trying to find a bug in your code, and that's what a debugger is for. Sending the in...
You can instantiate a List&lt;T&gt; from an array. VB.NET: Dim lstIDs as new List(of Integer)(ids.split(',')) This is prone to casting errors though if the array contains non-int elements
Alway use a key that has no business meaning. It's just good practise.
Alway use a key that has no business meaning. It's just good practise. EDIT: I was trying to find a link to it online, but I couldn't. However in ['Patterns of Enterprise Archtecture'][1] [Fowler] it has a good explanation of why you shouldn't use anything other than a key with no meaning other than being a key. ...
Alway use a key that has no business meaning. It's just good practice. EDIT: I was trying to find a link to it online, but I couldn't. However in ['Patterns of Enterprise Archtecture'][1] [Fowler] it has a good explanation of why you shouldn't use anything other than a key with no meaning other than being a key. ...
It's fine to return multiple values using a tuple for simple functions such as `divmod`. If it makes the code readable, it's Pythonic. If the return value starts to become confusing, check whether the function is doing too much and split it if it is. If a big tuple is being used like an object, make it an object. Al...
In Scheme, this will cause the interpreter to run out of memory: (define (x) ((x))) (x)
You can also take a screenshot of your app as an aid to creating the Default.png - while holding the Home button, press and release the Lock Sleep/Wake button. The screenshot can be find in your Camery Roll library in the Photos app and can be synced back to your desktop.
SELECT (CASE WHEN (Obsolete = 'N' OR InStock = 'Y') THEN 1 ELSE 0 END) as Salable, * FROM Product
How are callbacks written in PHP?
Implementation of a callback is done like so // This function uses a callback function. function doIt($callback) { $data = "this is my data"; $callback($data); } // This is a sample callback function for doIt(). function myCallback($data) { ...
You need to turn assignable constants on.
You need to turn assignable typed constants on. Project -> Options -> Compiler -> Assignable typed Constants Also you can add {J+} to the pas file, which is probably better, since it'll work even if you move the file to another project.
Not a VIM user myself, so forgive me if this is totally offbase. But according to what I gather from the following [VIM Tips][1] site: > " where was an option set > :scriptnames : list all plugins, _vimrcs loaded (super) > :verbose set history? : reveals value of history and where set > :funct...
Linux Lightweight Distro and X Windows for Development
|linux|desktop|lightweight|
I want to build a lightweight linux configuration to use for development. The first idea is to use it inside a Virtual Machine under Windows, or old Laptops with 1Gb RAM top. Maybe even a distributable environment for developers. So the whole idea is to use a LAMP server, Java Application Server (Tomcat or Jetty) an...
I want to build a lightweight linux configuration to use for development. The first idea is to use it inside a Virtual Machine under Windows, or old Laptops with 1Gb RAM top. Maybe even a distributable environment for developers. So the whole idea is to use a LAMP server, Java Application Server (Tomcat or Jetty) an...
If you set the background color and have a negative right margin on the image, the image will cover the external link image. Example: <style> a[href^="http:"] { background: url(http://en.wikipedia.org/skins-1.5/monobook/external.png) right center no-repeat; padding-right: 14px; ...
I lean towards a variable framerate model, but internally some systems are ticked on a fixed timestep. This is quite easy to do by using a time accumulator. Physics is one system which is best run on a fixed timestep, and ticked multiple times per frame if necessary to avoid a loss in stability and keep the simulation ...
Unless I misunderstood you: Just place cursor on the line you want to cut (no selection) and press Ctrl + x. That cuts the line (leaving no blanks) and puts the text in the Clipboard. (tested in *MS VC# 2008 Express* with no additional settings I'm aware of) Is that what you want?
What type is cwd? The above code snippet doesn't tell us that. It could be that ptr being a void* is treated differently by gdb.
Don't select anything, just hit ctrl-x when the cursor is on the line.
It doesn't sound so much like a question about tables/columns, but about normalization. In some situations have a high degree of [normalization][1] ("more tables" in this case) is good, and clean, but it typically takes a high number of JOINs to get relevant results. And with a large enough dataset, this can bog down p...
It doesn't sound so much like a question about tables/columns, but about normalization. In some situations have a high degree of [normalization][1] ("more tables" in this case) is good, and clean, but it typically takes a high number of JOINs to get relevant results. And with a large enough dataset, this can bog down p...
*Prefer composition over inheritance as it is more malleable / easy to modify later. But do not use a compose-always approach.* With Composition, its easy to change behavior on the fly with Dependency Injection / Setters. Inheritance if more rigid as most languages do not allow you to derive from more than one type.. S...
Have you considered the win+e hotkey? It isn't quite what you want, but might be close enough.
Typed datasets are by far an upgrade from the world of classic ADO disconnected recordsets. I have found that they are still nice to use in simple situations where you need to perform some sort task that's row oriented -- i.e. you still want to work in the context of a database paradigm of rows, columns, constraints a...
explorer -d c:\path
If you want to do this the Lisp Way, you should use recursion to return the new list: (defun biggerElems (x xs) (cond ((null xs) NIL) ((< x (car xs)) (biggerElems x (cdr xs))) (t (cons (car xs) (biggerElems x (cdr xs))))))
If you want to do this the Lisp Way, you could use recursion to return the new list: (defun biggerElems (x xs) (cond ((null xs) NIL) ((< x (car xs)) (biggerElems x (cdr xs))) (t (cons (car xs) (biggerElems x (cdr xs)))))) @Luís Oliveira This solution is to con...
You will need to use some P/Inovke interop code to do this. Look for the Win32 API SendMessage function and the EM_SETCUEBANNER message.
There is built-in functionality in the text box control -- [AutoCompleteMode][1] and [AutoCompleteSource][2]. They may be worth a try before you go into custom or 3rd party controls. [1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.autocompletemode.aspx [2]: http://msdn.microsoft.com...
I think it's this line that's not right: (setf xst (remove elem xs)))) The first argument to `setf` is the place, followed by the value. It looks like you have it backwards (and `xst` is either `nil` or uninitialized). You might find it easier to do this: (defun biggerElems (x xs) (remov...
I think it's this line that's not right: (setf xst (remove elem xs)))) The first argument to `setf` is the place, followed by the value. It looks like you have it backwards (and `xst` is either `nil` or uninitialized). You might find it easier to do this: (defun biggerElems (x xs) (remov...
What's a good method for extracting text from a PDF using C# or classic ASP (VBScript)?
|pdf|text-extraction|
Is there a good library for extracting text from a PDF? I'm willing to pay for it if I have to. Something that works with C# or classic ASP (VBScript) would be ideal and I also need to be able to separate the pages from the PDF. [This question](http://stackoverflow.com/questions/25665/python-module-for-convertin...
There are a lot of links after this [brief overview][1] of what is involved in writing an OS for the X86 platform. The link that appears to be [most promising][2] is down, so you'll need to poke through the [Archive.org version][3] to read it. At the end of the day the bootloader takes the machine code of the ker...
Based on NilObject's code: #include <sys/stat.h> off_t fsize(const char *filename) { struct stat st; if (stat(filename, &st) == 0) return st.st_size; return -1; } Changes: * Made the filename argument a `const char`. * Corrected the `st...
Based on NilObject's code: #include <sys/stat.h> off_t fsize(const char *filename) { struct stat st; if (stat(filename, &st) == 0) return st.st_size; return -1; } Changes: * Made the filename argument a `const char`. * Corrected the `st...
Based on NilObject's code: #include <sys/stat.h> off_t fsize(const char *filename) { struct stat st; if (stat(filename, &st) == 0) return st.st_size; return -1; } Changes: * Made the filename argument a `const char`. * Corrected the `st...
SELECT (CASE WHEN (Obsolete = 'N' OR InStock = 'Y') THEN 'YES' ELSE 'NO' END) as Salable, * FROM Product
Shell script solution in **10 characters** including newlines: Well, technically not stack overflow but logically so, if you consider spawning a new process as constructing a new stack frame. #!sh ./so Result: antti@blah:~$ ./so [disconnected] Whoops. Note: **don't try this at home** ...
Screen + vim causes shift-enter to insert 'M' and a newline
|vim|screen|gnu-screen|ide|editor|
When running a vim instance in gnu screen hitting shift enter in insert mode adds an 'M' and then a newline, rather than just a newline. Does anybody know what the problem might be, or where to look? Thanks in advance Relevant system info: > Ubuntu 8.04.1 > Screen version 4.00.03 (FAU) 23-Oct-06 > VIM -...
|ide|vim|editor|gnu-screen|screen|
When running a vim instance in gnu screen hitting shift enter in insert mode adds an 'M' and then a newline, rather than just a newline. Does anybody know what the problem might be, or where to look? Thanks in advance Relevant system info: > Ubuntu 8.04.1 > Screen version 4.00.03 (FAU) 23-Oct-06 > VIM -...
When running a vim instance in gnu screen hitting shift enter in insert mode adds an 'M' and then a newline, rather than just a newline. Does anybody know what the problem might be, or where to look? Thanks in advance Relevant system info: > Ubuntu 8.04.1 > Screen version 4.00.03 (FAU) 23-Oct-06 > VIM -...
I've used it in the inner loops of a game's graphics code, where you want some level of abstraction and modularity but can't pay the cost of branches or virtual calls. Overall it was a better solution than a proliferation of handwritten special-case functions.
Pieter's suggestion is good of course, but one thing you've to bear in mind is that in case of big arrays building it may be quite slow. Every time vector capacity changes, all the data has to be copied around ('n' vectors of vectors).
I find [google notebook][1] is very good for drive by code snippeting and [google bookmarks][2] especially as when used with the google toolbar, for web pages. The benefit of these tools are that they are available from any pc on the web, though a good use of semantic organisation using labels is recommended. The...
I find [google notebook][1] is very good for drive by code snippeting and [google bookmarks][2] especially as when used with the google toolbar, for web pages. The benefit of these tools are that they are available from any pc on the web, though a good use of semantic organisation using labels is recommended. The...
I find [google notebook][1] is very good for drive by code snippeting and [google bookmarks][2] especially as when used with the google toolbar, for web pages. The benefit of these tools are that they are available from any pc on the web, though a good use of semantic organisation using labels is recommended. ...
Also be aware of the affects that the current accepted solution may have on parsing hex, octal, and binary numbers: >> Integer('0x15') # => 21 >> Integer('0b10') # => 2 >> Integer('077') # => 63 In Ruby numbers that start with `0x` or `0X` are hex, `0b` or `0B` are binary, and jus...
If I am understanding your question correctly, you only need to connect to an existing web service and not create your own web service. If that is a case, and maybe I am missing something, I do not believe you will need Tomcat at all. If you are using Netbeans you can create a new Desktop or Web application, and then r...
The type params for generic methods can be specified explicitly like so: Collections.<String,Integer>emptyMap()
How do you communicate between Windows Vista Session 0 and Desktop?
|windows-vista|
In prior versions of Windows before Vista you could have a Windows Service interact with the current logged in desktop user to easy display information on the screen from the service. In Windows Vista Session 0 was added for security to isolate the services from the desktop. What is an easy way to communicate between a...
|windows-vista|ipc|
Even clearer, IMO, is: <%# String.Format("{0} - {1}", Eval("Name1"), Eval("Name2")) %>
yeah, you should be able to create a new group and add the users to that list/subweb/whatever and just that. This is assuming that you didn't grant access to all users somewhere. If you did, then hopefully the default access is granted to a default user group (like sharepoint visitors) and you can alter that group to...
What are the preferred versions of Vim and Emacs on OSX?
|mac|macos|editor|emacs|vim|
For those of us that like to use the graphical version of Vim or Emacs, instead of the console version, which version do you recommend? For Vim, there's [Mac OSX Vim](http://sourceforge.net/projects/macosxvim/), [MacVim](http://code.google.com/p/macvim/), [Vim-Cocoa](http://code.google.com/p/vim-cocoa/). For Emac...
|mac|macos|emacs|vim|editor|
eclipse javascript editor
|javascript|eclipse|plugins|editor|
I'm looking for opinions on the best JavaScript editor available as an Eclipse plugin. I've been using Spket, which is good, but I'm convinced there must be something better out there, is there....? Cheers, Donal
|javascript|eclipse|editor|plugins|
Touch Typing Software recommendations
|editor|touch-typing|
Since the keyboard is **the** interface we use to the computer, I've always thought touch typing should be something I should learn, but I've always been, well, lazy is the word. So, anyone recommend any good touch typing software? It's easy enough to google, but I'ld like to hear recommendations.
Based on NilObject's code: #include <sys/stat.h> off_t fsize(const char *filename) { struct stat st; if (stat(filename, &st) == 0) return st.st_size; return -1; } Changes: * Made the filename argument a `const char`. * Corrected the `st...
Based on NilObject's code: #include <sys/stat.h> off_t fsize(const char *filename) { struct stat st; if (stat(filename, &st) == 0) return st.st_size; return -1; } Changes: * Made the filename argument a `const char`. * Corrected the `st...
Have you considered just writing a small program in C/C++ that just calls [`CreateProcess`](http://msdn.microsoft.com/en-us/library/ms682425.aspx) to start up the java VM with the jar (or class) file? You could get [Visual C++ Express](http://www.microsoft.com/express/vc/) and put together the startup program pretty...
Have you considered writing a small program in C/C++ that just calls [`CreateProcess`](http://msdn.microsoft.com/en-us/library/ms682425.aspx) to start up the java VM with the jar (or class) file? You could get [Visual C++ Express](http://www.microsoft.com/express/vc/) and put together the startup program pretty easi...
I learned everything I know about the DCT from [The Data Compression Book][1]. In addition to being a great introduction to the field of data compression, it has a chapter near the end on lossy image compression which introduces JPEG and the DCT. [1]: http://www.amazon.com/Data-Compression-Book-Mark-Nelson/dp/15...
The reason that `cwd` is printed differently in `gdb` is because `gdb` knows that `ptr` is a `char *` (I guess) and that `cwd` is an array of length `3500` (as shown in your output). So when printing `ptr` it prints the pointer value (and as a service also the string it points to) and when printing `cwd` it prints the ...
You need a class name on either the `a` elements you want to include or exclude. If you don't want to do this in your server side code or documents, you could add the classes with javascript as the page is loaded. It would be possible with XPath to create a pattern like yours that would also exclude `a` that had `im...