instruction
stringlengths
0
30k
I've been working with [providers][1] a fair bit lately and I came across an interesting situation where I wanted to have an abstract class that had an abstract static method. I read a few posts on the topic and it sort of made sense, but I was wondering if someone here might be able to offer a nice clear explanation? ...
|c#|.net|
I can think of 2 options 1. Use javascript to resize the smaller column on page load. 2. Fake the equal heights by setting the background color for the column on the container div instead (<div class="separator"/>) with repeat-y
I've recently been looking into targeting the .NET Client Profile for a WPF application I am building. However, I was frustrated to notice that the Client Profile is only valid for the following OS configurations: - Windows XP SP2+ - <strike>Windows Server 2003</strike> **Edit:** [Appears][1] the Client Profil...
I often find myself defining some things that are done repetitively in certain functions. That makes the code much shorter and thus allows a better overview. But as always, try to find a good measure to not create a new language out of it. Might be a little hard to read for the occasional maintenance later on.
In C# #define macros, like some of Bernard's examples, are not allowed. The only common use of #define/#ifs in C# is for adding optional debug only code. For example: static void Main(string[] args) { #if DEBUG //this only compiles if in DEBUG Console.W...
#define is used to define compile-time constants that you can use with #if to include or exclude bits of code. #define USEFOREACH #if USEFOREACH foreach(var item in items) { #else for(int i=0; i < items.Length; ++i) { var item = item[0]; #endif ...
I've heard the books currently out there are pretty out of date. The whole ecosystem seems to evolve very fast with dramatic changes made in every OS release. He wrote a [tutorial][1] which pulls together some Apple documentation and other tutorials which should get you started. I think it covers the basics of using...
You should probably just use the standard ASP.Net LinkButton, unless it's really missing something you need.
A basic paper version is the way to go for an initial mock-up. It's been my experience that if you do a "real" mock-up, even if you explain to the customer that it's a non-functional mock-up, they are confused when things don't work. Bottom line: keep it as simple as possible. If it's on paper, there is no way the...
Always start with paper or paper-like mock-ups first. You do not want to fall into a trap of giving the impression of completeness when the back-end is completely hollow.
Always start with paper or paper-like mock-ups first. You do not want to fall into a trap of giving the impression of completeness when the back-end is completely hollow. Jeff discusses paper prototyping in his Coding Horror article [UI-First Software Development][1] Click the "Watch a video!" link at [twitter.c...
Always start with paper or paper-like mock-ups first. You do not want to fall into a trap of giving the impression of completeness when the back-end is completely hollow. A polished prototype or pixel-perfect example puts too much emphasis on the design. With an obvious sketch, you have a better shot of discussing...
File paths in the DB is **definitely** the way to go.
File paths in the DB is **definitely** the way to go - I've heard story after story from customers with TB of images that it became a nightmare trying to store any significant amount of images in a DB - the performance hit alone is too much.
Greg Hurlman wrote: > Why not just show/hide the proper container when a node is selected in the grid? Have the containers all sized appropriately in the same spot, and hide all but the default, which would be preselected in the grid on load. Unfortunately, that's what I'm trying to avoid. I'm looking for an easy...
Full complete mysql DB replication? Ideas? What do people do?
|mysql|replication|
Currently I have two linux servers wunning MySQL, one sitting on a rack right next to me under a 10Mbit upload pipe (main server) and another some couple of miles away on a 3Mbit upload pipe (mirror). I want to be able to replicate data on both servers continuously, but have run into several roadblocks. One of them ...
There shouldn't be. Virtual Machines emulate the pieces of hardware you can't access directly, but actual code is executed directly on the host CPU 99.9% of the time. Your best bet is trying to identify known VM environments, but that will give you some false positives and many missed detections. Identifying the CPU...
I can see the main benefit of employing XSLT to transform your data and display it to the user would be the following: * The data is already in an XML format * The data follows a well defined schema (this makes using tools like XMLSpy much easier). * The data needs to be transformed into a number of different outp...
Make an array of controls. TextBox[] textboxes = new TextBox[] { textBox1, textBox2, textBox3 };
Is MySQL replication an option? You could even turn it on and off if you didn't want it constantly replicating. This was a [good article](http://www.howtoforge.com/mysql_database_replication) on replication.
You can create table variables (in memory), and two different types of temp table: --visible only to me, in memory (SQL 2000 and above only) declare @test table ( Field1 int, Field2 nvarchar(50) ); --visible only to me, stored in tempDB create table #test ( Fi...
You can create table variables (in memory), and two different types of temp table: --visible only to me, in memory (SQL 2000 and above only) declare @test table ( Field1 int, Field2 nvarchar(50) ); --visible only to me, stored in tempDB create table #test ( Fi...
Another nice thing that VB .NET does is having a single event handler that handles multiple controls: Private Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles TextBox1.TextChanged, _ ...
How sophisticated should my Ajax code be ?
Try out [ScintillaNET][1] it's a .NET WinForms wrapper around the excellent [Scintilla][2] control. Scintilla itself is a free source code editor component that is very customisable and has all the features you asked for. See [here][3] for a screenshot. [1]: http://www.codeplex.com/ScintillaNET [2]: http://sc...
Little addition, instead of using switch(input) use... switch (toupper(input)) { case 'A': This will allow the user to enter 'a' or 'A' and saves you having to check for upper and lower case
This is a purely subjective thing I am afraid. - May it is because of your low end system configuration. - May be VS trying to get updates from the net? - May be you are running too many application in the background. - May be you are trying to open a huge solution.
How does Web Routing Work?
|c#|asp.net-mvc|
I need a good understanding of the inner workings of System.Web.Routing. Usually we define the RoutesTable. But how does it do the routing? The reason I'm asking it is that I want to pass the routing to subapps. What I want to see working is a way of passing the current request to mvc apps that work in other AppDom...
I need a good understanding of the inner workings of System.Web.Routing. Usually we define the RoutesTable. But how does it do the routing? The reason I'm asking it is that I want to pass the routing to subapps. What I want to see working is a way of passing the current request to mvc apps that work in other AppDom...
I need a good understanding of the inner workings of System.Web.Routing. Usually we define the RoutesTable. But how does it do the routing? The reason I'm asking it is that I want to pass the routing to subapps. What I want to see working is a way of passing the current request to mvc apps that work in other AppDom...
One other suggestion: If you have feature or enhancement requests, or bugs that you've run into, be sure to file them at Apple's [Bug Reporter][1]. It's the best way for developers to communicate their needs to Apple, because every issue is tracked through the system. [1]: http://bugreport.apple.com/
You may consider using a command like Linux's [dos2unix][1] for the conversion. Being a Linux command, it is easy to use it in batch mode with scripts etc. I do not know whether there is an equivalent for other operating systems. [1]: http://www.linuxcommand.org/man_pages/dos2unix1.html
SQL injection attacks are on the upswing. It's very easy for someone to find this code and run injection attacks on your website. You must always _**always**_ parameterize your queries. It's best to never run exec(@x) on a dynamic SQL query. It's just not a great idea to use inline SQL ever, IMO. Stored Procedures, ...
@Ed: When using C++, there is rarely any benefit for using #define over inline functions when creating macros. The idea of "greater speed" is a misconception. With inline functions you get the same speed, but you also get type safey, and no side-effects of preprocessor "pasting" due to the fact that parameters are eval...
http://en.wikipedia.org/wiki/Boxing_%28Computer_science%29#Boxing thats the correct link for boxing as related to computer science :D
> Is #define the only thing that > determines if the code is included > when compiled? If I have #define > DEBUGme as a custom symbol, the only > way to exclude it from compile is to > remove this #define statement? You can [undefine][1] symbols as well #if defined(DEBUG) #undef DEBUG #endif ...
CruiseControl.NET solves a different problem (continuous integration) ... however, I've had great success with NAnt for specifically what you're asking. There's a learning curve, but once you get proficient you'll wonder how you ever got along w/o it.
The most important feature I can't live w/o is VS.Net 2008. :P
The main thing is being able to abstract the complexity of the system so that you don't get bogged down by it as soon as you start off. * First read the spec like a story (skimming through it). Don't stop at every requirement to analyze it right there and then. This will allow you to get an overall picture of the sy...
I recently bought a Vista machine for my home and when I use ssh to log in at work Vista pops up a box complaining about a process that died. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? * * * I'm at work right now, so I can't ...
I recently bought a Vista machine for my home and when I use ssh to log in at work Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? * * * I'm at work right now...
|cygwin|ssh|windows-vista|x11|openssh|
I recently bought a Vista machine for my home and when I use ssh to log in at work Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? * * * Specifically, the mes...
Why does Vista complain about a dead process when I use Cygwin X11 ssh and how do I get it to shut up?
|windows-vista|ssh|cygwin|x11|openssh|
When I log into a remote machine using ssh X11 forwarding, Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? * * * Specifically, the message reads: sh.ex...
I think the best you can do in this case is to take their input and then show them what you think they meant. If they disagree, show them the format you're expecting and get them to enter it again.
GTK implementation of MessageBox
|unix|linux|x11|gtk|sdl|opengl|
I have been trying to implement Win32's MessageBox using GTK. The app using SDL/OpenGL, so this isn't a GTK app. I handle the initialisation (**gtk_init**) sort of stuff inside the MessageBox function as follows: int MessageBox(HWND hwnd, const char* text, const char* caption, UINT type) { Gt...
|c++|c|linux|unix|gtk|x11|
Any assemblies that are expected to be in the GAC should stay in the GAC. This includes System.web.dll or any other 3rd party dll that you'll deploy to the GAC in production. This means a new developer would have to install these assemblies. All other 3rd party assemblies should be references through a relative path...
Is this a .Net specific question? Generally the best practice is to not check in anything which is built automatically from files that are already in SCM. All of that is ideally created as part of your automatic build process. If the `bin` directory you're referring to contains third-party binaries, rather than ...
If it VM does the job well, it should be invisible to the client that it's being virtualized. However, one can look at other clues. I would imagine that looking for known drivers or software specific to the VM environment would be the best possible way. For example, on a VMWare client running Windows, vmxnet.sys ...
There are two aspects. .NET readily supports arrays of controls, VB6 just had to use a workaround because otherwise, wiring up events was really hard. In .NET, wiring up events dynamically is easy. However, the .NET form designer does not support control arrays for a simple reason: arrays of controls are created/...
I would create a (Ruby) script to do a <code>SELECT * FROM ...</code> on all the databases on the server and then do a <code>DROP DATABASE ...</code> followed by a series of new <code>INSERT</code>s on the local copy. You can do a <code>SHOW DATABASES</code> query to list the databases dynamically. Now, this assumes th...
I agree with Robocopy as a solution...thats why the utility is called *"Robust File Copy"* > I've used Robocopy for this with excellent results. By default, it will retry every 30 seconds until the file gets across. And by default, a million retries. That should be plenty for your intermittent connection. It ...
Martin's answer is correct on Windows Server 2003: You will have to assign the "Lock pages in memory" privilege to any user that runs your application. This includes administrators 1. Select Control Panel -> Administrative Tools -> Local Security Policy 2. Select Local Policies -> User Rights Assignment ...
We, too, just put the binaries in source control. We use Git, but it would apply just as well to Subversion. One suggestion I have is to use SVGs where possible, because you can see actual differences. With binaries (most other image formats), the best you can get is a version history.
A lot of the graphics type people will want something more sophisticated than subversion. While it's good for version control, they will want a content management system that allows cross-referencing of assets, tagging, thumbnails and that sort of thing (as well as versioning).
From [Rick Strahl][1]: You can chain the ?? operator so that so that you can do a bunch of null comparisons. string result = value1 ?? value2 ?? value3 ?? String.Empty; [1]: http://www.west-wind.com/weblog/posts/236298.aspx
From [Rick Strahl][1]: You can chain the ?? operator so that you can do a bunch of null comparisons. string result = value1 ?? value2 ?? value3 ?? String.Empty; [1]: http://www.west-wind.com/weblog/posts/236298.aspx
Yes, having art assets in version control is very useful. You get the ability to track history, roll back changes, and you have a single source to do backups with. Keep in mind that art assets are MUCH larger so your server needs to have lots of disk space & network bandwidth. I've had success with using [perforc...
import java.util.*; Map map = new HashMap();
Best practices for development environment and API dev?
|api|development-environment|pipeline|
|api|development-environment|pipeline|
My current employer uses a 3rd party hosted CRM provider and we have a fairly sophisticated integration tier between the two systems. Amongst the capabilities of the CRM provider is for developers to author business logic in a Java like language and on events such as the user clicking a button or submitting a new ac...
|asp.net-mvc|
The [section on "Why am I getting no hits?"][1] in the Lucene FAQ has some suggestions you might find useful. You're using Field.Index.UN_TOKENIZED, so no Analyzer will be used for indexing (I think). If you're using an Analyzer when you're searching then that might be the root of your problem - the indexing and sear...
How do I reference a javascript file?
|c#|asp.net|javascript|
I'm working on a C#/ASP.NET project that has all the javascript files in a /Javascript folder. If I refer to the JS file using this syntax: src="/Javascript/jsfile.js" then the file is correctly picked up if the project is deployed to the root of the URL. However, if this "web site" is deployed to a sub-folder of th...
|asp.net|javascript|
try `sealed` class B : A { protected sealed override void SpecialRender() { // do stuff } } class C : B protected override void SpecialRender() { // not valid } } Of course, I think C can get around it by being `new`.
Suggestions for migrating ASP.net app from 1.1 forward
|c#|asp.net|silverlight|
I am recently in charge of an older app written in C# using asp.net 1.1. 1. Are there any resources to guide me in converting the application to a newer version of of the .NET Framework. _My main pause is that there are ton's of customized DataGrids in the app as it is written now and since so much of the code n...
|asp.net|silverlight|
it might be that you have a plugin that is misbehaving. Try the [safemode][1] switch to see if this improves performance [1]: http://msdn.microsoft.com/en-us/library/xee0c8y7(VS.80).aspx
This is what I used for Excel 2003: Dictionary<string, string> props = new Dictionary<string, string>(); props["Provider"] = "Microsoft.Jet.OLEDB.4.0"; props["Data Source"] = repFile; props["Extended Properties"] = "Excel 8.0"; StringBuilder sb = new StringBuilder(); foreach (KeyValueP...
Martin's answer is correct on Windows Server 2003: > You will have to assign the "Lock pages in memory" privilege to any user that runs your > application. This includes administrators > > 1. Select Control Panel -> Administrative Tools -> Local Security Policy > 2. Select Local Policies -> User Rights Assign...
One good example is that apparently doing a WMI query for the motherboard manufacturer, and if it returns "Microsoft" you're in a VM. Thought I believe this is only for VMWare. There are likely different ways to tell for each VM host software. This article here <http://blogs.technet.com/jhoward/archive/2005/07/26/...
Visual Studio 2005/2008: How to keep first curly brace on same line?
|visual-studio|
Trying to get my css / C# functions to look like this: body { color:#222; } instead of this: body { color:#222; } when I auto-format the code.
How do you build a multi-language web site?
|database|web-applications|jakarta-ee|multilingual|
A friend of mine is now building a web application with J2EE and Struts, and it's going to be prepared to display pages in several languages. I was told that the best way to support a multi-language site is to use a properties file where you store all the strings of your pages, something like: welcome.english...
A more empirical approach is to check for known VM device drivers. You could write WMI queries to locate, say, the VMware display adapter, disk drive, network adapter, etc. This would be suitable if you knew you only had to worry about known VM host types in your environment. Here's [an example of doing this in Perl...
Login Integration in PHP
|php|authentication|integration|
In my host, I currently have installed 2 wordpress applications, 1 phpBB forum and one MediaWiki. Is there a way to merge the login so that all applications share the same credentials? For instance, I want to register only in my phpBB and then I want to access all other applications with the given username and pa...
When I log into a remote machine using ssh X11 forwarding, Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? * * * Specifically, the message reads: sh.ex...
@Alexandru & Jeremy, Thanks for your help. You both get upvotes @Jeremy Using your method I got the following error: > sed: -e expression #1, char 8: > unterminated `s' command If you can make it work I'd accept your answer. (pasting my solution doesn't count)