instruction
stringlengths
0
30k
From the Class Library design guidelines for errors (<http://msdn.microsoft.com/en-us/library/8ey5ey87(VS.71).aspx>): >In most cases, use the predefined exception types. Only define new exception types for programmatic scenarios, where you expect users of your class library to catch exceptions of this new type and p...
Try putting "cd $1/hooks/" before the line that runs mono. You may have some assemblies in that folder that are found when you run mono from that folder in the shell but are not being found when you run your script.
Interesting question! My own preference is the for the reflection-based syntax (what I guess you mean by the Standard Syntax). I would argue that this is the most frictionless, as it does not add much extra code: you reference the stubs directly on your interfaces as though they were properly implemented. I do a...
Restful URLs for ASP.NET
|asp.net|rest|url|friendly-url|
Python frameworks always provide ways to handle urls that convey the data of the request in an elegant way: think http://somewhere.overtherainbow.com/userid/123424/ I want your to notice the ending path /userid/123424/ How do you do this in ASP.NET?
Friendly URLs for ASP.NET
If you need data you can copy it in the OnDrop, store it in some temporary location, then in the WM_APP range message pass the index to the data in temporary location. The handler for the WM_APP message can clean up the temporary data after showing the message box.
Java might actually be a good option here, believe it or not. It is strongly based on C/C++, so if you can get the syntax and the strong typing, picking up C might be easier. The benefit is you can learn the lower level syntax without having to learn pointers (since memory is managed for you just like in Python and P...
Python is about as close to C as you're going to get. It is in fact a very thin wrapper around C in a lot of places. However, C does require that you know a little more about how the computer works on a low level. Thus, you may benefit from trying an assembly language. [LC-3][1] is a simple assembly language with...
I've always made those decisions on a case by case basis, depending on the use case, such as: - Do I need the ordering to remain? - Will I have null key/values? Dups? - Will it be accessed by multiple threads - Do I need a key/value pair - Will I need random access? And then I break out my handy 5th e...
I've always made those decisions on a case by case basis, depending on the use case, such as: - Do I need the ordering to remain? - Will I have null key/values? Dups? - Will it be accessed by multiple threads - Do I need a key/value pair - Will I need random access? And then I break out my handy 5th e...
Best Way to Unit Test a Website With Multiple User Types with PHPUnit
|unit-testing|types|phpunit|
I'm starting to learn how to use PHPUnit to test the website I'm working on. The problem I'm running into is that I have five different user types defined and I need to be able to test every class with the different types. I currently have a user class and I would like to pass this to each function but I can't figure...
I'm starting to learn how to use PHPUnit to test the website I'm working on. The problem I'm running into is that I have five different user types defined and I need to be able to test every class with the different types. I currently have a user class and I would like to pass this to each function but I can't figure...
You may want to consider the master-master replication scenario, but with a slight twist. You can specify which databases to replicate and limit the replication for each server. For server1 I would add `--replicate-do-db=server_2_db` and on server2 `--replicate-do-db=server_1_db` to your my.cnf (or my.ini on Windows...
Also be aware that _XmlSerializer_ cannot serialize abstract properties.. See my question [here][1] (which I have added the solution code to).. [XML Serialization and Inherited Types][1] [1]:http://stackoverflow.com/questions/20084/xml-serialization-and-inherited-types
In if statements put the constant on the left i.e. if( 12 == var ) not if( var == 12 ) Beacause if you miss typing a '=' then it becomes assignment. In the top version the compiler says this isn't possible, in the latter it runs and the if is always true. I use braces for if's whenever they are not ...
You can try [TreeViewAdv](http://www.codeproject.com/KB/tree/treeviewadv.aspx). It is open source and hosted on sourceforge.
I blogged about a bunch of resources on WPF Commands along with an example last year at http://blogs.vertigo.com/personal/alanl/Blog/archive/2007/05/31/commands-in-wpf.aspx
I blogged about a bunch of resources on WPF Commands along with an example last year at http://blogs.vertigo.com/personal/alanl/Blog/archive/2007/05/31/commands-in-wpf.aspx Pasting here: [Adam Nathan’s sample chapter on Important New Concepts in WPF: Commands][1] [MSDN article: The Command Pattern In WPF][2] ...
I believe what you want is a flag type enum. You need to add the Flags attribute to the top of the enum, and then you can combine enums with the 'Or' keyword. Like this: <Flags()> _ Enum CombinationEnums As Integer HasButton = 1 TitleBar = 2 ReadOnly = 4 ETC = 8 End En...
Here's a utility class I've used for IO tasks like this. using System; using System.Runtime.InteropServices; namespace MyNameSpace { public class ShellFileOperation { private static String StringArrayToMultiString(String[] stringArray) { String multiString =...
How to see the actual Oracle SQL statement that is being executed
|sql|oracle-database|
I'm using a custom-built inhouse application that generates a standard set of reports on a weekly basis. I have no access to the source code of the application, and everyone tells me there is no documentation available for the Oracle database schema. (Aargh!) I've been asked to define the specs for a variant of an e...
About "step 4": > The transaction manager coordinates > with the resource managers to ensure > that all succeed to do the requested > work or none of the work if done, thus > maintaining the ACID properties. This of course requires all participants to provide the proper interfaces and (error-free) implementat...
Eclipse alternative to VS .sln files.
|eclipse|
I've recently had to switch from Visual Studio to Eclipse CDT. It would seem that Eclipse "workspaces" are not quite like VS solution files. Eclipse workspaces use the .metadata folder for managing multiple projects, but there doesn't seem to be a simple distinction between user settings or IDE preferences and projec...
The project triangle is a gross simplification. In lots of cases you can actually save time by improving quality. For example by reducing repairs and avoiding costs in maintenance. This is not only true in software development.Toyota lean production proved that this works in manufacturing too. The whole process of s...
I use scripting languages for writing programs which are not expected to be maintained beyond few executions. Most of these languages are light on boiler-plate syntax and do have a REPL. Both these features enable rapid prototyping. Since you already know Java, you can try JVM languages like Groovy, JRuby, BeanShell...
Prevent Multi-Line ASP:Textbox from trimming line feeds
|c#|asp.net|textbox|postback|
I have the following webform: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWebApp.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http:/...
Take my advice. Ditch PDF for XPS. I am working on two apps, both server based. One displays image-based documents as PDFs in a browser. The second uses FixedPage templates to construct XPS documents bound to data sources. My conclusion after working on both projects is that PDFs suck; XPS documents less so. ...
Modbus - .NET
|.net|open-source|protocols|plc|modbus|
Does anyone know of a good (preferably open source) library for dealing with the Modbus protocol? I have seen a few libraries, but I am looking for some people's personal experiences, not just the top ten Google hits. I figure there has to be at least one other person who deals with PLCs and automation hardware like I ...
|python|arrays|
I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of the ran...
I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of the ran...
Is there a way to get ms-access to display images from external files
A couple of my personal favorites: Strive to write code that is [const correct][1]. You will enlist the compiler to help weed out easy to fix but sometimes painful bugs. Your code will also tell a story of what you had in mind at the time you wrote it -- valuable for newcomers or maintainers once you're gone. G...
A few of my personal favorites: Strive to write code that is [const correct][1]. You will enlist the compiler to help weed out easy to fix but sometimes painful bugs. Your code will also tell a story of what you had in mind at the time you wrote it -- valuable for newcomers or maintainers once you're gone. Get ...
Learn to use your cursor keys. 1. Use Arrow Up/Down to move to the line you want to copy. 2. Hit Home if not there already, and again if it places the cursor after whitespace. 3. Then press **Shift+Down** to select the line (or lines) you want to move 4. Ctrl+X to cut the line. 5. Move Up/Down to the line you wa...
Learn to use your cursor keys. For moving lines I do the following: 1. Use Arrow Up/Down to move to the line you want to copy. 2. Hit Home if not there already, and again if it places the cursor after whitespace. 3. Then press **Shift+Down** to select the line (or lines) you want to move 4. Ctrl+X to cut the l...
There's a pattern that I learned from Twisted Python code. class SMTP: def lookupMethod(self, command): return getattr(self, 'do_' + command.upper(), None) def do_HELO(self, rest): return 'Howdy ' + rest def do_QUIT(self, rest): return 'Bye' ...
I often find IDE's have a preferred way to work. Sure, you might be able to get the IDE to do it your way, but you'll probably end up fighting it all the way. Try to use your IDE like their makers intended you to. They have made presumptions on how you are supposed to do your work. They have optimized the user exper...
Yes you are right eclipse does not manage projects in the same way VS does with solution files. However for putting a group of related projects into a VCS eclipse has the concept of a *Team Project Set* available in File->Export then under the Team folder there is Team Project Set.
earthtools.org provides a free web service to get the time zone from a city here: <http://www.earthtools.org/webservices.htm#timezone> You just pass in the long/lat values like this: (This is for New York) <http://www.earthtools.org/timezone-1.1/40.71417/-74.00639>
[WorldTimeServer.com][1] has what appears to be a comprehensive time zone database, which you can purchase access to in a variety of formats, including a .NET component for Web use. No connection, just had to research the same thing myself recently. [1]: http://www.worldtimeserver.com/time_zone_guide/
I think the [V$SQLAREA][1] table contains what you're looking for (see columns **SQL_TEXT** and **SQL_FULLTEXT**). [1]: http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2129.htm
There's a lot of work done on somewhat related problem of DNA sequence alignment (search for "local sequence alignment") - classic algorithm being "Needleman-Wunsch" and more complex modern ones also easy to find. The idea is - similar to Greg's answer - instead of identifying and comparing keywords try to find longest...
You **don't** want to be using catch (...) (i.e. catch with the ellipsis) unless you really, definitely, most provable have a need for it. The reason for this is that some compilers (Visual C++ 6 to name the most common) also turn errors like segmentation faults and other really bad conditions into exceptions that y...
I wouldn't recommend this for anything but a "learning" project. For any real application, regardless of size, you don't know what type of "next feature" you will add. You want to have a real independent database in which you can delegate functionality to, in which you can set jobs to run independently, sit on a dif...
Try <a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx">Debug View</a>. It works quite nicely.
How can I monitor trace output of a .Net app?
|.net|visual-studio|windows|
I'm working on some code that uses the System.Diagnostics.Trace class and I'm wondering how to monitor what is written via calls to Trace.WriteLine() both when running in debug mode in Visual Studio and when running outside the debugger.
|.net|windows|visual-studio|
The &lt;%#DataBinder.Eval(...) %&gt; mechanism is not Data Binding in a "strict" sense. It is a one-way technique to put text in specific places in the template. If you need to get the data back out, you have to either: 1. Get it from your source data 2. Populate the repeater with a different mechanism Note...
The &lt;%#DataBinder.Eval(...) %&gt; mechanism is not Data Binding in a "strict" sense. It is a one-way technique to put text in specific places in the template. If you need to get the data back out, you have to either: 1. Get it from your source data 2. Populate the repeater with a different mechanism Note...
What is the best style/syntax to use with Rhino Mocks?
|c#|unit-testing|syntax|mocking|rhino-mocks|
Multiple approaches exist to write your unit tests when using Rhino Mocks: - The Standard Syntax - Record/Replay Syntax - The Fluent Syntax What is the ideal and less frictionless way?
Multiple approaches exist to write your unit tests when using Rhino Mocks: - The Standard Syntax - Record/Replay Syntax - The Fluent Syntax What is the ideal and most frictionless way?
|ms-access|image|jpeg|jpg|
I've got an MS-Access app (1/10th MS-Acccess, 9/10ths MS-SQL) that needs to display photographs of some assets along with their specifications. Currently the images are stored in an MS-Access table as an OLE Object (and copy-n-pasted into the field by the users). For various reasons, I would like to do is store the ...
|image|ms-access|jpeg|jpg|
|ms-access|image|
There's no way to do this in the SQL standard, but you can usually find vendor-specific extensions, e.g., `CONNECT BY` in Oracle.
You could wrap echo / print etc. in your own methods which you can then use to escape output. i.e. instead of echo "blah"; use myecho('blah'); you could even have a second param that turns off escaping if you need it. In one project we had a debug mode in our output functions which made all th...
You could wrap echo / print etc. in your own methods which you can then use to escape output. i.e. instead of echo "blah"; use myecho('blah'); you could even have a second param that turns off escaping if you need it. In one project we had a debug mode in our output functions which made all th...
Because Google can't be bothered to follow the [Module Pattern](http://yuiblog.com/blog/2007/06/12/module-pattern/) and therefore they don't want accidental collisions in the global namespace?
At the top of your external js file, add the following: /// <reference path="jQuery.js"/> Make sure the path is correct, relative to the file's position in the folder structure, etc. That should do it. ---------- EDIT: You may need to then save the file and close it and reopen it for VS to parse that...
I don't know if you have cpanel installed on your host, but i was able to do this by adding a new subdomain '*' and then sending all that traffic to a particular subdomain, ex *.domain.com -> master.domain.com. Then you can read out which url you are at in master.domain.com and go from there.
if your using log4j Exception e; log.error("error here",e); will print the stacktrace to your log.
If it's an application behind a firewall, theoretically yes. It depends on what you mean by "real world"; if by that you mean "high performance" perhaps NetTcpBinding is a better appraoch.
There's a pattern that I learned from Twisted Python code. class SMTP: def lookupMethod(self, command): return getattr(self, 'do_' + command.upper(), None) def do_HELO(self, rest): return 'Howdy ' + rest def do_QUIT(self, rest): return 'Bye' ...
How to determine the value of a controller variable during execution in Ruby on Rails?
|ruby|ruby-on-rails|debugging|variables|
What is the best way for me to determine a controller variable's value during execution? For example, is there a way I can insert a break in the code, and cause the value of the variable to be output to the screen (or the log)?
If the slave isn't used for any writes other than the replication, the authors of High Performance MySQL recommend adding `read_only` on the slave server to prevent users from mistakenly changing data on the slave as this is will also create the same errors you experienced.
This is a simple test program I knocked up: #!/usr/bin/env python TEST1=""" #include "Foo.h" #define bar foo\\ x #include "Bar.h" """ TEST2=""" #define bar foo #define x 1 \\ 12 \\ 2 \\\\ 3 Foobar """ TEST3=""" #defin...
Yep, that's definitely possible. The v$sql views contain that info. Something like [this piece of code][1] should point you in the right direction. I haven't tried that specific piece of code myself - nowhere near an Oracle DB right now. [1]: http://www.oracle.com/technology/oramag/code/tips2005/100305.html
Yep, that's definitely possible. The v$sql views contain that info. Something like [this piece of code][1] should point you in the right direction. I haven't tried that specific piece of code myself - nowhere near an Oracle DB right now. [Edit] Damn two other answers already. Must type faster next time ;-) ...
On the data dictionary side there are a lot of tools you can use to such as [Schema Spy][1] To look at what queries are running look at views sys.v_$sql and sys.v_$sqltext. You will also need access to sys.all_users One thing to note that queries that use parameters will show up once with entries like a...
On the data dictionary side there are a lot of tools you can use to such as [Schema Spy][1] To look at what queries are running look at views sys.v_$sql and sys.v_$sqltext. You will also need access to sys.all_users One thing to note that queries that use parameters will show up once with entries like and...
**Manually.** I'm not a big fan of automated *UI testing* if that is what you're getting at. I'm not sure about the WPF guidances (need to read thru aku's links).. because they are still solidifying so to speak... WPF has not stabilized from the point of 'what is the right way'. Unless you're using one of these evolvin...
**Manually.** I'm not a big fan of automated *UI testing* if that is what you're getting at. I'm not sure about the WPF guidances (need to read thru aku's links).. because they are still solidifying so to speak... WPF has not stabilized from the point of 'what is the right way'. Unless you're using one of these evolvin...
- [LibHaru][1] seems to be used by many. - [PDF Creator Pilot][2] provides more language options as well > PDF Creator Pilot - PDF Library for C++, C#, Delphi, ASP, ASP.NET, VB, > VB.NET, VBScript, PHP, Python [1]: http://libharu.org/wiki/Main_Page [2]: http://www.colorpilot.com/pdflibrar...
The [Primo burning engine][1] for .Net works nicely. [1]: http://www.primoburner.com/
A nice way I used to escape all user input is by writing a modifier for smarty wich escapes all variables passed to the template; except for the ones that have |unescape attached to it. That way you only give HTML access to the elements you explicitly give access to. I don't have that modifier any more; but about t...
There's probably no ideal method for every situation, but push is usually better and used more often. It allows to optimize server caching and data transfers, which helps performance and scalability, and cuts network traffic a bit by avoiding client requests and empty responses. It can be important advantage for a serv...
I have had great success using Microsoft Word. The form is designed in Word and composited with XML data. The document is run through a PDF converter (Neevia in this case, but there are better) to generate the PDF. All of this is done in C#.
Chasing the word "Quality" is like chasing the horizon. I have never seen anything (in the IT world or outside) that is 100% quality. There's always room for improvement. Secondly, "quality" is an overly broad term. It means something different to everyone and subjective in it's degree of implementation. That bei...
Getting the back/fwd history of web browser in C# WinForms
|c#|webbrowser|winforms|mshtml|navigation|