instruction stringlengths 0 30k ⌀ |
|---|
|c#|bestpractices|null|dbnull| |
We have our own ORM we use here, and provide strongly typed wrappers for all of our db tables. We also allow weakly typed ad-hoc SQL to be executed, but these queries still go through the same class for getting values out of a data reader.
In tweaking that class to work with Oracle, we've come across an interesting ... |
|c#|bestpractices|orm|null|dbnull| |
|c#|orm|null|dbnull| |
What are the best practices for using Extension Methods in .Net? |
|c#|vb.net|.net| |
I have seen these being used every which way, and have been accused of using them the wrong way (though in that case, I was using them that way to demonstrate a [point](http://blog.gadodia.net/extension-methods-in-vbnet-and-c/)).
So, what do you think are the best practices for employing Extension Methods?
Should... |
|c#|vb.net|.net|bestpractices| |
Basically, if your site still works with JavaScript turned off, then anything you add with JavaScript can be considered progressive enhancement.
Some people may think that this is unnecessary, but plenty of people browse with addons like NoScript (or, with JavaScript simply turned off in their browser settings). In ... |
You can use <a href="http://www.firephp.org/">Firephp</a> an add-on to firbug to debug php in the same environment as javascript.
I also use <a href="http://xdebug.org/">Xdebug</a> mentioned earlier for profiling php. |
Not an answer, but a warning: my company bought the 2007 Infragistics ASP.NET controls just for the Grid, and we regret that choice.
The quality of API is horrible (in our opinion at least), making it very hard to program against the grid (for example, inconsistent naming conventions, but this is just an inconvenie... |
Code Complete is the number one choice, but I'd also cite Gang of Four's Design Patterns and Craig Larman's Applying UML and Patterns.
The Timeless Way of Building, by Christopher Alexander, is another great one. Even though it's about archtecture, it's included in the bibliography of many great programming books I... |
***esellerate***
if it is Digital stuff that you are selling, I recommend http://www.esellerate.net/ .
they have nice support for website payment, delivery of serial numbers upon sell and even have API so you can integrate the buying process into your application in case it is a desktop application. |
Oracle has got an [online tutorial about SQL Injection][1]. Even though you want a ready-made solution, this might give you some hints on how to use it better to defend yourself.
[1]: http://st-curriculum.oracle.com/tutorial/SQLInjection/index.htm |
Well by cheap do you mean processing fees or month fees? Also is this for micro or normal transactions? PayPal in my experience is an all around good choice because it offers both starter to professional level payment processing services that fit most needs. |
Here is a good way to remember the process that each of them follow that I use when trying to decide which is better for my circumstance.
DateTime i = (DateTime)value;
// is like doing
DateTime i = value is DateTime ? value as DateTime : throw new Exception(...);
and the next should be easy to guess... |
Since you can't modify IIS settings to map .mvc to ASP.Net, you can use a different extension that's already mapped to ASP.Net. For example, you could use {controller}.ashx/{action} and it should work out of the box on IIS 6. |
In a client-server setting, if you care about security, you should always program on the assumption that the client may have been compromised. Even if it hasn't, there is always the risk of somebody using an old version of the client, using a competing or modified version of the client, or just of the net connection be... |
It rather depends how many times you want to do it, and what resources are available - if you're doing the test once, then the O(log N) techniques are good. If you're doing it a thousand times on a server, constructing a bitmap lookup table would be faster, either giving the result directly or as a first stage of. 2GB ... |
You could check out the new [UI Automation][1] stuff in .NET 3.5. It is supposed to mask a whole lot of the PInovke stuff and works with web and WPF applications.
I haven't used it yet, so I don't have a more specific place to direct you, but it might fit the bill.
[1]: http://msdn.microsoft.com/en-us/librar... |
Are you using Apache? If so you could have a look at [mod_log_spread][1] Though you may have too big an infrastructure to make it maintainable. The other option is to look at "broadcasting" or "multicasting" your log messages and having dedicated logging servers subscribing to those feeds and collating them
[1]:... |
Being an admin, I really appreciate apps that log to the Event Log (preferably their own, otherwise the application log) for all logging but trace logs. By logging to the event log, you make it much more likely that warnings or errors can be found and addressed by the admin staff before they become a major problem (if... |
How do I track file downloads with apache/PHP |
|php|apache| |
I have a website that plays mp3's in a flash player. If a user clicks 'play' the flash player automatically downloads an mp3 and starts playing it.
Is there an easy way to track how many times a particular song clip (or any binary file) is downloaded? |
The _hook_ and _listener_ method is the most commonly used, but there are other things you can do. Depending on the size of your app, and who your going to allow see the code (is this going to be a FOSS script, or something in house) will influence greatly how you want to allow plugins.
kdeloach has a nice example,... |
Is the play link a link to the actual mp3 file or to some javascript code that pops up a player?
If the latter, you can easily add your own logging code in there to track the number of hits to it.
If the former, you'll need something that can track the web server log itself and make that distinction. My hosting ... |
As of .Net 1.1 the only available method is reaching into the java libraries.<br>
<a href="http://msdn.microsoft.com/en-ca/magazine/cc164129.aspx">Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#</a><br>
Not sure if this has changed in recent versions. |
You could even set up an Apache .htaccess directive that converts *.mp3 requests into the querystring dubayou is working with. It might be an elegant way to keep the direct request and still be able to slipstream log function into the response. |
Well, what is the nature of the flat databases. Are they large or small. Is it simple arrays with arrays in them? if its something simple say userprofiles built as such:
$user = array("name" => "dubayou",
"age" => 20,
"websites" => array("dubayou.com","willwharton.com","... |
I used to have lots of Explorer crashes (on 32-bit) caused by Tortoise. They seem to have gone away since I used the Include/Exclude path settings in the "Icon Overlays" configuration of TSVN. Constraining icon overlays to specific directories where I keep my source made this much more stable. |
Use your httpd log files. Install http://awstats.sourceforge.net/ |
Strictly speaking, a memory leak is consuming memory that is "no longer used" by the program.
"No longer used" has more than one meaning, it could mean "no more reference to it", that is, totally unrecoverable, or it could mean, referenced, recoverable, unused but the program keeps the references anyway. Only the la... |
I store everything in the repository to make it easy for developers (or rebuilt devboxes) to check-out from SVN and then run a build (with all necessary assemblies in relative paths). If you have multiple projects that should be separate, this would also encourage the team of your shared components to deliver high qua... |
I think it is highly recommended that you create separate repositories for each project. If for nothing else than to avoid the scenario you are talking about.
With version control, especially Subversion, you can easily check out pieces of a repository into another working copy and then commit them back to their r... |
Try overriding the validate method in your markup.
This should work (haven't tested though):
<input type="text" name="startDate" dojoType="dijit.form.DateTextBox"
constraints="{datePattern:'MM/dd/yyyy'}"
value='<c:out value="${sessionScope.adminMessageForm.startDate}"/>'
validate='retu... |
Try overriding the validate method in your markup.
This will work (just tested):
<input type="text" name="startDate" dojoType="dijit.form.DateTextBox"
constraints="{datePattern:'MM/dd/yyyy'}"
value='<c:out value="${sessionScope.adminMessageForm.startDate}"/>'
validate='return true;'
... |
Network shares.
Of course, then you have killer lag on the network, but at least there's only one copy of your files.
You don't want to hear what I did when I was developing on both platforms. But you're going to: drag-n-drop copy a few times a day. Local build and run, and periodically checking it out on Unix ... |
I just built a quad core - 8 GB of RAM and run Server 2008 with Hyper-V on it. I have VMs for my build server, dev platform, and deployment options (XP, Vista, Server 2003/2008) with snapshots at the various service pack levels. What's nice is you can spin up a VM whenever you need it, and re-allocate the resources w... |
I think there is a great misunderstanding about the use of the Singleton pattern. Most of the comments here refer to it as a place to access global data. We need to be careful here - Singleton as a pattern is **not** for accessing globals.
Singleton should be used to have **only one instance** of the given class. [... |
Is it possible to coax Visual Studio 2008 into using italics for comments? |
|visual-studio|fonts|consolas| |
I'm quite used to my IDE setup in Delphi 7, where I have my comments rendered in italics.
This doesn't appear to be possible in VS2008. There's only an option for bold font, not italics.
Is there some kind of registry hack or font magic I can perform to get it to work? The font I'm using is Consolas, if that make... |
I'm quite used to my IDE setup in Delphi 7, where I have my comments rendered in italics.
This doesn't appear to be possible in VS2008. There's only an option for bold font, not italics.
Is there some kind of registry hack or font magic I can perform to get it to work? The font I'm using is Consolas, if that make... |
opendir(D, "/path/to/directory") || die "Can't opedir: $!\n";
while (my $f = readdir(D)) {
print "\$f = $f\n";
}
closedir(D);
EDIT: Oh, sorry, missed the "into an array" part:
my $d = shift;
opendir(D, "$d") || die "Can't opedir $d: $!\n";
my @list = readdir(D);
... |
opendir(D, "/path/to/directory") || die "Can't opedir: $!\n";
while (my $f = readdir(D)) {
print "\$f = $f\n";
}
closedir(D);
EDIT: Oh, sorry, missed the "into an array" part:
my $d = shift;
opendir(D, "$d") || die "Can't opedir $d: $!\n";
my @list = readdir(D);
... |
Logging in a PHP webapp |
|php|logging| |
I want to keep logs of some things that people do in my app, in some cases so that it can be undone if needed.
Is it best to store such logs in a file or a database? I'm completely at a loss as to what the pros and cons are except that it's another table to setup.
Is there a third (or fourth etc) option that I'm ... |
Django Templates and variable attributes. |
|python|django|google-app-engine| |
I'm using Google App Engine and Django Templates.<br>
I have a table that I want to display the objects look something like:<br>
Object Result:
Items = [item1,item2]
Users = [{name='username',item1=3,item2=4},..]
The django template is:
<table>
<tr align="center">
<th>user</th>
... |
If the OP is asking about idomatic sorting expressions, then not all languages have a *natural* expression built in. For c I'd go to `<stdlib.h>` and use `qsort`. Something on the lines of :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv){
/* Sor... |
If the OP is asking about idomatic sorting expressions, then not all languages have a *natural* expression built in. For c I'd go to `<stdlib.h>` and use `qsort`. Something on the lines of :
/* non-functional mess deleted */
to sort the arguments into lexical order. Unfortunately this idiom is rather hard to ... |
I've used CyberSource in the past, and had a good experience.
They support several interfaces including SOAP, they work internationally, and have a pretty good web interface.
I'm not sure about a cheap, though.
<http://www.cybersource.com/products_and_services/global_payment_services/credit_card_processing/> |
I'd say paypal or [GoogleCheckout][1].
Google Checkout is either 2% + .20USD or free depending on how much you spend on adwords.
[1]: https://checkout.google.com/sell/ |
I'd say paypal or [GoogleCheckout][1].
Google Checkout is either 2% + .20USD or free depending on how much you spend on adwords. If you spend a dollar on adWords, your next $10 on Google checkout is free.
[Paypal][2] is 1.9% to 2.9% + $0.30 USD <span style='color:grey'>(2.9% for up to $30,000/month, 1.9% for more... |
I'm not a security expert, but I think the most important fact you should be aware of, before testing security, is what you are trying to protect. Only if you know what you are trying to protect, you can do a proper analysis of your security measures and only then you can start testing those implemented measures.
Ve... |
In IIS, enable annonymous access and allow the web.config to handle user authentication.
If this doesn't work, please can you send a sample of your web.config. |
A VirtualHost would also work for this and may work better for you as you can host several projects without the need for subdirectories. Here's how you do it:
httpd.conf:
NameVirtualHost *:80
# ...
<VirtualHost *:80>
DocumentRoot C:\projects\transitCalculator\trunk\
ServerName t... |
A VirtualHost would also work for this and may work better for you as you can host several projects without the need for subdirectories. Here's how you do it:
httpd.conf (or extra\httpd-vhosts.conf relative to httpd.conf. Trailing slashes "\" might cause it not to work):
NameVirtualHost *:80
# ...
... |
With respect to diff and merging, I think the version control is more critical for graphics and media elements. If you think about it, most designers are going to be the sole owners of a file -- at least in the case of graphics -- or at least I would think that'd be the case. I'd be curious to hear from a designer. |
Use of 3rd party libraries/components in production |
|bestpractices| |
When using 3rd party libraries/components in production projects, are you rigorous about using only released versions of said libraries?
When do you consider using a pre-release or beta version of a library (in dev? in production, under certain circumstances)?
If you come across a bug or shortcoming of the libr... |
|untagged| |
|untagged| |
Off the top of my head, pretty much any card since a geforce 2 or something can do it. There's always a performance hit, but this varies on the card and AA mode (of which there are about 100 different kinds) but generally it's quite a performance hit. |
For more than you ever wanted to know about `sort`, read the [specification of `sort`][1] in the [Single Unix Specification v3][2]. It states
> Comparisons [...] shall be performed using the collating sequence of the current locale.
IOW, how `sort` sorts is dependent on the locale (language) settings of the envir... |
I've got 2005 and 2008 installed concurrently.
2008 is a superset of 2005, so I have no reason whatsoever to have them both, I just haven't gotten around to un-installing it yet |
Agree with Orion Edwards, pretty much everything new can. Performance also depends greatly on the resolution you run at. |
I haven't used Oracle's table clusters myself, but I understand that its index table clusters are very much like MS SQL Server's clustered indexes. That is, the row data is physically organized by the clustered index's key.
That makes one ideal for a heavily-accessed column that has a reasonably small number of poss... |
How do you begin designing a large system? |
|java| |
It's been mentioned to me that I'll be the sole developer behind a large new system. Among other things I'll be designing a UI and database schema.
I'm sure I'll receive some guidance, but I'd like to be able to knock their socks off. What can I do in the meantime to prepare, and what will I need to keep in mind w... |
AFAIK, pretty much every OS X developer uses Xcode.
That, and Interface Builder for creating the GUIs.
FWIW, try to get hold of a copy of Hillegas's book, as it's a great introductory tutorial, and the reference Docs Apple provides really aren't. (They are generally very good reference docs, however). |
I'd suggest you pick a fun little product and dive in. If you're looking for a book I'd suggest [Cocoa Programming for Max OSX][1] which is a very good introduction both to Objective-C and Cocoa.
XCode is pretty much the de facto IDE and free with OSX. It should be on your original install DVD. It's good but not as ... |
Before you start coding, plan out your database schema - everything else will flow from that. Getting the database reasonably correct early on will save you time and headaches later. |
I don't know if this is the right way to do it but you could add a prebuild event to your startup projcet (if it's static) to clean the project which will force a rebuild.
something like:
devenv project.csproj /clean
|
Do you know much about OOP? If so, look into Spring and Hibernate to keep your implementation clean and [orthagonal][1]. If you get that, you should find TDD a good way to keep your design compact and lean, especially since you have "automated testing" up and running.
UPDATE:
Looking at the first slew of answers,... |
If the OP is asking about idomatic sorting expressions, then not all languages have a *natural* expression built in. For c I'd go to `<stdlib.h>` and use `qsort`. Something on the lines of :
/* non-functional mess deleted */
to sort the arguments into lexical order. Unfortunately this idiom is rather hard to ... |
I'd use a database simply for maintainability - also multiple edits on a file may cause some getting missed out. |
How do you full-text search multiple criteria on left-joined tables in SQL Server? |
|sql-server|full-text-search| |
I have a query that originally looks like this:
select c.Id, c.Name, c.CountryCode, c.CustomerNumber, cacc.AccountNumber, ca.Line1, ca.CityName, ca.PostalCode
from dbo.Customer as c
left join dbo.CustomerAddress as ca on ca.CustomerId = c.Id
left join dbo.CustomerAccount as cacc on cacc.CustomerId... |
The best way that I have found is the [MySQL Migration Toolkit][1] provided by MySQL. I have used it successfully for some large migration projects.
[1]: http://www.mysql.com/products/tools/migration-toolkit/ |
I would define memory leaks as an object not freeing up all the memory allocated after it has completed. I have found this can happen in your application if you are using Windows API and COM (i.e. unmanaged code that has a bug in it or is not being managed correctly), in the framework and in third party components. I h... |
You can use a [3rd-party library such as SharpZip](http://sharpdevelop.net/OpenSource/SharpZipLib/) as Tom pointed out.
Another way (without going 3rd-party) is to use the Windows Shell API. You'll need to set a reference to the Microsoft Shell Controls and Automation COM library in your C# project. Gerald Gibson ha... |
You can do it by adding the following anywhere in your code
$Id:$
So for example Jeff did:
<div id="svnrevision">svn revision: $Id:$</div>
and when checked in the server replaced $Id:$ with the current revision number. I also [found this reference][1].
There is also **$Date:$**, **$Rev:$**, **$... |
You could use conditional comments to get IE and Firefox to do different things
<![if !IE]>
<p> Firefox only code</p>
<![endif]>
<!--[if IE]>
<p>Internet Explorer only code</p>
<![endif]--> |
You could use conditional comments to get IE and Firefox to do different things
<![if !IE]>
<p> Firefox only code</p>
<![endif]>
<!--[if IE]>
<p>Internet Explorer only code</p>
<![endif]-->
The browsers themselves will ignore code that isn't meant for them to read. |
Personally, I feel like it's important to remain consistent. If you have getters and setters, use them. The only time I would access a field directly is when the accessor has a lot of overhead. It may feel like you're bloating your code unnecessarily, but it can certainly save a whole lot of headache in the future. ... |
Windows Vista Virtual PC-image for Visual Studio-development minimized |
|windows-vista|virtual-pc| |
Which features and services in Vista can you remove with nLite (or tool of choice) to make a Virtual PC-image of Vista as small as possible?
The VPC must work with development in Visual Studio.
A normal install of Vista today is like 12-14 GB, which is silly when I got it to work with Visual Studio at 4 GB. But w... |
@Motti: Combining the `grep`s isn't working, it's having no effect.
I understand that without the trailing `$` something else may folow the checksum & still match, but it didn't work at all with it so I had no choice...
GNU grep 2.5.3 and GNU bash 3.2.39(1) if that makes any difference.
And it looks like the l... |
Does your video card support Shader 2.0? You can refer [to this wiki page][1] to see if it does...
[1]: http://en.wikipedia.org/wiki/Pixel_shader |
You can also create an ISAPI filter that re-writes urls. The user enters a url with no extension, but the filter will interpret the request so that it does. Note that in IIS it's real easy to screw this up, so you might want to find a pre-written one. I haven't used any myself so I can't recommend a specific product... |
@baldy
Thanks. I'll look at as well. Oddly enough though I didn't change the connection string at all. And when I created a new project and tried to drag-n-drop a DB into the LINQ to SQL diagram that error was raised then as well.
|
Error handling / error logging in C++ for library/app combo |