instruction
stringlengths
0
30k
From a friend of mine. [http://gist.github.com/4069][1] # Ways to execute a shell script cmd = "echo 'hi'" # Sample string that can be used # 1. Kernel#` - commonly called backticks - `cmd` # This is like many other languages, including bash, PHP, and Perl # Returns the result...
@travis Unfortunately It has to be over HTTP inside the users browser. I'll update the question to be more clear about that.
The way I've dealt with this in the past is to create a new collection to serve as the data provider for the combobox, and then I listen for changes to the original source (using an `mx.BindingUtils.ChangeWatcher`). When I get such a notification, I recreate my custom data provider. I wish I knew a better way to ap...
It really depends on how bad it is. If it's a small system, and you fully understand it, then a rewrite is not crazy. On the other hand, if it's a giant legacy monster with ten million lines of undocumented mystery code, then you're really going to have a hard time with a full rewrite. Points to consider: ...
[bittorrent][1]? There have been a few web-based versions already ([bitlet][2], [w3btorrent][3]), and [Azureus][4] was built using java, so it's definitely possible. [1]: http://www.bittorrent.com/ [2]: http://www.bitlet.org/ [3]: http://torrentfreak.com/w3btorrent-a-bittorrent-client-for-your-web-serve...
[bittorrent][1]? There have been a few web-based versions already ([bitlet][2], [w3btorrent][3]), and [Azureus][4] was built using java, so it's definitely possible. Edit: @[TonyB][5] is it limited to port 80? [1]: http://www.bittorrent.com/ [2]: http://www.bitlet.org/ [3]: http://torrentfreak.com/w3...
Can you split the files into pieces and then rejoin them after the download?
It's kinda difficult for us. We have a custom program that writes a lot of the sql code for the different databases for us. Essentially it writes the code once and then copies it over and over again along with placing the change database commands etc. It also makes sure that the primary key identities etc are in sync...
Use a code generator / scripting language to implement the original schema and updates to it over time.
More likely you'd put an Access database in App_Data. If you're using a MSSQL MDF file, you'll definitely still need either MSSQL or MSSQL-Express. Your question is confusing, however. You seem to interchanging data access, ORM and the actual database. You can use SubSonic with MySQL, but you cannot use LINQ to S...
Having experiences with both (CR and SSRS) here is the lowdown of what I think: CR lets you develop a report very fast. As long as its simple. If it gets slightly complicated, it gets fishy trying to make it do what you want. Per example you are limited to a max hierarchy of 2 subreports. It gets weird when you have...
Example for SVN: trunk/ branch/ tags/ The trunk should be kept at a point where you can always push a release from it. There should be no huge gaping bugs that you know about(of course there will be eventually but that is what you should strive for). Every time you need to make a new feature, do a desi...
Example for SVN: trunk/ branch/ tags/ The trunk should be kept at a point where you can always push a release from it. There should be no huge gaping bugs that you know about(of course there will be eventually but that is what you should strive for). Every time you need to make a new feature, do a desi...
I think outsourcing the problem is the best bet: send it to the Google (or Yahoo) geocoder. The geocoder returns not only the lat/long (which aren't of interest here), but also a rich parsing of the address, with fields filled in that you didn't send (including ZIP+4 and county). For example, parsing "1600 Amphithe...
EDIT: Having tried Cem Catikkas' <a href="http://stackoverflow.com/questions/34571/whats-the-best-way-of-unit-testing-private-methods#34658">solution using reflection</a>, I'd have to say his was a more elegant solution than I have described here. However, if you're looking for an alternative to using reflection, and h...
Reading Email using Pop3 in C#
|c#|unicode|pop3|
I am looking for a method of reading emails using Pop3 in C# 2.0. Currently, I am using code found in [CodeProject][1]. However, this solution is less than ideal. The biggest problem is that it doesn't support emails written in unicode. [1]: http://www.codeproject.com/KB/IP/Pop3MimeClient.aspx?fid=341657
FlashDevelop is really easy to setup with the Flex SDK. Just download FlashDevelop, then download the Flex SDK. In FlashDevelop go to Tools > Program Options > AS3Context (under Plugins) > Set the "Flex SDK Location" to the root of the folder you extracted the SDK to and build away. FlashDevelop even has a basic MXML...
Pretty much any of them would work (even though SQLLite wasn't meant to be used in a concurrent multi-user environment, which could be a problem...) since you don't want to index the actual contents of the files. The only limiting factor is the maximum "packet" size of the given DB (by packet I'm referring to a quer...
I had the exact same problem, and this article helped me clean up all the related files from my system and do a fresh install of both Visual Studio and the SQL client components. Give it a try and let me know if it helps you out: http://support.citrix.com/article/CTX115270
Historically 33 seems like a popular choice, and it tends to work pretty well. Noone knows why though. For more details, look at [http://www.cse.yorku.ca/~oz/hash.html](http://www.cse.yorku.ca/~oz/hash.html).
A great resource for 'best practices' is the [Google Testing Blog][1], for example a recent post on [Writing Testable Code][2] is a fantastic resource. Specifically their 'Testing on the Toilet' series weekly posts are great for posting around your cube, or toilet, so you can always be thinking about testing. [...
The problem that seems to catch a lot of people, is that you can create a table that by definition would hold more than 8K of data, and it will accept it just fine. And the table will work fine, up until the point you actually try to insert more than 8K of data into the table. So, let's say you create a table wit...
You can set a breakpoint within javascript in VS2005 but in addition to debugging needing to be enabled in IE, you can only set the breakpoint in a .js file. you cannot debug any inline javascript code. I also sometimes have problems when trying to debug my javascript when using the attach process method to go into...
You want to use something that is relatively prime to the size of your set. That way, when you loop around, you won't end up on the same numbers you just tried.
Strange. My VS2008SP1 install exhibits your desired behavior (in a web application project). I do not recall making any explicit changes.
I had an interesting discussion with a coworker about hash function recently. Our conclusions were as follows: If you really need to write a good hash function that minimizes collisions more than the default implementations available in the standard languages you need an advanced degree in mathematics. If you're...
Yes, as a matter of fact there is. You will need to write a custom assert function yourself, as C++'s `assert()` is exactly C's `assert()`, with the `abort()` "feature" bundled in. Fortunately, this is surprisingly straightforward. _Assert.hh_ template <typename X, typename A> inline void Assert(A asse...
I think you answered it yourself. The page you are linking to does just that: detect which version of Silverlight the user has (not if s/he installs it). From the page: > After a little poking around, I found that Google Analytics has support for reporting a user-defined field. ... > Basically this detects the...
While I agree with Lucas that regular expressions are not all that scary, I still think that you should go with a specialized HTML parser. This is because the HTML standard is hairy enough (especially if you want to parse arbitrarily "HTML" pages taken off the Internet) that you would need to write a lot of code to han...
Edit: If you want to improve this script, feel free to update it it using the following link. <br> From a friend of mine. [http://gist.github.com/4069][1] # Ways to execute a shell script cmd = "echo 'hi'" # Sample string that can be used # 1. Kernel#` - commonly called backticks - `cmd`...
Data verifications in Getter/Setter or elsewhere ?
|optimization|data|getter|setter|verification|
I'm wondering if it's a good idea to make **verifications** in **getters** and **setters** or elsewhere in the code. This might surprise you be when it comes to **optimizations** and **speed-ing** up the code, I think you should not made verifications in getters and setters but in the code where your're **updating**...
Use Prepared/Parameterized queries!
My team scripts out all database changes, and commits those scripts to SVN, along with each release of the application. This allows for incremental changes of the database, without losing any data. To go from one release to the next, you just need to run the set of change scripts, and your database is up-to-date,...
I would suggest putting the log file onto a seperate disk, though should give you a little performance gain so that your not trying to both read and write to the same disk as the website. If you cannot put the log file on a seperate disk, then I would simply choose a folder of your choice. In any case, you will have...
I would suggest putting the log file onto a seperate disk, though should give you a little performance gain so that your not trying to both read and write to the same disk as the website. If you cannot put the log file on a seperate disk, then I would simply choose a folder of your choice. In any case, you will have...
If your wanting to find a way of generating prime numbers, this have been covered in a [previous question][1]. [1]: http://stackoverflow.com/questions/622/most-efficient-code-for-the-first-10000-prime-numbers#2753
Darren, that would work if the types were specific enumerations - for general enumerations to work you have to cast them to ints (or more likely uint) to do the boolean math: public static bool IsSet( this Enum input, Enum matchTo ) { return ( Convert.ToUInt32( input ) & Convert.ToUInt32( matchTo ) ) ...
@valters I disagree with your statement that tests shouldn't break the build. The tests should be an indication that the application doesn't have new bugs introduced for the functionality that is tested (and a found bug is an indication of a missing test). If tests don't break the build, then you can easily run ...
How to avoid redefining VERSION, PACKAGE, etc.
|c|linux|unix|automake|autoconf|
I haven't seen any questions relating to GNU autoconf/automake builds, but I'm hoping at least some of you out there are familiar with it. Here goes: I have a project (I'll call it myproject) that includes another project (vendor). The vendor project is a standalone project maintained by someone else. Including a...
I use [wxWidgets][1] myself. It makes good use of the C++ language features and uses smart pointers, so object and memory management is not that hard. In fact, it feels like writing in a scripting language. Coupled with a dialog editor/code generator like [wxFormBuilder][2] or [wxDesigner][3], (links to screenshots)...
@[Martín][1] The reason you were not getting the UAC prompt is because UAC can only change how a process is **started**, once the process is running it must stay at the same elevation level. The UAC will prompt will happen if: - Vista thinks it's an installer ([lots of rules here][2], the simplest one is if it'...
For most people in a corporate environment the choice comes down to "the one we have". Since you seem to be fortunate enough to have a choice, I'll take a quick run through the questions and maybe pose a few more at the end. The biggest criterion may be cost. Do you want/are you prepared to pay for your DBMS plat...
Using primary keys with business meaning ("natural keys") certainly has its merits, but it can make refactoring your database _very_ difficult. Use caution, especially if there's any reason to believe the database structure will change over time.
Depending on what version of IIS you're considering, I would second lbrandy's recommendation to check out [PowerShell][2]. Microsoft is working on a PowerShell provider for IIS (specifically version 7). There is a decent post about this at [http://blogs.iis.net/thomad/archive/2008/04/14/iis-7-0-powershell-provider-tech...
How do you reference a bitmap on the stage in actionscript?
|flash|actionscript-3|
How do you reference a bitmap on the stage in flash using actionscript 3? I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/img3. he...
How do you reference a bitmap on the stage in flash using actionscript 3? I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/img3. he...
Lightweight IDE for Linux
|c++|php|linux|ide|freeware|lightweight|
Even though I have a robust and fast computer (Pentium Dual Core 2.0 with 2Gb RAM), I'm always searching for lightweight software to have on it, so it runs fast even when many apps are up and running simultaneously. On the last few weeks I've been migrating gradually to Linux and want to install a free lightweight y...
It depends. Generally, code should fail fast. If the value can be set by multiple points in the code and you validate only on after retrieving the value, the bug appears to be in the code that does the update. If the setters validate the input, you know what code is trying to set invalid values.
Well, one of the reaons why classes usually contain private members with public getters/setters is exactly because they can verify data. If you have a Number than can be between 1 and 100, i would definitely put something in the setter that validates that and then maybe throw an exception that is being caught by the...
gedit - Syntax hilightihng - Fast, lightweight - Tabs - GUI
Check out: - [Open Source Web Designs][1] - [CSS Remix][2] - [Best Web Gallery][3] - [CSS Based][4] - [CSS Beauty][5] [1]: http://www.oswd.org/ [2]: http://cssremix.com/ [3]: http://bestwebgallery.com/ [4]: http://www.cssbased.com/ [5]: http://www.cssbeauty.com/gallery/
It's because the pipe version is creating a subshell, which reads the variable into its local space which then is destroyed when the subshell exits. Execute this command $ echo $$;cat | read a 10637 and use pstree -p to look at the running processes, you will see an extra shell hanging off of your mai...
What is keyboard shortcut to view all open documents in Visual Studio 2008
|visual-studio|keyboard|shortcut|
I am trying to learn the keyboard shortcuts in Visual Studio in order to be more productive. So I downloaded a document showing many of the default keybindings in Visual Basic when using the VS 2008 IDE from Microsoft: http://www.microsoft.com/downloads/details.aspx?familyid=255b8cf1-f6bd-4b55-bb42-dd1a69315833&displa...
For my projects, I always use this structure. >- trunk > - config > - docs > - sql > - initial > - updates > - src > - app > - test > - thirdparty > - lib > - tools >- tags >- branches - config - Used to store my application config templates. ...
We practice highly componentised development using Java, we have about 250 modules in trunk that have independent life cycles. Dependencies are managed through Maven (that's a best practice right there), every iteration (by-weekly) actively developed modules get tagged with a new version. 3 digit version numbers with s...
It appears that I was misunderstanding how mdf files are accessed through .net. There is no MS SQL Server available on the server, so it looks like I'm screwed.
One of the few differences between SQL Server Express and the "full" SQL Server is the ability to automatically attach to MDF files - what Microsoft call "[xcopy deployment][1]". SQL Server Express is free (as in beer) so unless you have no administrator rights on the box for installation, this should work fine. ...
programmatically merge .reg file into win32 registry
|registry|unit-testing|
What's the best way to programmatically merge a .reg file into the registry? This is for unit testing; the .reg file is a test artifact which will be added then removed at the start and end of testing. Or, if there's a better way to unit test against the registry... thanks.
|unit-testing|registry|
There is a new book coming out, [Brownfield Application Development in .NET][1] by Baley and Belcham. The first chapter is free, and talks about these issues from a mostly platform agnostic perspective. [1]: http://www.manning.com/baley/
@levand The problem only exist in IE (it works in Firefox) so while ActiveX would only work on IE, IE is the only one we need the work around for. @travis - interesting idea. Not sure if it will work for what I need but I'll keep it in mind. I'm hoping to find something to integrate with the existing site instead...
Here is a very free version of VisualSVN called [Ankhsvn][1]. Its much better now that collabnet has taken it over. [1]: http://ankhsvn.open.collab.net/
How do I restore files to previous states in git?
|git|
Given the following interaction: $ git add foo $ git commit -m "Initial import of 'foo'" $ rm foo # This could be any destructive action on foo, like editing it. How do I restore 'foo' in my working copy? I'm looking for something like: $ git <magic> foo Restored foo to revision <blah>.
> Doesn't using multiple open-id providers sort of undermine the point of open id? No. Say you are using a Yahoo OpenID, but you decide to move to Google instead. Multiple OpenIDs per account allows you to associate your account with the Google OpenID, then deauthorize the Yahoo OpenID.
git checkout foo That will reset `foo` to HEAD. You can also: git checkout HEAD^ foo for one revision back, etc.
@jjnguy I'm looking for a java applet or ActiveX component that will do that for me. These are non-technical users so we really just want to have them click download and the full file ends up in the specified location
You could use some kind of random challenge string that's used along with the username to create the hash. If you store the challenge string on the server in a database you can then ensure that it's only used once, and only for one particular user.
catching button clicks in javascript without server interaction
|javascript|ajax|
I've got a sign up form that requires the user to enter their email and password, both are in two separate text boxes. I want to provide a button that the user can click so that the password (which is masked) will appear in a popup when the user clicks the button. currently my JS code for this is as follows: ...
Given the module foo.py class foo(object): pass class bar(foo): pass class baz(foo): pass class grar(Exception): pass def find_subclasses(module, clazz): for name in dir(module): o = getattr(module, name) try: if issubclass(o, clazz)...
C# .Net 3.5 Code to replace a file extension using LINQ
|c#|linq|.net-3.5|
I've written this very simple function to replace a file extension using LINQ in C#.NET 3.5 however I have a feeling that there's a more elegant way to do this. (I'm not committed to using LINQ here - just looking for a more elegant approach.) Ideas? private string ReplaceFileExtension(string fileName, str...
Would having the sources for the dependency help? You can tell the eclipse plugin to download those (and refer to them in the .classpath) with `-DdownloadSources=true`
If you only accept each key once (say, make the key a GUID, and then check when it comes back), that would prevent replays. Of course, if the attacker responds *first*, then you have a new problem...
NUnit is a good tool for any of the .NET languages. Unit tests can be used in a number of ways: 1. Test Logic 2. Increase separation of code units. If you can't fully test a function or section of code, then the parts that make it up are too interdependant. 3. Drive development, some people write tests *be...
Microsoft has documented this at [http://msdn.microsoft.com/en-us/library/cc463912(EXCHG.80).aspx][1] [1]: http://msdn.microsoft.com/en-us/library/cc463912(EXCHG.80).aspx
@David Schlosnagle [mentions][1] mentions Josh Bloch's [Effective Java][2] -- this is a **must-read** for any Java developer. There is a related issue: for immutable value objects, you should also consider overriding `compare_to`. The standard wording for if they differ is in the [Comparable API][3]: > It is gen...
This is where I started. [haskell.org][1] [1]: http://www.haskell.org/haskellwiki/Category:Tutorials
Tool for generating CSS skeleton?
|css|markup|
My HTML is all marked up, ready to make it rain CSS. The problem is that I have to go back and find out what all my id and class names are so I can get started. What I need is a tool that parses my HTML and spits out a stylesheet with all the possible elements ready to be styled (maybe even with some defaults). Does...
Haskell's datatypes are called "algebraic" because of their connection to [categorical initial algebras][1]. But that way lies madness. @olliej: ADTs are actually "sum" types. Tuples are products. [1]: http://en.wikipedia.org/wiki/Initial_algebra