instruction
stringlengths
0
30k
if you are in SQL Server you can use CAST(RAND() as varchar(10)) **EDIT**: This will only work inside an iteration. As part of a multi-row insert it will use the same RAND() result for each row.
The interesting side-effect of using nullable types is that you can't really use a shorthand IF. Shorthand IF has to return the same Type from both conditions, and it can't be null in either case. So, cast or write it out :)
The [devcon][1] tool can control the NIC devcon disable (id or name) devcon enable (id or name) [1]: http://support.microsoft.com/kb/311272
The [devcon][1] tool can control the NIC, but not the interface directly. It's a command-line version of the Device Manager applet. devcon disable (id or portion of name) devcon enable (id or portion of name) [1]: http://support.microsoft.com/kb/311272
How can I provide dynamic CSS styles or custom theme for web site?
|asp.net|themes|branding|
There are plenty of ways to provide a dynamic style/theme for a web site, but I am looking for some help on some best practices or techniques that have worked well for others. I am creating a web site that needs to provide the ability for customers to create or specify their own colors, style, theme, or layout. I'm...
I use the same .vimrc file for GVim and the command line vim. I tend to use tabs in GVim and buffers in the command line vim, so I have my .vimrc set up to make working with both of them easier: " Movement between tabs OR buffers nnoremap L :call MyNext()<CR> nnoremap H :call MyPrev()<CR> "...
When trying to commit to a cvs branch after adding a new file I get this error Assertion failed: key != NULL, file hash.c, line 317 Any idea how to fix it so I can check my code in? both server and client are Linux there are pre-commits involved
Not free. Not opensource. But I have found AgitarOne Agitator (http://www.agitar.com/solutions/products/agitarone.html) to be REALLY good for automatically generating unit tests AND looking for unwanted obscure side effects
One has exactly space for 11 bytes, the other for exactly 11 characters. Some charsets such as Unicode may use more than one byte per char, therefore the 11 byte field might have space for less than 11 chars depending on the encoding. See also [http://www.joelonsoftware.com/articles/Unicode.html][1] [1]: http...
One has exactly space for 11 bytes, the other for exactly 11 characters. Some charsets such as Unicode variants may use more than one byte per char, therefore the 11 byte field might have space for less than 11 chars depending on the encoding. See also [http://www.joelonsoftware.com/articles/Unicode.html][1] ...
Probability of finding TCP packets with the same payload?
|statistics|tcp|protocols|probability|packets|
I had a discussion with a developer earlier today re identifying TCP packets going out on a particular interface with the same payload. He told me that the probability of finding a TCP packet that has an equal payload (even if the same data is sent out several times) is very low due to the way TCP packets are construct...
you could always petition wp to add your widget to their 'approved' list, but who knows how long that would take. you're talking about a way to circumvent the rules they have in place about posting arbitrary script. myspace javascript exploits in particular have increased awareness of the possibility of such workaround...
Rather than adding programmers, one can think about adding administrative help. Anything that will remove distractions, improve focus, or improve motivation can be helpful. This includes both system and administration, as well as more prosaic things like getting lunches.
This is pretty cheesy, but it should get the job done. Assuming you're currently cd'd into the directory containing all of your files: mkdir ../outdir ls | sort -n | while read fname; do mv "$fname" ../outdir/; read; read; read; done The `sort -n` is there assuming your filenames don't all have the same...
I may have found an answer to my own question. The [FormattedText][1] class seems to have what I'm after. [1]: http://msdn.microsoft.com/en-us/library/system.windows.media.formattedtext.aspx
!#/bin/sh if [ -e 'current_version' ]; then version=`cat current_version`; version=`echo $version | tr -ds [[:blank:]]` if [ -n '$version' ]; then if [ -d '$version' ]; then cd $version else echo $version is not a directory ...
!#/bin/sh if [ -e 'current_version' ]; then version=`cat current_version`; version=`echo $version | tr -ds [[:blank:]]` if [ -n "$version" ]; then if [ -d "$version" ]; then cd "$version" else echo $version is not a directory ...
The big drawbacks to NHibernate, Castle, etc., is that they're not exactly light-weight (especially NHibernate.) Linq to SQL is good for a light-weight, limited use ORM.
Force Internet Explorer to use a specific Java Runtime Environment install?
|internet|explorer|java|plugins|
How can I force Internet Explorer 6.0 to use a a particular JRE when I have several installed?
When viewing someone else's webpage containing an applet, how can I force Internet Explorer 6.0 to use a a particular JRE when I have several installed?
To augment the bag-of-words idea: There are a few ways you can also pay some attention to n-grams, strings of two or more words kept in order. You might want to do this because a search for "space complexity" is much more than a search for things with "space" AND "complexity" in them, since the meaning of this phra...
![alt text][1] [1]: http://www.webcomicsnation.com/memberimages/20070107.png
When you write > does a lot of object comparisons using GetHashCode() i sense there is something horribly wrong with this code. The GetHashCode method does not guarantee, that the returned hash values should be in any way unique given two different objects. As far as GetHashCode is concerned, it can return 0 for ...
So, it sounds like you are gathering categories. The nodes are the entry points of this categories. How about "TopCategoryNode", "CategoryEntry" then for som,ething that is below them. Or, if you want to divide more, something like "CategoryCSS", "CategoryLayout" etc? This is kind of generic, but you make clear that...
Changing the distribution of any function to another involves using the inverse of the probability function you want. In other words, if you know the probability function p(x) and it has an inverse: Inv(p(x)) then by using the random probability function (uniform distribution) and casting the result value through th...
Is the Contains Method in java.lang.String Case-sensitive?
|java|string|
Say I have 2 strings, String s1 = "AbBaCca"; String s2 = "bac"; I want to preform a check to see if s2 is contained within s1. I can do this with: return s1.contains(s2); I am pretty sure that contains() is case sensitive, however I can't determine this for sure from reading the documentation. ...
Say I have 2 strings, String s1 = "AbBaCca"; String s2 = "bac"; I want to preform a check returning that s2 is contained within s1. I can do this with: return s1.contains(s2); I am pretty sure that contains() is case sensitive, however I can't determine this for sure from reading the documentat...
Is it the filename or the whole URL used as a key in browser caches?
|javascript|browser|url|caching|filenames|
It's common to want browsers to cache resources - JavaScript, CSS, images, etc. until there is a new version available, and then ensure that the browser fetches and caches the new version instead. One solution is to embed a version number in the resource's filename, but will placing the resources to be managed in th...
SqlServer Express slow performance
|sql-server-express|slow|performance|asp.net|
Yesterday, I did a stress test for a .NET web application. I did this for 2 reasons, I wanted to see what performance was like under real world conditions and also to make sure we hadn't missed any problems during testing. We had 30 concurrent users in the application using it as they would during the normal course of ...
|sql-server-express|performance|asp.net|
|asp.net|performance|sql-server-express|
Yesterday, I did a stress test for a .NET web application. I did this for 2 reasons, I wanted to see what performance was like under real world conditions and also to make sure we hadn't missed any problems during testing. We had 30 concurrent users in the application using it as they would during the normal course of ...
|asp.net|performance|subsonic|sql-server-express|
I wasn't able to locate any info on the Adobe error code, so I ended up installing [xpdf via Darwinports][1]. Loading my PDF with xpdf spit out much more useful error information and I was able to track down the problem. (I was creating a circular reference in a form when I copied content from one document to another...
I'm in the middle of writing a rails/flex application and we're moving to using a JSON communication within the REST framework. Simple HTTP requests from the Flex side handling JSON responses seemed like the best way to decouple the client and server. XML is just as easy. For what it's worth, we're using the PureMV...
Can't Drag Items Onto An Empty List Using Scriptaculous Sortables
|javascript|drag-and-drop|scriptaculous|
I have three unordered lists that have been created as Scriptaculous Sortables so that the user can drag items within the lists and also between them: var lists = ["pageitems","rowitems","columnitems"]; Sortable.create("pageitems", { dropOnEmpty: true, containment: lists, constraint: false }); ...
What do you mean when you say "heavily included"? If you want to calculate how many times the file is included, use this bash command: find . -name "*.cpp" -exec egrep "include" {} \; 2>/dev/null | sort | uniq -c | sort -k 1rn,1 | head -20
If you wish to know which files are included most of all, use this bash command: >find . -name '*.cpp' \ > > -exec egrep '^[:space:]*#include[[:space:]]+["<][[:alpha:][:digit:]_.]+[">]' {} \; \ > > | sort | uniq -c | sort -k 1rn,1 \ > > | head -20 It will display top 20 files ranked by ...
If you wish to know which files are included most of all, use this bash command: >find . -name '*.cpp' -exec egrep '^[:space:]*#include[[:space:]]+["<][[:alpha:][:digit:]_.]+[">]' {} \; > >> | sort | uniq -c | sort -k 1rn,1 >> | head -20 It will display top 20 files ranked by amount of times they were inc...
If you wish to know which files are included most of all, use this bash command: >find . -name '*.cpp' -exec egrep '^[:space:]*#include[[:space:]]+["<][[:alpha:][:digit:]_.]+[">]' {} \; >> | sort | uniq -c | sort -k 1rn,1 >> | head -20 It will display top 20 files ranked by amount of times they were includ...
I'd look through your code and make sure all handles to open (generated) files have been closed properly. Sometimes you just can't rely on the garbage collector to sort these things out.
You will want to kill the line: C-a C-k, and then C-y or ?
You can check the size of the file using the -s operator. <pre> use strict; use warnings; use File::Slurp qw(read_file write_file); my $file = 'path/to/file'; my $size_file = 'path/to/file/keeping_the_size'; my $excel_file = 'path/to/excel/file.xls'; my $current_size = -s $file...
You can check the size of the file using the -s operator. <pre> use strict; use warnings; use File::Slurp qw(read_file write_file); use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; use Spreadsheet::WriteExcel; my $file = 'path_to_file'; my $size_file = 'path_to_file_keeping_th...
Your only option seems to be client-side validation, because server side means the file was already uploaded. Also the MIME type is usually dictated by the file extension. use a JavaScript Framework like jQuery to overload the onsubmit event of the form. Then check the extension. This will limit most attempts. ...
I've written something very similar. I used the FileSystemWatcher to get notifications about changes. I then used a FileStream to read the data (keeping track of my last position within the file and seeking to that before reading the new data). Then I add the read data to a buffer which automatically extracts comple...
document.getElementById('someframe').contentWindow.location.reload();
document.getElementById('some_frame_id').contentWindow.location.reload(); in Firefox, window.frames doesn't include iframes.
document.getElementById('some_frame_id').contentWindow.location.reload(); be careful, in Firefox, window.frames[] cannot be indexed by id, but name or index
I recommend getting the [Zend Studio Toolbar](http://www.zend.com/en/products/studio/downloads). The extension allows you to control which pages are debugged from within the browser instead of from Zend Studio. The options for debugging let you debug the next page, the next form post or all pages. When you debug like...
From javascript, you should be able to get the filename in the onsubmit handler. So in your case, you should do something like: <form onsubmit="if (document.getElementById('fileUpload').value.match(/xls$/) || document.getElementById('fileUpload').value.match(/xlsx$/)) { alert ('Bad file type') ; return false; }...
Best Practices for embedding .NET assemblies in SQL Server
|.net|sql-server-2005|assemblies|
What are some important practices to follow when creating a .NET assembly that is going to be embedded to SQL Server 2005? I am brand new to this, and I've found that there are significant method attributes like: [SqlFunction(FillRowMethodName = "FillRow", TableDefinition = "letter nchar(1)")] I'm also looking...
Windows Forms Test Automation
|winforms|testing|
We are looking for a way to automate windows forms acceptance testing. Our requirements are: - **Must be usable by non-developers** (ie: people with no development environment installed) - Must have a recorder - Must support third-party controls - Must have basic functionality (allow clicking on buttons, inputing...
I'm not sure whether I understand the question. `c !='\n'` is used to stop reading the line when the end of line (linefeed) occurs. Otherwise we would always read it until the limit even if it ends before. The first `s[i++] = c;` in the while-loop doesn't occur if a linefeed has been reached. That's why there is the sp...
If the data you are trying to import is in a reasonable format -- comma-delimited, for example -- and your database server has reasonable command line utilities, this should be no problem. MySQL has the "mysqlimport" command-line tool that will accept various arguments describing the format of the file: mysqlimp...
make sure the file "Particles.cpp" has also included "Particles.h" to start with and the files are in the same folder and they are all part of the same project. it will help if you also share the error message that you are getting from your compiler.
Minimizing the number of projects in your solution makes the problem a little better. And of course all the normal build speed-ups will work, like reducing includes and shrinking obj files size.
Maybe something like that ? public class Person { public class Editor { private readonly Person person; public Editor(Person p) { person = p; } public void SetName(string name) { ...
Maybe something like that ? public class Person { public class Editor { private readonly Person person; public Editor(Person p) { person = p; } public void SetName(string name) { ...
perhaps try data[0].Make
I would either try tying the postback to a button to allow the user to submit their changes and unhook the event handler.
A database is great as part of your program. If quering the data is part of your business logic. XML is best as a file format, especially if you data format is: 1, Hierarchal <br> 2, Likely to change in the future in ways you can't guess <br> 3, The data is going to live longer than the program
I think `internal` is the least complex and best approach (this of course involves multiple assemblies). Short of doing some overhead intensive stack walking to determine the caller in the property setter you could try: interface IPerson { Name { get; set; } } and implement this interfac...
I see a lot of people advocating using a base class to share common functionality. Be careful with this - you should favor composition over inheritance. Inheritance should only be used for polymorphism, when it makes sense from a modelling point of view. It is not a good tool for code reuse. As for the question: Be ...
I see a lot of people advocating using a base class to share common functionality. Be careful with this - you should favor composition over inheritance. Inheritance should only be used for polymorphism, when it makes sense from a modelling point of view. It is not a good tool for code reuse. As for the question: Be ...
> How much do you stand to lose if the end user loads an unauthorised plugin? Admittedly this won't happen often, but when/if it does happen we lose a lot and I although I understand we will produce nothing 100% secure, I want to make it enough of a hindrance to put people off doing it. The annoying thing about g...
I would go with HANDLE drive = CreateFile(_T("\\.\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); // error handling DWORD br = 0; DISK_GEOMETRY dg; DeviceIOControl(drive, IOCTL_DISK_GET_DRIVE_GEOMETRY, 0, 0, &dg, sizeof(dg), &br, 0); // LARGE_INTEGER pos; ...
I would go with HANDLE drive = CreateFile(_T("\\.\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); // error handling DWORD br = 0; DISK_GEOMETRY dg; DeviceIOControl(drive, IOCTL_DISK_GET_DRIVE_GEOMETRY, 0, 0, &dg, sizeof(dg), &br, 0); // LARGE_INTEGER pos; ...
Did you think of using OSGi as a plugin framework? With OSGi you are able to update/replace, load or unload your modules on demand.
ASCII mode also makes file sharing of text files across different platforms more straightforward for end users. They won't have to worry about the default line ending (cr/lf versus just lf for example) since the ASCII mode will do that translation for them on the fly. For most file types you will ALWAYS want to use ...
For further reference the [curses library][1] gives a higher level of control than simply sending characters to the terminal. [1]: http://www.manpagez.com/man/3/ncurses/
Corporal Touchy has answered how this is done at the lowest level. For easier development the [curses library][1] gives a higher level of control than simply sending characters to the terminal. [1]: http://www.manpagez.com/man/3/ncurses/
Depending on your unix implementation ioctl/FIONREAD might do the trick <pre> err = ioctl(pipedesc, FIONREAD, &bytesAvailable); </pre> Unless this returns the error code for "invalid argument" (or any other error) bytesAvailable contains the amount of data available for unblocking read operations at that time.
BSTR objects contain a length prefix, so finding out the length is cheap. Find out the length, allocate a new array big enough to hold the result, process into that, and remember to free it when you're done.
Intellisense in Visual Studio 2005 between C# and VB - can't navigate to definitions
|c#|visual-studio|vb.net|microsoft|intellisense|
I'm absolutely stunned by the fact that MS just couldn't get it right to navigate to the definition of a method, when you're combining C# and VB projects in one solution. If you're trying to navigate from VB to C#, it brings up the "Object Explorer", and if from C# to VB, it generates a metadata file. Honestly, wha...
I'm absolutely stunned by the fact that MS just couldn't get it right to navigate to the definition of a method, when you're combining C# and VB projects in one solution. If you're trying to navigate from VB to C#, it brings up the "Object Explorer", and if from C# to VB, it generates a metadata file. Honestly, wha...
I'm absolutely stunned by the fact that MS just couldn't get it right to navigate to the definition of a method, when you're combining C# and VB projects in one solution. If you're trying to navigate from VB to C#, it brings up the "Object Explorer", and if from C# to VB, it generates a metadata file. Honestly, wha...
Sounds like, the files - after being created - are still locked by the worker process. Make sure that you close all the connections for your file. (remember, using using blocks'll take care of that)
Have you considered taking advantage of RSS/Atom feeds? Why scrape the content when it's usually available for you in a consumable format? There are libraries available for consuming RSS in just about any language you can think of, and it'll be a lot less dependent on the markup of the page than attempting to scrape ...
I was just trying to tackle this very problem yesterday. I don't know exactly what you mean by "dwell" timers, but I tried implementing my very own version of waiting until all changes are done. Unfortunately the only way I could think of to do this was in a separate thread and it turns out that when you create a sep...