instruction
stringlengths
0
30k
In C# WinForms, what's the proper way to get the backward/forward history stack for the System.Windows.Forms.WebBrowser?
|c#|winforms|navigation|webbrowser|mshtml|
In C# WinForms, what's the proper way to get the backward/forward history stacks for the System.Windows.Forms.WebBrowser?
What are some best practices for creating my own custom exception?
|c#|.net|exception|
In a follow-up to a [previous question][1] regarding exceptions, what are best practices for creating a custom exception in .NET? More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception? [1]: http://stackoverflow.com/questions/54789/what-is-the-co...
I use a simple little program called '[BareTail][1]' which displays plain text files, updating it's display as the file gets written to and follows (or wraps) to the bottom of the file. When running outside the debugger you'll need to attach a file-writer to write out the trace information, which you can do by [addi...
Problem with .net app under linux, doesn't work from shell script
|svn|mono|linux|.net|
|.net|linux|svn|mono|
I'm working on a .net post-commit hook to feed data into OnTime via their Soap SDK. My hook works on Windows fine, but on our production RHEL4 subversion server, it won't work when called from a shell script. <pre> #!/bin/sh /usr/bin/mono $1/hooks/post-commit.exe "$@" </pre> When I execute it with parameters fro...
I'm working on a .net post-commit hook to feed data into OnTime via their Soap SDK. My hook works on Windows fine, but on our production RHEL4 subversion server, it won't work when called from a shell script. <pre> #!/bin/sh /usr/bin/mono $1/hooks/post-commit.exe "$@" </pre> When I execute it with parameters fro...
Can I change the appearance of an html image during hover without a second image?
|html|css|image|
Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file?
Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)?
Sealing as much classes as possible should also help. AFAIK this is one trick that SmartAssembly uses to reduce memory consumption.
The Rails way is to have [skinny controllers and fat models][1]. [1]: http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model
[HttpRequest.ServerVariables][1] Property is a read-only collection. So, you cannot directly modify that. I would suggest storing your custom data in [httpcontext][2] (or global application object or your database) from your httpmodule and then reading that shared value in the aspx page. If you still want to modify ...
start = r"^\s*#define\s+" continuation = r"(?:.*\\\n)+" lastline = r".*$" re_multiline_macros = re.compile(start + continuation + lastline, re.MULTILINE)
there was a good essay from Joel on software (making wrong code look wrong I think, I'm on my phone otherwise I'd have a URL for you) that covered the correct use of Hungarian notation. The short version would be something like: Var dsFirstName, uhsFirstName : String; Begin uhsFirstName := request.queryfiel...
Yes. The easiest way is to raise the value as a string. Like so: `raise @foo.to_s` Or, you can install the debugger (`gem install ruby-debug`), and then start the development server with the `--debugger` flag. Then, in your code, call the `debugger` instruction. Inside the debugger prompt, you have many commands,...
If you have a controller instance variable named `@foo`, then in your controller you can simply do something like: logger.debug "@foo is: #{@foo}" Additionally, you can output the value in your view template using: <%= debug @foo %>
Sorry for the short answer but it is late. Google "oracle event 10046 sql trace". It would be best to trace an individual session because figuring which SQL belongs to which session from v$sql is no easy if it is shared sql and being used by multiple users. If you want to impress your Oracle DBA friends, learn how t...
asp consuming a web service, what do do with recordset object ?
|asp.net|asp|upgrading|web-services|
Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion. I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net. The site itself remains ASP for the mome...
|asp.net|web-services|asp|upgrading|
Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion. I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net. The site itself remains ASP for the mome...
|asp.net|web-services|asp|asp-classic|upgrading|
Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion. I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net. The site itself remains ASP for the mome...
Forget Java - it is not going to bring you anywhere closer to C (you have allready proved that you don't have a problem learning new syntax). Either read K&R or go one lower: Learn about the machine itself. The only tricky part in C is pointers and memory management (which is closely related to pointers, but also ha...
C is a bridge onto itself. K&R is the only programming language book you can read in one sitting and almost never pick it up again ...
My suggestion is to get a good C-book that is relevant to what you want to do. I agree that K & R is considered to be "The book" on C, but I found "UNIX Systems Programming" by Kay A. Robbins and Steven Robbins to be more practical and hands on. The book is full of clean and short code snippets you can type in, compile...
I think C++ is a good "bridge" to C. I learned C++ first at University, and since it's based on C you'll learn a lot of the same concepts - perhaps most notably pointers - but also Object Oriented Design. OO can be applied to all kinds of modern languages, so it's worth learning. After learning C++, I found it w...
[OraPowerTools](http://www.dkgas.com/) will do the job. There is also a "Diff Wizard" in [Oracle SQL Developer](http://www.oracle.com/technology/software/products/sql/index.html), but I haven't used it yet.
There are also appropriate methods of the `CListViewCtrl` and `CTreeViewCtrl` wrapper classes: - GetBkColor - SetBkColor
Use [Advanced Encryption Standard][1] (AES). It supports Key lengths of 128, 192, or 256 bits. The [algorithm][2] is simple. The Sun Java website has a [section explaining how to do AES][3] encryption in Java. From Wikipedia... > ... the Advanced > Encryption Standard (AES), also known > as Rijndael, is a bl...
Use [Advanced Encryption Standard][1] (AES). It supports Key lengths of 128, 192, or 256 bits. The [algorithm][2] is simple. The Sun Java website has a [section explaining how to do AES][3] encryption in Java. From Wikipedia... > ... the Advanced > Encryption Standard (AES), also known > as Rijndael, is a bl...
It depends a bit on your needs. Some toolkits are better at drawing, others are better for writing text. [Cairo][1] has a pretty good for drawing (it support a wide range of screen and file types, including pdf), but it may not be ideal for good typography. [1]: http://en.wikipedia.org/wiki/Cairo_(graphics)
Ok I might have this sorted. I have changed the database config resource to the following: *SNIP* maxActive="10" maxIdle="5" maxWait="7000" removeAbandoned="true" logAbandoned="false" removeAbandonedTimeout="3" *SNIP* This works well enough for now. What is happening, afaik,...
Copy files on Windows Command Line with Progress
|windows|batch-file|scripting|
Does anyone know of a windows commmand-line ( available on XP Pro or later by default ) that could copy a file while showing progress. I do not care if the progress indicator is in a terminal or a GUI window. This is intended to be used during batch file scripting
What tool do you use for counting lines of source code in Visual Studio Projects ?
|visual-studio|code-analysis|
I know there are quite a few line count tools around. Is there something simple that's not a part some other big package that you use ?
[robocopy][1]. [1]: http://en.wikipedia.org/wiki/Robocopy
Slick Edit Gadgets has a nice report breaking it down by lines of code, whitespace and comments. The plug-in is free and relatively small. http://www.slickedit.com/content/view/441
If you are using VIM, you can use "*p (i.e. double quotes, asterisk, letter p).
You can assert on the ActionResult that is returned, you'll need to cast it to the appropriate type but it does allow you to use state-based testing. A search on the Web should find some useful links, here's [just one][1] though. [1]: http://sebastienlachance.com/2008/05/06/testing-controllers-in-aspnet-mvc-aka-...
Databinding an enum property to a ComboBox in WPF
|wpf|.net|
As an example take the following code: public enum ExampleEnum { FooBar, BarFoo } public class ExampleClass : INotifyPropertyChanged { private ExampleEnum example; public ExampleEnum ExampleProperty { get { return example; } { /* set and notify */; } } } I want a...
You could put a hidden input on the page, and after the page loads, give it a value. Then you can check that field, if it was in the post data, it's a postback, otherwise it is not.
You could put a hidden input on the page, and after the page loads, give it a value. Then you can check that field, if it was in the post data, it's a postback, otherwise it is not. There were two solutions that used server side code (ASP.NET specific) posted as responses. I think it is worth pointing out that thi...
Two things come to mind: **1 -** You can repeatedly outer-join the table to itself to recursively walk up your tree, as in: SELECT * FROM MY_GROUPS MG1 ,MY_GROUPS MG2 ,MY_GROUPS MG3 ,MY_GROUPS MG4 ,MY_GROUPS MG5 ,MY_GROUP_MEMBERS MGM WHERE MG1.PARENT_ID = MG2.UNI...
Two things come to mind: **1 -** You can repeatedly outer-join the table to itself to recursively walk up your tree, as in: SELECT * FROM MY_GROUPS MG1 ,MY_GROUPS MG2 ,MY_GROUPS MG3 ,MY_GROUPS MG4 ,MY_GROUPS MG5 ,MY_GROUP_MEMBERS MGM WHERE MG1.PARENT_ID = MG2.UNI...
* Use tabs for indentations, but align data with spaces This means people can decide how much to indent by changing the tab size, but also that things stay aligned (eg you might want all the '=' in a vertical line when assign values to a struct) * Allways use constants or inline functions instead of macros where po...
1. Delete unnecessary code. That is all.
For safety critical embedded application certifying agencies require to satisfy the "proven-in-use" requirement for the compiler. There are typically certain requirements (kind of like "hours of operation") that need to be met and proven by detailed documentation. However, most people either cannot or don't want to mee...
for apache: sudo apt-get -yq install apache2 for ssh sudo apt-get -yq install openssh-server for subversion sudo apt-get -yq install subversion subversion-tools If you'd like you can combine these into one command like: sudo apt-get -yq apache2 openssh-server subversion subversion-tools...
Guidelines to improve your code
|c++|guidelines|
What guidelines do you follow to improve the general quality of your code? Many people have rules about how to write C++ code that (supposedly) make it harder to make mistakes. I've seen people _insist_ that every `if` statement is followed by a brace block (`{...}`). I'm interested in what guidelines other people f...
Justin, I'd try [djangosearch][1] first: Jacob Kaplan-Moss (Django's lead developer) is working on it. Potential hazards: * The home page warns the API might not be entirely stable Potential benefits: * “The long term goal is for this to become `django.contrib.search`.” [1]: http://code.google.com/p/...
Web service - current time zone for a city?
|web-services|timezone|
Is there a web service of some sort (or any other way) to pull a current time zone settings for a (US) city. For the parts of the country that don't follow the Daylight Saving Time and basically jump timezones when everyone else is switching summer/winter time... I don't fancy creating own database of the places that d...
Is there a web service of some sort (or any other way) to pull a current time zone settings for a (US) city. For the parts of the country that don't follow the Daylight Saving Time and basically jump timezones when everyone else is switching summer/winter time... I don't fancy creating own database of the places that d...
Is there really need to save the hashed password into the file. Can't you just use the password (or hashed password) with some salt and then encrypt the file with it. When decrypting just try to decrypt the file with the password + salt. If user gives wrong password the decrypted file isn't correct. Only drawbacks I...
Win32 CreatePatternBrush
|winapi|gdi|
MSDN displays the following for CreatePatternBrush: > You can delete a pattern brush without > affecting the associated bitmap by > using the DeleteObject function. > Therefore, you can then use this > bitmap to create any number of pattern > brushes. My question is the opposite. If the HBRUSH is long lived,...
Geonames.org has a wonderful set of worldly data that's available via webservice or download: http://www.geonames.org/export/ws-overview.html
If catching all exceptions - including OS ones - is really what you need, you need to take a look at your compiler and OS. For example, on Windows you probably have "__try" keyword or compiler switch to make "try/catch" catch SEH exceptions, or both.
What is the cleanest way to direct wxWidgets to always use wxFileConfig ?
|c++|wxwidgets|
I am writing my first serious wxWidgets program. I'd like to use the wxConfig facility to make the program's user options persistent. However I *don't* want wxConfigBase to automatically use the Windows registry. Even though I'm initially targeting Windows, I'd prefer to use a configuration (eg .ini) file. Does anyone ...
I have had good success in the past with http://www.bouncycastle.org/ (they have a C# version as well).
Approximate string matching algorithms
|algorithm|string|
Here at work, we often need to find a string from the list of strings that is the closest match to some other input string. Currently, we are using Needleman-Wunsch algorithm. The algorithm often returns a lot of false-positives (if we set the minimum-score too low), sometimes it doesn't find a match when it should (wh...
The problem seams to be the ending of the file... If I name the file [test2.html][1] everything works. If I name the file [test2.xhtml][2] I get the error message. The diverence between the two seams to be the Content-Type in the response header from apache. - For .html it is Content-Type text/html; charset=I...
The problem seams to be the ending of the file... - If I name the file [test2.html][1] everything works. - If I name the file [test2.xhtml][2] I get the error message. The diverence between the two seams to be the Content-Type in the response header from apache. - For .html it is Content-Type text/html;...
Compile your code with debug symbols, enter unlimit coredumpsize in your shell and you'll get a coredump in the same folder as the binary. Use gdb/ddd - open the program first and then open the core dump. You can check [this](http://www.agsrhichome.bnl.gov/Controls/doc/crashFiles/crashFiles.html) out for additional inf...
We are using the [Levenshtein distance][1] method to check for duplicate customers in our database. It works quite well. [1]: http://en.wikipedia.org/wiki/Levenshtein_distance
Why not just have the sequence as increment by 100 all the time? each "nextval" gives you 100 sequence numbers to work with SQL> create sequence so_test start with 100 increment by 100 nocache; Sequence created. SQL> select so_test.nextval from dual 2 ; NEXTVAL --...
you can also try using the register_tick_function function in php. which tells php to call a certain function periodcally through out your code. You could then keep track of which function is currently running and the amount of time between calls. then you could see what's taking the most time. http://www.php.net/reg...
or My.Computer.Name
Server-side, write: if(IsPostBack) { ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack", "var isPostBack = true;", true); } Then, in your script which runs for the onLoad, check for the existence of that variable: if(isPostBack) { // do your thing } -----...
Server-side, write: if(IsPostBack) { // NOTE: the following uses an overload of RegisterClientScriptBlock() // that will surround our string with the needed script tags ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack", "var isPostBack = true;", true); } Then, ...
How do I get a custom application name and starting window name in Visual C# 2008 using WPF?
|c#|visual-studio-2008|
I'm using Microsft Visual C# 2008 and am creating WPF applications. If you create a new solution and pick the WPF application template it lets you provide a single string to name the solution. It then automatically turns that string into a base project name and a namespace using underscores instead of spaces. It ...
How do you generate and analyze a thread dump from a running JBoss instance?
|java|multithreading|dump|
How do you generate and analyze a thread dump from a running JBoss instance?
You can't do it from a web page. One of the main purposes of a web browser is to protect users from the internet. They define a very specific set of things that web sites can do, and disabling buttons isn't in the list. On the other hand, if you're a network admin and just want to mess with your users, you might b...
|c++|coding-style|guidelines|