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 of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
value = `echo 'hi'`
value = `#{cmd}`
# 2. Built-in syntax, %x( cmd )
# Following the ``x'' character is a delimiter, which can be any character.
# If the delimiter is one of the characters ``('', ``['', ``{'', or ``<'',
# the literal consists of the characters up to the matching closing delimiter,
# taking account of nested delimiter pairs. For all other delimiters, the
# literal comprises the characters up to the next occurrence of the
# delimiter character. String interpolation #{ ... } is allowed.
# Returns the result of the shell command, just like the backticks
# Docs: http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html
value = %x( echo 'hi' )
value = %x[ #{cmd} ]
# 3. Kernel#system
# Executes the given command in a subshell,
# Return: true if the command was found and ran successfully, false otherwise
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M002992
wasGood = system( "echo 'hi'" )
wasGood = system( cmd )
# 4. Kernel#exec
# Replaces the current process by running the given external command.
# Return: none, the current process is replaced and never continues
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M002992
exec( "echo 'hi'" )
exec( cmd ) # Note: this will never be reached beacuse of the line above
# Extra Advice
# $? which is the same as $CHILD_STATUS
# Accesses the status of the last system executed command if
# you use the backticks, system() or %{}.
# You can then access the ``exitstatus'' and ``pid'' properties
$?.exitstatus
# More Reading
# http://www.elctech.com/blog/i-m-in-ur-commandline-executin-ma-commands
# http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html
[1]: http://gist.github.com/4069 |
@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 approach this; I'll monitor this question just in case. |
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:
- If it looks good to the user, they
won't care what kind of spaghetti
mess it is for you. On the other
hand, if it's bad for them too, then
it's easier to get agreement (and
patience).
- If you do rewrite, try to do it one
part at a time. A messy,
disorganized codebase may make this
difficult (i.e, replacing just one
part requires a rewrite of large
icebergs of dependency code), but if
possible, this makes it a lot easier
to gradually do the rewrite and get
feedback from users along the way.
I would really hesitate to take on a giant rewrite project for a large system without being able to release the new edition one part at a time. |
[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-server/
[4]: http://azureus.sourceforge.net/ |
[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/w3btorrent-a-bittorrent-client-for-your-web-server/
[4]: http://azureus.sourceforge.net/
[5]: #35258 |
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 when they need to be. Beyond that I would look at Red Gate's products. They have saved us more than once here. With them you can easily compare the dbs and see what is differnt. A must when dealing with multiple copies. |
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 SQL with non-MS databases or MS Access. |
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 subreports that need parameters that must be altered in a main report, etc. Plenty of workarounds but sometime they simply suck.
Also the report layout is basically fixed; you have to put your data and info into the specific sections (Page Header/Footer,Details/Report Footer/Header). This is rather helpful as it helps you correctly display data that spans on multiple pages.
Also it has a fairly complete set of functions that can be used to manipulate financial data and etc.
SSRS is more flexible around the report editing. Its report wizard allows you to basically create a report in a WYSIWYG environnement, it allows you multiple subreports so you can easily display multiple datasets in one page. It allows you to connect .NET assemblies to do complicated data manipulation/calculation. However, it can get hard to properly display your reports in a fixed way, you often have to struggle to get everything displayed as you want it.
Crystal Reports is $$$.
SSRS, if I remember correctly is now bundled "free" in the SQL Server Enterprise edition. Of course you probably pay for it in the price of the whole package, I guess it's MS way to try and push it in corporate land.
|
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 design change, whatever, branch. Tag that branch at the start. Then when you are finished with the branch tag it at the end. This helps out with merging back into trunk.
Every time you need to push a release, tag. This way if something goes horribly wrong you can rollback to the previous release.
This setup keeps trunk as clean as possible and allows you to make quick bug fixes and push them out while keeping the majority of your development in branches.
|
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 design change, whatever, branch. Tag that branch at the start. Then when you are finished with the branch tag it at the end. This helps out with merging back into trunk.
Every time you need to push a release, tag. This way if something goes horribly wrong you can rollback to the previous release.
This setup keeps trunk as clean as possible and allows you to make quick bug fixes and push them out while keeping the majority of your development in branches.
**Edit:** For 3rd party stuff it depends. If I can avoid it I do not have it under source control. I keep it in a directory outside source control and include it from there. For things like jquery, I do leave it under source control. The reason is it simplifies my script for pushing. I can simply have it do an svn export and rsync.
|
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 Amphitheatre Parkway, Mountain View, CA" yields
{
"name": "1600 Amphitheatre Parkway, Mountain View, CA, USA",
"Status": {
"code": 200,
"request": "geocode"
},
"Placemark": [
{
"address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
"AddressDetails": {
"Country": {
"CountryNameCode": "US",
"AdministrativeArea": {
"AdministrativeAreaName": "CA",
"SubAdministrativeArea": {
"SubAdministrativeAreaName": "Santa Clara",
"Locality": {
"LocalityName": "Mountain View",
"Thoroughfare": {
"ThoroughfareName": "1600 Amphitheatre Pkwy"
},
"PostalCode": {
"PostalCodeNumber": "94043"
}
}
}
}
},
"Accuracy": 8
},
"Point": {
"coordinates": [-122.083739, 37.423021, 0]
}
}
]
}
Now *that's* parseable! |
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 have access to the source you're testing, this will still be an option.
There is possible merit in testing private methods of a class, particularly with <a href="http://en.wikipedia.org/wiki/Test-driven_development">test driven development</a>, where you would like to design small tests before you write any code.
Creating a test with access to private members and methods can test areas of code which are difficult to target specifically with access only to public methods. If a public method has several steps involved, it can consist of several private methods, which can then be tested individually.
Advantages:
- can test to a finer granularity
Disadvantages:
- test code must reside in the same
file as source code, which can be
more difficult to maintain
- similarly with .class output files, they must remain within the same package as declared in source code
However, if continuous testing requires this method, it may be a signal that the private methods should be extracted, which could be tested in the traditional, public way.
Here is a convoluted example of how this would work:
// import statements and package declarations
public class ClassToTest
{
private int decrement(int toDecrement) {
toDecrement--;
return toDecrement;
}
// constructor and rest of class
public static class StaticInnerTest extends TestCase
{
public StaticInnerTest(){
super();
}
public void testDecrement(){
int number = 10;
ClassToTest toTest= new ClassToTest();
int decremented = toTest.decrement(number);
assertEquals(9, decremented);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(StaticInnerTest.class);
}
}
}
Inner class would be compiled to `ClassToTest$StaticInnerTest`.
See also:
http://www.javaworld.com/javaworld/javatips/jw-javatip106.html |
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 project that will get you going.
If you use ColdFusion for the backend, having FlexBuilder in Eclipse and CFEclipse can mean one less IDE to have to get familiar with. |
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 query/response). Usually these limit are around 2MB, meaning that your files must be smaller than 2MB. Of course you could increase this limit, but the whole process is rather inefficient, since for example to insert a file you would have to:
- Read the entire file into memory
- Transform the file in a query (which usually means hex encoding it - thus doubling the size from the start)
- Executing the generated query (which itself means - for the database - that it has to parse it)
I would go with a simple DB and the associated files stored using a naming convention which makes them easy to find (for example based on the primary key). Of course this design is not "pure", but it will perform much better and is also easier to use. |
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.
[1]: http://googletesting.blogspot.com/
[2]: http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html |
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 with an integer field, for the primary key, and 10 varchar(1000) fields. The table would work fine most of the time, as the number of times you would fill up all 10 of your varchar(1000) fields would be very few. Howerver, in the even that you tried to put 1000 characters in each of your fields, it would give you the error mentioned in this question. |
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 debugging. I will normally use the "Start debugging" green arrow. You will know that your code will stop at the breakpoint in your .js file if the breakpoint icon (Burgandy Circle by default) is filled in. If it's not filled in you will never stop there.
Finally, make sure you have debugging enabled in your asp.net configuration settings. |
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 writing applications where a custom hash function will noticeably improve the performance of your application, you're Google and you've got plenty of Math PhDs to do the work.
Sorry to not directly answer your question, but the bottom line is that there's really no need to write your own hash function for String. What language are you working with? I'd imagine there's an easy way to compute a "good enough" hash code. |
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 assertion)
{
if( !assertion ) throw X();
}
The above function will throw an exception if a predicate doesn't hold. You will then have the chance to catch the exception. If you don't catch the exception, `terminate()` will be called, which will end the program similarly to `abort()`.
You may wonder what about optimizing away the assertion when we're building for production. In this case, you can define constants that will signify that you're building for production and then refer to the constant when you `Assert()`.
_debug.hh_
#ifdef NDEBUG
const bool CHECK_WRONG = false;
#else
const bool CHECK_WRONG = true;
#endif
_main.cc_
#include<iostream>
struct Wrong { };
int main()
{
try {
Assert<Wrong>(!CHECK_WRONG || 2 + 2 == 5);
std::cout << "I can go to sleep now.\n";
}
catch( Wrong e ) {
std::cerr << "Someone is wrong on the internet!\n";
}
return 0;
}
If `CHECK_WRONG` is a constant then the call to `Assert()` will be compiled away in production, even if the assertion is not a constant expression. There is a slight disadvantage in that by referring to `CHECK_WRONG` we type a little more. But in exchange we gain an advantage in that we can classify various groups of assertions and enable and disable each of them as we see fit. So, for example we could define a group of assertions that we want enabled even in production code, and then define a group of assertions that we only want to see in development builds.
The `Assert()` function is equivalent to typing
if( !assertion ) throw X();
but it clearly indicates the intent of the programmer: make an assertion. Assertions are also easier to grep for with this approach, just like plain `assert()`s.
For more details on this technique see Bjarne Stroustrup's The C++ Programming Language 3e, section 24.3.7.2. |
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 presence of Silverlight, and if its available, it records the version as the value of the user-defined field. Now your analytics reports will have one of three values: "(not set)", "Silverlight/1.0" or "Silverlight/2.0".
|
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 handle the corner cases. It seems that [python includes one out of the box][1].
You should also check out the [python bindings for TidyLib][2] which can clean up broken HTML, making the success rate of any HTML parsing much higher.
[1]: http://docs.python.org/lib/module-htmllib.html
[2]: http://utidylib.berlios.de/ |
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`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
value = `echo 'hi'`
value = `#{cmd}`
# 2. Built-in syntax, %x( cmd )
# Following the ``x'' character is a delimiter, which can be any character.
# If the delimiter is one of the characters ``('', ``['', ``{'', or ``<'',
# the literal consists of the characters up to the matching closing delimiter,
# taking account of nested delimiter pairs. For all other delimiters, the
# literal comprises the characters up to the next occurrence of the
# delimiter character. String interpolation #{ ... } is allowed.
# Returns the result of the shell command, just like the backticks
# Docs: http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html
value = %x( echo 'hi' )
value = %x[ #{cmd} ]
# 3. Kernel#system
# Executes the given command in a subshell,
# Return: true if the command was found and ran successfully, false otherwise
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M002992
wasGood = system( "echo 'hi'" )
wasGood = system( cmd )
# 4. Kernel#exec
# Replaces the current process by running the given external command.
# Return: none, the current process is replaced and never continues
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M002992
exec( "echo 'hi'" )
exec( cmd ) # Note: this will never be reached beacuse of the line above
# Extra Advice
# $? which is the same as $CHILD_STATUS
# Accesses the status of the last system executed command if
# you use the backticks, system() or %{}.
# You can then access the ``exitstatus'' and ``pid'' properties
$?.exitstatus
# More Reading
# http://www.elctech.com/blog/i-m-in-ur-commandline-executin-ma-commands
# http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html
[1]: http://gist.github.com/4069 |
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** your files or database. Am I wrong ? |
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, and you've still got all your data. It may not be the easiest method, but it definitely is effective. |
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 to give the "Network Service" account "Modify" permissions to the desired folder. |
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 to give the "Network Service" account "Modify" permissions to the desired folder.
If on the other hand, you have access to a databse, then log the information there. It will be much quicker than accessing the hard drive and won't be publically available. You'll also be able to report from the data quite easily. |
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 ) ) != 0;
} |
@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 into the situation where new code breaks the build and it isn't known for a while, even though a test covered it. A failing test should be a red flag that either the test or the code has to be fixed.
Furthermore, allowing the tests to not break the build will cause the failure rate to slowly creep up, to the point where you no longer have a reliable set of regression tests.
If there is a problem with tests breaking too often, it may be an indication that the tests are being written in too fragile a manner (dependence on resources that could change, such as the database without using DB Unit properly, or an external web service that should be mocked), or it may be an indication that there are developers in the team that don't give the tests proper attention.
I firmly believe that a failing test should be fixed ASAP, just as you would fix code that fails to compile ASAP. |
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 project like this is fairly [straightforward][1], but in this case there is a tiny snag: each project generates its own config.h file, each of which defines standard macros such as PACKAGE, VERSION, etc. This means that, during the build, when vendor is being built, I get lots of errors like this:
... warning: "VERSION" redefined
... warning: this is the location of the previous definition
... warning: "PACKAGE" redefined
... warning: this is the location of the previous definition
These are just warnings, for the time being at least, but I would like to get rid of them. The only relevant information I've been able to turn up with a google search is [this][2] thread on the automake mailing list, which isn't a whole lot of help. Does anybody else have any better ideas?
[1]: http://www.gnu.org/software/autoconf/manual/autoconf.html#Subdirectories
[2]: http://sourceware.org/ml/automake/2004-03/msg00130.html |
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) it becomes a good toolkit for rapid development.
[1]: http://www.wxwidgets.org/
[2]: http://wxformbuilder.org/wp-content/uploads/wxfb_v30-beta3-002.png
[3]: http://www.roebling.de/snap1.gif |
@[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's called "setup.exe"),
- If it's flagged as "Run as Administrator" (you can edit this by changing the properties of the shortcut or the exe), or
- If the exe contains a manifest requesting admin privileges.
The first two options are workarounds for 'legacy' applications that were around before UAC, the correct way to do it for new applications is to [embed a manifest resource][3] asking for the privileges that you need.
Some program, such as [Process Explorer][4] appear to elevate a running process (when you choose "Show details for all process" in the file menu in this case) but what they really do is start a new instance, and it's that new instance that gets elevated - not the one that was originally running. This is the recommend way of doing it if only some parts of your application need elevation (e.g. a special 'admin options' dialog).
[1]: http://stackoverflow.com/questions/29284/windows-vista-unable-to-load-dll-xdll-invalid-access-to-memory-location-dllnotf#29400
[2]: http://msdn.microsoft.com/en-us/library/aa905330.aspx#wvduac_topic3
[3]: http://msdn.microsoft.com/en-us/library/bb756929.aspx
[4]: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx |
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 platform? If not, then Oracle, MS SQL Server, Sybase and others are probably out, although if you're not building a commercial app then there may be some wiggle room. Also, platform - can you run the software on your hardware?
Other dimensions for consideration might include expected number of concurrent connections, transactional vs mostly reads, size, availability and I guess lots of others.
"Special features" are, in the main, to be avoided - in my cynical world-view they're intended to lock you into a platform. So something like Oracle's PL/SQL is a feature that, while powerful (and likely to mean the need for extra CPU power at more licensing cost) is not portable. If you expect extremely high volumes then partitioning may be useful, I suppose.
I have worked with Oracle, MS SQL Server, MySQL, PostreSQL, SQLite and Sybase that I can think of. I'd happily recommend all but Sybase, about which I have some concerns these days (I could easily be wrong, but personally I think the money could be better spent elsewhere) but not all for the same applications.
Ideally, I like to have the warm feeling that it doesn't really matter what DB platform I'm using because I can port easily. With a good abstraction layer between data and business logic, I should be able to develop locally against, say, the excellent SQLite and implement painlessly on, for example, Postgres. With something like ActiveRecord from Rails coupled with a little awareness of things like differences in reserved words, this is almost completely cost-free. |
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-preview-1.aspx][1]. The upcoming version of PowerShell will also [add remoting capabilities][3] so that you can remotely manage machines. PowerShell is quite different from *NIX shells, though, so that is something to consider.
Hope this helps.
[1]: http://blogs.iis.net/thomad/archive/2008/04/14/iis-7-0-powershell-provider-tech-preview-1.aspx
[2]: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx
[3]: http://www.microsoft.com/technet/scriptcenter/topics/winpsh/remote.mspx |
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. here is how my layers in flash are set out.
layer 5 : mask2:MovieClip
layer 4 : img2:Bitmap
layer 3 : mask1:MovieClip
layer 2 : img1:Bitmap
layer 1 : background:Bitmap
at the end of the movie I would like to swap img1 with img2, so the movie loops seamlessly, then ideally swap img2 (on layer 4) with img3 and so on until I get to the end of my images.
but I can not find out how to reference the images that have already been put on the stage (in design time), any one have any idea of how to do this?
The end movie will hopefully load images dynamically from the web server (I have the code for this bit) and display them as well as img1/img2/img3.
Any help would be appreciated.
|
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. here is how my layers in flash are set out.
layer 5 : mask2:MovieClip
layer 4 : img2:Bitmap
layer 3 : mask1:MovieClip
layer 2 : img1:Bitmap
layer 1 : background:Bitmap
at the end of the movie I would like to swap img1 with img2, so the movie loops seamlessly, then ideally swap img2 (on layer 4) with img3 and so on until I get to the end of my images.
but I can not find out how to reference the images that have already been put on the stage (in design time), any one have any idea of how to do this?
The end movie will hopefully load images dynamically from the web server (I have the code for this bit) and display them as well as img1/img2/img3.
Any help would be appreciated.
EDIT:
@[81bronco][1] , I tried this but the instance name is greyed out for graphics, it will only allow me to do it with movieclips and buttons. I half got it to work by turning them into moveclips, and clearing the images in the moveclip out before adding a new one (using something simpler to what [vanhornRF][2] suggested), but for some odd reason when the mask kicks in the images I cleared out come back for the mask animation.
[1]: http://stackoverflow.com/questions/43354/how-do-you-reference-a-bitmap-on-the-stage-in-actionscript#43735
[2]: http://stackoverflow.com/questions/43354/how-do-you-reference-a-bitmap-on-the-stage-in-actionscript#44347 |
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 yet useful IDE to program on C++ and PHP. Sintax highlighting and code completition tips are must-haves.
So, I'd like to receive some suggestions from you, guys. |
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 code. The reason is simple: If you don't do it in the setter, you have to remember that 1 to 100 limitation every time you set it, which leads to duplicated code or when you forget it, it leads to an invalid state.
As for performance, i'm with Knuth here:
> "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." |
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 main shell.
| |-bash(10637)-+-bash(10786)
| | `-cat(10785) |
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&displaylang=en
But, when I tried what they say is the keyboard shortcut to view all open documents (**CTRL + ALT + DOWN ARROW**) I got a completely unexpected result on my XP machine - my entire screen display was flipped upside down!
Was this a prank by someone at Microsoft? I can't imagine what practical value this flipping of the screen would have.
Does anyone know what the *correct* keyboard shortcut is to view all open documents in VS 2008?
Oh and if you try the above shortcut and it flips your display the way it did mine, do a **CTRL + ALT + UP ARROW** to switch it back. |
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. During the build process, I take these templates and replace token placeholders with actual values depending on what configuration I am making the build.
- docs - Any application documentation gets placed in here.
- sql - I break my sql scripts into two directories. One for the initial database setup for when you are starting fresh and another place for my update scripts which get ran based on the version number of the database.
- src - The application source files. In here I break source files based on application and tests.
- thirdparty - This is where I put my third party libraries that I reference inside of my application and not available in the GAC. I split these up based on lib and tools. The lib directory holds the libraries that need to be included with the actual application. The tools directory holds the libraries that my application references, but are only used for running unit tests and compiling the application.
My solution file gets placed right under the trunk directory along with my build files. |
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 strict semantics (major.minor.build - major changes means backwards incompatible, minor changes mean backwards compatible and build number changes mean backwards and forwards compatible). Our ultimate software product is an assembly that pulls in dozens of individual modules, again as Maven dependencies.
We branch modules/assemblies when we need to make a bug fix or enhancement for a released version and we can not deliver the HEAD version. Having tagged all versions makes this easy to do but branches still incur a significant administrative overhead (specifically keeping branches in sync with certain HEAD changesets) that are partly caused by our tools, Subversion is sub-optimal for managing branches.
We find that a fairly flat and above all **predictable** tree structure in the repository is crucial. It has allowed us to build release tools that take away a lot of the pain and danger from a manual release process (updated release notes, project compiles, unit tests run through, tag is made, no SNAPSHOT dependencies, etc). Avoid putting too much categorization or other logic in your tree structure.
We roughly do something like the following:
svnrepo/
trunk/
modules/
m1/ --> will result in jar file
m2/
...
assemblies/
a1/
...
tags/
modules/
m1/
1.0.0/
1.0.1/
1.1.0/
m2/
...
assemblies/
a1/
iteration-55/
...
branches/
m1/
1.0/
...
For external dependencies, I can not overemphasize something like Maven: manage your dependencies as references to versioned, uniquely identified binary artifacts in a repository.
For intenal module/project structure: stick to a standard. Uniformity is key. Again, Maven can help here since it dictates a structure. Many structures are fine, as long as you stick to them. |
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.
[1]: http://msdn.microsoft.com/en-us/library/ms165716.aspx
[2]: http://dev.mysql.com/downloads/connector/net/5.2.html |
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 of having to go out to a third party. It would also require me to setup a bittorrent tracker which wouldn't be as easy as it sounds for this application because different users will have different access to different files. |
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:
function toggleShowPassword() {
var button = $get('PASSWORD_TEXTBOX_ID');
var password;
if (button)
{
password = button.value;
alert(password);
button.value = password;
}
}
The problem is that every time the user clicks the button, the password is cleared in both firefox and IE. I want them to be able to see their password in clear text to verify without having to retype their password.
My questions are:
1) why does the password field keep getting reset with each button click
2) how can I make it so the password field is NOT cleared once the user has seen his/her password in clear text? |
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):
yield name, o
except TypeError: pass
>>> import foo
>>> list(foo.find_subclasses(foo, foo.foo))
[('bar', <class 'foo.bar'>), ('baz', <class 'foo.baz'>), ('foo', <class 'foo.foo'>)]
>>> list(foo.find_subclasses(foo, object))
[('bar', <class 'foo.bar'>), ('baz', <class 'foo.baz'>), ('foo', <class 'foo.foo'>), ('grar', <class 'foo.grar'>)]
>>> list(foo.find_subclasses(foo, Exception))
[('grar', <class 'foo.grar'>)] |
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, string newExtension)
{
string[] dotSplit = fileName.Split('.');
return String.Join(".", dotSplit.Take(dotSplit.Length - 1).ToArray()) + "." + newExtension;
}
(I'm aware of the fact that this won't work if the original file name doesn't have a dot.) |
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 *before* they write the code to be tested. This forces you to think about what you want the code to *do*, and then gives you a definite guideline on when you have acheived that. |
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 generally the case, but not strictly required that (compare(x, y)==0) == (x.equals(y)). Generally speaking, any comparator that violates this condition should clearly indicate this fact. The recommended language is "Note: this comparator imposes orderings that are inconsistent with equals."
[1]: http://stackoverflow.com/questions/16557/overiding-the-equals-method-vs-creating-a-new-method#16591
[2]: http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1219178565&sr=8-1
[3]: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Comparator.html |
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 such a tool exist? |
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 |