instruction
stringlengths
0
30k
Another problem with static methods is that is a quite painful write unit test to them - in Java, at least. You can't mock a static method in any way. There is a [post on google testing blog about this issue][1]. My rule of thumb is write static method when they haven't external dependencies (like database access, read...
If you are going with open source libraries, pick ones with a good license. I have found out the hard way (when trying to OEM an application) that many companies shy away from licenses like LGPL. I won't go into the details on why but they prefer Apache, BSD or MIT style licenses. Pick tools that have been around fo...
I think it depends on the knowledge you are trying to transfer. I've found the following: Technical Knowledge: "How to guide" with screenshots and a short demo - similar to the way you will see new features at a conference. The added benefit of this is what you have got is documented for when you leave the company...
Try this var fooids = from fb in foobar where fb.BarId=1000 select fb.fooID var ff = from f in foo where f.FooID = fooids select f
According to the source of [wx/config.h][1] file, all you need is to undefine the wxUSE_CONFIG_NATIVE symbol in your project and then it should always use wxFileConfig. [1]: http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk/include/wx/config.h
According to the source of [wx/config.h][1] file, all you need is to define the **wxUSE_CONFIG_NATIVE** symbol to 0 in your project and then it will always use wxFileConfig. [1]: http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk/include/wx/config.h
i'm implementing that using the 'Order' column/property where people input numbers like 10, 20, 30 (i have ascending ordering). i have a list of items with text boxes to input order, and an 'apply order' button that saves new values to the database and reorders/reloads items on the page with the new ordering applied. ...
If you can modify the database, add an IsHot column. Then sort by IsHot and DisplayOrder (in that order). This will keep the products in the correct order and the "hot" products will bubble up to the top.
using AJAX you could implement a Reoder list control you can find more information here [http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx][1] Mauro [http://www.brantas.co.uk][2] [1]: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx [2]: htt...
put the spinner in a div the same size as the chart, you know the height and width so you can use relative positioning to center it correctly.
I think all of the above. But you're forgetting the most important way. The most efficient way to transfer knowledge is to have people work together. You might think about doing 1 on 1 code reviews or even pair programming and make knowledge transfer an intergral part of the work.
In the [herding code](http://herdingcode.com/) podcast 14 someone mentions that stackoverflow displayed the queries that were executed during a request at the bottom of the page. It sounds like an excellent idea to me. Every time a page loads I want to know what sql statements are executed and also a count of the t...
|asp.net|linq-to-sql|
In the [herding code](http://herdingcode.com/) podcast 14 someone mentions that stackoverflow displayed the queries that were executed during a request at the bottom of the page. It sounds like an excellent idea to me. Every time a page loads I want to know what sql statements are executed and also a count of the t...
You can write a query search the information schema views (definition column) to find the table in all views, triggers, procedure, etc. Not sure about FK & indexes though.
Can you bind a DataTrigger to an Attached Property?
Passing impersonation token on a Managed Thread to an Unmanaged Thread
|c#|vb.net|multithreading|unmanaged|managed|
I have a case where a VB.Net winforms app needs to play WMV files from across the network. The user running the app cannot be given direct access to the network share. Through impersonation, I can see that the files exist (without impersonation, File.Exists returns false for the files on the network share). When I then...
I'd consider it dirty hack, but as a non-Portal developer I'd consider using JavaScript to insert a new link element in the head pointing to your new CSS file. Of course you'd have a flash of un-styled content because the script probably won't run until after part of the page has been downloaded and rendered, but it ...
Like virtually everybody else here, I say make it readable. It costs nothing extra in your generation process and you (or your successor) will appreciate it when they go digging. For a real world example - look at anything Visual Studio generates. Well formatted, with comments and everything.
Not sure about IE7 on Windows Server 2008, but for IE6 the start page is stored in a registry key "Start Page" in HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main.
Look up [active code generation][1] vs. [passive code generation][2]. With respect to passive code generation, **absolutely yes, always.** With regards to active code generation, *when* the code achieves the goal of being transparent, which is acting exactly like a documented API, then no. [1]: http://www.c2.com...
Unfortunately, function closures work weird/poorly in Actionscript. Variables only get a "snapshot" when they go out of scope. Unfortunately, variables are function scoped, and not block scoped. So it doesn't end up working like you want. You could create a dictionary to map from TextInput -> node, or you could s...
Is there a way to build a Flash 9 SWF from an FLA file without using the Flash IDE?
|flash|actionscript-3|
Two reasons this would be useful, in case there's some other way to achieve these goals: 1) Building in the Flash IDE is really slow; I was hoping a third-party compiler would be faster. 2) It would be nice to be able to build projects on machines that don't have the Flash IDE installed. I'm familiar with other AS3 ...
How do I find records added to my database table in the past 24 hours?
|sql|
I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record. INSERT INTO messages (typeId, messageTime, stationId, message) VALUES (?, NOW(), ?, ?)
Specifically, it is about a "Holy Grail" of design in OOP of making an entity extensible enough (through its individual design or through its participation in the architecture) to support future unforseen changes without rewriting its code (and sometimes even without re-compiling **). Some ways to do this include Po...
The major performance difference is that COUNT(*) can be satisfied by examining the primary key on the table. i.e. in the simple case below, the query will return immediately, without needing to examine any rows. select count(*) from table I'm not sure if the query optimizer in SQL Server will do so, but i...
The major performance difference is that COUNT(*) can be satisfied by examining the primary key on the table. i.e. in the simple case below, the query will return immediately, without needing to examine any rows. select count(*) from table I'm not sure if the query optimizer in SQL Server will do so, but i...
Learning LISP/Scheme - Interpreter
|ide|lisp|scheme|
I've been making my way through The Little Schemer and was wondering what environment/ide/interpreter would be best to use in order to test any of the Scheme code I jot down for myself. Thanks
You can accomplish this using the Do callback: Expect.Call(delegate {dao.Save(transaction);}) .Do(x => x.IsSaved = true);
**Yes.** > Reads and writes of the following data types are atomic: bool, char, byte, sbyte, short, ushort, uint, int, float, and reference types. as found in [C# Language Spec][1]. Edit: That said, you should probably mark it as [**volatile**][2]. [1]: http://msdn.microsoft.com/en-us/library/aa691278(...
**[Firebug][1]** does include JS profiling, and it is probably the best out there. While I've had problems with Firebug's debugger, its profiler is currently top-of-the-line. **[Venkman][2]** is also an older JS debugger/profiler for Firefox, just in case you run into Firebug issues. Using these tools should get y...
How does the Licenses.licx based .Net component licensing model work?
|.net|licensing|
I've encountered multiple third part .Net component-vendors use a licensing scheme. On an evaluation copy, the components show up with a nag-screen or watermark or some such indicator. On a licensed machine, a **Licenses.licx** is created - with what appears to be *just* the assembly full name/identifiers. This file ha...
I should've been a little more descriptive. The database in question is for an internal ERP system and thus we don't have many versions of our database, just Production/Testing/Development. When we've done a change request, some new fancy feature or something, we simply execute a script or series of scripts to update t...
I found it: DirectoryEntry de = new DirectoryEntry("IIS://localhost"); de.Invoke("Backup", new object[0] ); new object needs to be set to hold proper arguments like overwriting current backup
If I was certain of the targeted database I'd go with Mark Nold's solution, but if you ever want some dialect agnostic SQL*, try SELECT * FROM scott.emp e WHERE e.deptno = 20 AND e.job = 'CLERK' AND e.sal = ( SELECT MAX(e2.sal) FROM scott.emp e2 WHERE e.deptno = e2.dep...
At my workplace we use a wiki. The workplace is small enough (~20 people) so that you can always ask the person who was most involved in a particular project, however it is expected that you have searched on the wiki before you ask "the expert". If you cannot find your answer in the wiki, then you should add it after y...
I believe that Django models does not support composite primary keys (see [documentation](http://docs.djangoproject.com/en/dev/topics/db/models/#automatic-primary-key-fields)). But perhaps you can use SQLAlchemy in Django? A [google search](http://www.google.com/search?q=sqlalchemy+django) indicates that you can. I hav...
|wpf|
In WPF, is it possible for a DataTrigger to bind to an attached property? I essentially want to use a converter on an attached property to provide a style when a particular validation rule has been broken. I am using markup like the following: <DataTrigger Binding="{Binding Path=Validation.Errors, ...
[Delicious Bookmarks](https://addons.mozilla.org/en-US/firefox/addon/3615) extension for Firefox
I'm a MS-SQL guy myself, and we'd use [DBCC PINTABLE][1] to keep a table cached, and [SET STATISTICS IO][2] to see that it's reading from cache, and not disk. I can't find anything on Postgres to mimic PINTABLE, but [pg_buffercache][3] seems to give details on what is in the cache - you may want to check that, and ...
This page should provide a workaround for your problem. http://code.google.com/p/support/wiki/ImportingFromGit Basically, you create a read-only clone of your Git repository in the SVN repository format, exporting updates as you go. An SVN hook could be written that fires after each update to copy the new files ...
Ruby Package Include Problems
|ruby|
I'm trying to use the [Optiflag][1] package in my Ruby code and whenever I try to do the necessary `require optiflag.rb`, my program fails with the standard `no such file to load -- optiflag` message. I added the directory with that library to my $PATH variable, but it's still not working. Any ideas? [1]: http:/...
One thing you can try is find a Java bytecode compiler for the language you're talking about (there are JVM compilers for all kinds of languages) and then decompile the bytecode back into Java using a decompiler like Jad. This is fraught with peril. The regenerated code will suck and will probably be unreadable.
GOTO still considered harmful?
|goto|goto-considered-harmful|program-design|
Everyone is aware of Dijkstra's [GOTO Considered Harmful [pdf]][1] and there has been a formidable push since that time to eschew the goto statement whenever possible. While it's possible to use goto to produce unmaintainable, sprawling code, it nevertheless remains in [modern programming languages][2]. Even the advanc...
|goto|program-design|
Everyone is aware of Dijkstra's [GOTO Considered Harmful [pdf]][1] and there has been a formidable push since that time to eschew the goto statement whenever possible. While it's possible to use goto to produce unmaintainable, sprawling code, it nevertheless remains in [modern programming languages][2]. Even the advanc...
You'll need some sort of CronJob/Timer Service that checks the Mailbox regularly and then acts on it. Alternatively, you should check the mailserver if it can run a script when a mail arrives (i.e. see if it's possible to put a spamfilter-script in and "abuse" that functionality to call your script instead). With pu...
Generated code is code, and there's no reason any code shouldn't be readable and nicely formatted. This is cheap especially in generated code: you don't need to apply formatting yourself, the generator does it for you everytime! :) As a secondary option in case you're really that lazy, how about piping the code thro...
Two ways: 1. Control Panel->Internet Options 2. Start->Run... "%windir%\system32\inetcpl.cpl"
Using the Int32 type requires a namespace reference to System, or fully qualifying (System.Int32). I tend toward int, because it doesn't require a namespace import, therefor reducing the chance of namespace collision in some cases. When compiled to IL, there is no difference between the two.
Single-threaded solutions with time delays before displaying graphics are fine, but I think the progressive way is to run game logic in one thread, and displaying in other thread. But you should synchronize threads right way ;) It'll take a long time to implement, so if your game is not too big, single-threaded sol...
We've built up a development stack gradually here, we're currently using: - Subversion - CruiseControl - RedMine (integrates bug tracking with source control and includes wiki, basic project management, etc).
You should be able to configure the webserver to do a header redirect (301 or 302 depending on your situation) so it redirects without ever loading an HTML page. This can be done in PHP as well: <?php header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code belo...
**MS-DOS batch:** copy CON so.bat so.bat ^Z so.bat
You will kill yourself if you have to debug your own generated code. Don't start thinking you won't. Keep in mind that when you trust your code to generate code you've already introduced two errors into the system - You've inserted yourself twice. There is absolutely NO reason NOT to make it human parseable, so wh...
*You will kill yourself if you have to debug your own generated code.* Don't start thinking you won't. **Keep in mind that when you trust your code to generate code then you've already introduced two errors into the system - You've inserted yourself twice.** There is absolutely NO reason NOT to make it human parse...
**[Firebug][1]** does include JS profiling, and it is probably the best out there. While I've had problems with Firebug's debugger, its profiler is currently top-of-the-line. **[Venkman][2]** is also an older JS debugger/profiler for Firefox, just in case you run into Firebug issues. Using these tools should get y...
I know from personal experience there really isn't much you need to do for the iPhone. I usually rather just browse your regular site with my iPhone. Just my two cents though.
Dr Scheme has a nice editor, several different Scheme dialects, an attempt at visual debugging, lots of libraries, and can run on most platforms. It even has some modes specifically geared around learning the language.
SELECT * FROM messages WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= messageTime
Different style sheets based on user agent will handle the "pretty". Are you using master pages? You could also set up different masters based on the device using device filters.
The only real solution I see is to copy all the controls into a new form by selecting them in the designer. This way all the not created controls should not follow you to the next form.
Clean up Designer.vb file in Visual Studio 2008
|visual-studio-2008|vb|
I noticed that my Designer.vb file of one of my forms has **a lot** of controls that aren't even used or visible on my form. This is probably from copying controls from my other forms. Is there a way to clean up the Designer.vb file and get rid of all the unused controls?
I noticed that my Designer.vb file of one of my forms has **a lot** of controls that aren't even used or visible on my form. This is probably from copying controls from my other forms. Is there a way to clean up the Designer.vb file and get rid of all the unused controls? **UPDATE: This is for a Windows Form proje...
The SQL Server query is: Select * From Messages Where MessageTime > DateAdd(dd, -1, GetDate()) As far as I can tell the (untested!) MySQL equivalent is Select * From Messages Where MessageTime > ADDDATE(NOW(), INTERVAL -1 DAY)
You might be interested in [MSDeploy][1]. [Here's][2] a Scott Hanselman post on this. It's only available a technical preview at the moment (September 2008) but is worth evaluation against your requirements. [1]: http://blogs.iis.net/msdeploy/archive/2008/01/22/welcome-to-the-web-deployment-team-blog.aspx [2]...
I believe that Django models does not support composite primary keys (see [documentation](http://docs.djangoproject.com/en/dev/topics/db/models/#automatic-primary-key-fields)). But perhaps you can use SQLAlchemy in Django? A [google search](http://www.google.com/search?q=sqlalchemy+django) indicates that you can. I hav...
Use the power of the setTimeout() function ([More info][1]) - this allows you set a timer to trigger a function call in the future, and it block execution of the current / other functions (async.). Position a div containing the spinner above the chart image, with it's css display attribute set to none: <div>&...
Use the power of the setTimeout() function ([More info][1]) - this allows you set a timer to trigger a function call in the future, and calling it **won't** block execution of the current / other functions (async.). Position a div containing the spinner above the chart image, with it's css display attribute set to n...
There's only a couple of things I can think of to try. First, are you developing on the box where you might be able to use Visual Studio to debug? So just stepping through it. Assuming that's not the case - what I'd do is fire up WinDBG and attach it to the process just before I registered the policy. Turn on first ...
$( function() { $( "input:radio" ).click( radioClicks ).filter( "[value='S']" ).attr( "checked", "checked" ); } );
I am assuming you need to generate dynamic images from asp.net You might be in luck http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449 Hanselman blogged about it recently http://www.hanselman.com/blog/ASPNETFuturesGeneratingDynamicImagesWithHttpHandlersGetsEasier.aspx
I'd suggest using servicewrapper to manage the application server, and then use its api methods for requesting a restart of the service. There would be some configuration involved and its hard to know if this would work in your particuar environment, but thats the only solution that I know of which is even reasonably ...
There is an incredibly easy way of doing this (in .net). Its called a MatchEvaluator and it lets you do all sorts of cool find and replace. Essentially you just feed the Regex.Replace method the method name of a method that returns a string and takes in a Match object as its only parameter. Do whatever makes sense for ...
Tabs and spaces confusion can be fixed by setting your editor to use spaces instead of tabs. To make whitespace completely intuitive, you can use a stronger code editor or an IDE (though you don't need a full-blown IDE if all you need is proper automatic code indenting). A list of editors can be found in the Py...
If you use an email address for ID, don't require that it be verified. I learned the hard way about this when one day suddenly the number of signups at my site drastically decreased. It turns out that the entire range of IP addresses including my site's IP was blacklisted. It took a long time to resolve it. In other ca...
Instead of using string concatenation, you should use StringBuilder if your code is not threaded, and StringBuffer if it is.
iPhone app loading
|iphone|
When loading, my iPhone apps always loads to a black screen first then pops up the main window--this happens even with a simple empty app with a single window loaded. I've noticed that when loading, most apps zoom in on the main window (or scale it to fit the screen, however you want to think about it) and then load th...
A true C++ exception thrown from Microsoft's runtime will have an SEH code of 0xe06d7363 (E0 + 'msc'). You have some other exception. .NET generates SEH exceptions with the code 0xe0434f4d (E0 + 'COM'). NT's status codes are documented in ntstatus.h, and generally start 0x80 (warnings) or 0xC0 (errors). The most ...
The answer is posted, but here's how you can discover the answer without having to ask <br/> 1: Set the homepage to something random ie FindMeKeyForURL.com <br/> 2: Search the registry for it <br/> 3: Extract it out and modify it, now you can deploy the .reg file
Have you looked at vim? It supports autocompletion, syntax highlighting, incremental search, integrated building, etc, etc. It is modular and many of its more advanced features are implemented as plugins that either ship with it or can be found separately (e.g., svn integration, code indexing with cscope/ctags, transpa...