instruction
stringlengths
0
30k
|sql|database|evaluation|
We're living in a golden age of databases, with numerous high quality commercial and free databases. This is great, but the downside is there's not a simple obvious choice for someone who needs a database for his next project. - What are the constraints/criteria you use for selecting a database? - How well do the various databases you've used meet those constraints/criteria? - What special features do the databases have? - Which databases do you feel comfortable recommending to others? etc...
We're living in a golden age of databases, with numerous high quality commercial and free databases. This is great, but the downside is there's not a simple obvious choice for someone who needs a database for his next project. - What are the constraints/criteria you use for selecting a database? - How well do the various databases you've used meet those constraints/criteria? - What special features do the databases have? - Which databases do you feel comfortable recommending to others? etc...
|database|sql|evaluation|
|sql|database|evaluation|
We develop on the trunk unless the changes are too major, destabilizing, or we are nearing a major release of one of our products, in which case we create a temporary branch. We also create a permanent branch for every individual product release. I found Microsoft's document on [Branching Guidance][1] quite helpful. Eric Sink's [tutorial on branching][2] is also interesting, and points out that what works for Microsoft may be too heavy for some of the rest of us. It was in our case, we actually use the approach Eric says his team does. [1]: http://www.codeplex.com/BranchingGuidance/Wiki/View.aspx?title=Guidance%20for%20Structuring%20Team%20Projects [2]: http://www.ericsink.com/scm/scm_branches.html
I've been trying to find the original game I was thinking of - I think it was called 'bots or something like that, and ran on my Mac back in around system 6 days. I'll have to do some digging next time I'm back at my parents place. Thinking more about it over the last day or so, I suppose it's really not all that different to writing brains for bolo ([http://www.lgm.com/bolo/][1]) or bots for Quake and those sort of games. [1]: http://www.lgm.com/bolo/
It looks like the Compressed Folder shell extension ignores directories (but not files) whose names begin with a dot, unless explicitly given as a parameter (i.e. selected for the Send To command). It's hard to find out what else it excludes, as I can't even find out *what* the "compressed folder" sendto item is doing in the first place, without referring to 3rd party documentation. Edit: OK, the "Send to compressed folder" sendto shortcut has an extension of .ZFSendToTarget, which is handled by zipfldr.dll, which is doing all the work. @[Kibbee](#30180): Mine does include hidden folders while zipping, though I do have "show hidden files" enabled.
The way I check in Windows if a file has been completely uploaded by ftp is to try to rename it. If renaming fails, the file isn't complete. Not very elegant, I admit, but it works.
The words you want to google for are [JavaScript Worker Threads][1] Apart from from [Gears][2] there's nothing available right now, but there's plenty of talk about how to implement this so I guess watch this question as the answer will no doubt change in future. Here's the relevant documentation for Gears: [WorkerPool API][3] WHATWG has a Draft Recommendation for worker threads: [Web Workers][4] And there's also Mozilla’s [DOM Worker Threads][5] [1]: http://www.google.com/search?q=JavaScript+worker+threads [2]: http://gears.google.com/ [3]: http://code.google.com/apis/gears/api_workerpool.html [4]: http://www.whatwg.org/specs/web-workers/current-work/ [5]: https://wiki.mozilla.org/DOMWorkerThreads
There is no true multi-threading in Javascript, but you can get asynchronous behavior using setTimeout() and asynchronous AJAX requests. What exactly are you trying to accomplish?
Send to zipped Folder does not traverse into folders without names before dot (like ".svn"). If you had other folders that begin with dots, those would not be included either. Files without names are not excluded. Hidden attribute does not come into play. Might be a bug, might be by design. Remember that Windows explorer does not allow creating folders beginning with dot, even though the underlying system can handle them.
AFAIK Visual Studio Express does not come with 64bit support.
I'm a big believer in Use Cases, detailing the system behaviour in response to user actions. Collectively these can form a loose set of requirements, and in a SCRUM environment can help you prioritise the Use Cases which will form that particular sprint's implemented features. For example, after talking to your functional team you identify 15 separate Use Cases. You prioritise the Use Cases, and decided to plan for 5 sprints. And the end of each sprint you go through and demo the product fulfilling the Use Cases implemented during the sprint, noting the feedback and amending the Use Cases.
There is only one point where q4e is actually better: dependency viewer. You could see the dependency tree, manage your dependencies visually and even see them in a graph. But, m2eclipse works in a better way, specially because you can create you own build commands (in the run menu). q4e comes with some predefined commands and I can't find where to define a new one. In other words, m2eclipse is more friendly to the maven way. Kind Regards
c# straight forward answer // Main.cs created with MonoDevelop // User: jboker at 09:28�09/06/2008 // using System; namespace q47407 { class MainClass { public static void Main(string[] args) { string s = Console.ReadLine(); string[] r = s.Split(' '); for(int i = r.Length-1 ; i >= 0; i--) Console.Write(r[i] + " "); Console.WriteLine(); } } }
using System; namespace q47407 { class MainClass { public static void Main(string[] args) { string s = Console.ReadLine(); string[] r = s.Split(' '); for(int i = r.Length-1 ; i >= 0; i--) Console.Write(r[i] + " "); Console.WriteLine(); } } } edit: i guess i should read the whole question... carry on.
Tomcat vs Weblogic JNDI Lookup
|java|tomcat|jakarta-ee|jndi|weblogic|
The Weblogic servers we are using have been configured to allow JNDI datasource names like "appds". For development (localhost), we might be running Tomcat and when declared in the <context> section of server.xml, Tomcat will hang JNDI datasources on "java:comp/env/jdbc/*" in the JNDI tree. **Problem:** in Weblogic, the JNDI lookup is "appds" whilst in Tomcat, it seems that that I must provide the formal "java:comp/env/jdbc/appds". I'm afraid the Tomcat version is an implicit standard but unfortunately, I can't change Weblogic's config ... so that means we end up with two different spring config files (we're using spring 2.5) to facilitate the different environments. Is there an elegant way to address this. Can I look JNDI names up directly in Tomcat? Can Spring take a name and look in both places? Google searches or suggestions would be great.
I don't particularly care for the exact implementation [**@Jon**][1] suggests, but the idea behind it is sound and I would concur that emitting these would be a good thing to do. A slightly better implementation, though this is all subjective to some degree, would be to create a server-side model (read: C# class(es)) that represents this dictionary (or simply use an instance of Dictionary<string, string>) and serialize that to JavaScript literal object notation. That way you are not dealing with the string hacking you see in Jon's example (if that bothers you). [1]: http://stackoverflow.com/questions/46489/referencing-embedded-resources-from-other-resources-in-c#47242
What are the advantages of installing programs in AppData like Google Chrome?
|windows-installer|
I've learned never to use `include` in PHP except inside the core libraries that I use and one central `include` of these libraries (+ config) in the application. Everything else is handled by a global `__autoload` handler that can be configured to recognize the different classes needed. This can be done easily using appropriate naming conventions for the classes. This is not only flexible but also quite efficient and keeps the architecture clean.
We use something similar to bcwoord to keep our database schema's synchronized across 5 different installations (production, staging and a few development installations), and backed up in version control, and it works pretty well. I'll elaborate a bit: ---------- To synchronize the database structure, we have a single script, update.php, and a number of files numbered 1.sql, 2.sql, 3.sql, etc. The script uses one extra table to store the current version number of the database. The N.sql files are crafted by hand, to go from version (N-1) to version N of the database. They can be used to add tables, add columns, migrate data from an old to a new column format then drop the column, insert "master" data rows such as user types, etc. Basically, it can do anything, and with proper data migration scripts you'll never lose data. The update script works like this: > - Connect to the database. - Make a backup of the current database (because stuff _will_ go wrong) [mysqldump]. - Create bookkeeping table (called _meta) if it doesn't exist. - Read current VERSION from _meta table. Assume 0 if not found. - For all .sql files numbered higher than VERSION, execute them in order - If one of the files produced an error: roll back to the backup - Otherwise, update the version in the bookkeeping table to the highest .sql file executed. Everything goes into source control, and every installation has a script to update to the latest version with a single script execution (calling update.php with the proper database password etc.). We SVN update staging and production environments via a script that automatically calls the database update script, so a code update comes with the necessary database updates. ---------- It took only a few hours to set up this system, it's conceptually simple and everyone gets the version numbering scheme, and it has been invaluable in having the ability to move forward and evolving the database design, without having to *Beware when pasting queries from phpMyAdmin though!* Those generated queries usually include the database name, which you definitely don't want since it will break your scripts! Something like CREATE TABLE `mydb`.`newtable`(...) will fail if the database on the system is not called mydb. We created a pre-comment SVN hook that will disallow .sql files containing the `mydb` string, which is a sure sign that someone copy/pasted from phpMyAdmin without proper checking.
We use something similar to bcwoord to keep our database schema's synchronized across 5 different installations (production, staging and a few development installations), and backed up in version control, and it works pretty well. I'll elaborate a bit: ---------- To synchronize the database structure, we have a single script, update.php, and a number of files numbered 1.sql, 2.sql, 3.sql, etc. The script uses one extra table to store the current version number of the database. The N.sql files are crafted by hand, to go from version (N-1) to version N of the database. They can be used to add tables, add columns, migrate data from an old to a new column format then drop the column, insert "master" data rows such as user types, etc. Basically, it can do anything, and with proper data migration scripts you'll never lose data. The update script works like this: > - Connect to the database. - Make a backup of the current database (because stuff _will_ go wrong) [mysqldump]. - Create bookkeeping table (called _meta) if it doesn't exist. - Read current VERSION from _meta table. Assume 0 if not found. - For all .sql files numbered higher than VERSION, execute them in order - If one of the files produced an error: roll back to the backup - Otherwise, update the version in the bookkeeping table to the highest .sql file executed. Everything goes into source control, and every installation has a script to update to the latest version with a single script execution (calling update.php with the proper database password etc.). We SVN update staging and production environments via a script that automatically calls the database update script, so a code update comes with the necessary database updates. We can also use the same script to recreate the entire database from scratch; we just drop and recreate the database, then run the script which will completely repopulate the datase. We can also use the script to populate an empty database for automated testing. ---------- It took only a few hours to set up this system, it's conceptually simple and everyone gets the version numbering scheme, and it has been invaluable in having the ability to move forward and evolving the database design, without having to communicate or manually execute the modifications on all databases. *Beware when pasting queries from phpMyAdmin though!* Those generated queries usually include the database name, which you definitely don't want since it will break your scripts! Something like CREATE TABLE `mydb`.`newtable`(...) will fail if the database on the system is not called mydb. We created a pre-comment SVN hook that will disallow .sql files containing the `mydb` string, which is a sure sign that someone copy/pasted from phpMyAdmin without proper checking.
Attempting to manage maintenance of current production code in line with new development is problematic at best. In order to mitigate those problems code should branch into a maintenance line once testing efforts have completed and the code is ready for delivery. Additionally, the mainline should branch to assist in release stabilization, to contain experimental development efforts, or to house any development efforts whose lifecycle extends across multiple releases. A non-maintenance branch should be created only when there is the likelihood (or certainty) of collisions among the code that would be difficult to manage any other way. If the branch does not solve a logistical problem, it will create one. Normal release development occurs in the mainline. Developers check into and out of the mainline for normal release work. Development work for patches to current Production code should be in the branch for that release and then merged with the mainline once the patch has passed testing and is deployed. Work in non-maintenance branches should be coordinated on a case-by-case basis.
For me, it depends on the software I'm using. Under CVS, I would just work in "trunk" and never tag/branch, because it was really painful to do otherwise. In SVN, I would do my "bleeding edge" stuff in trunk, but when it was time to do a server push get tagged appropriately. I recently switching to git. Now I find that I never work in trunk. Instead I use a named "new-featurename" sandbox branch and then merge into a fixed "current-production" branch. Now that I think about it, I really should be making "release-VERSIONNUMBER" branches before merging back into "current-production" so I can go back to older stable versions...
These are all weighty topics, but here is my recommendation for updating. You did not specify your platform, but for NANT build environments I use [Tarantino][1]. For every database update you are ready to commit, you make a change script (using RedGate or another tool). When you build to production, Tarantino checks if the script has been run on the database (it adds a table to your database to keep track). If not, the script is run. It takes all the manual work (read: human error) out of managing database versions. [1]: http://jeffreypalermo.com/blog/the-tarantino-project-automated-database-migrations-and-more/
You might also look into setting up your own site as a delegate for another OpenID provider. That way, you can use your own custom URL, but not worry about security and maintenance as mentioned already. However, it's not very difficult, so it may not meet your criteria :) As an example, you would add this snippet of HTML to the page at your desired OpenID URL if you are [using ClaimID](http://claimid.com/openid) as the OpenID provider: <link rel="openid.server" href="http://openid.claimid.com/server" /> <link rel="openid.delegate" href="http://openid.claimid.com/USERNAME" /> So when OpenID clients access your URL, they "redirect" themselves to the actual provider.
It depends on your situations. We use Perforce and have typically have several lines of development. The trunk is considered "gold" and all development happens on branches that get merged back to the mainline when they are stable enough to integrate. This allows rejection of features that don't make the cut and can provide solid incremental capability over time that independent projects/features can pick up. There is integration cost to the merging and catching up to new features rolled into the trunk, but you're going to suffer this pain anyway. Having everyone develop on the trunk together can lead to a wild west situation, while branching allows you to scale and choose the points at which you'd like to take the bitter integration pills. We're currently scaled to over a hundred developers on a dozen projects, each with multiple releases using the same core components, and it works pretty well. The beauty of this is that you can do this recursively: a big feature branch can be its own trunk with other branches coming off if it. Also, final releases get a new branch to give you a place to do stable maintenance.
If he's interested, aren't the minor details the good parts? Using python, you've already cut the GUI off of it so that confusion is gone. Why not pick a project, a game or something, and implement it. The classic hi-lo number guessing game can be simply implemented from the command line in 20-30 lines of code (depending on language of course) and gives you variables, conditions, loops, and user input.
First of all, start out like everyone else does: with a [Hello World][1] program. It's simple, and it gives them a basic feel for the layout of a program. Try and remember back to when you were first programming, and how difficult some of the concepts were - start simple. After Hello World, move on to creating some basic variables, arithmetic, then onto boolean logic and if/else statements. If you've got one of your old programming textbooks, check out some of the early examples and have him run through those. Just don't try to introduce too much all at once, or it will be overwhelming and confusing. [1]: http://en.wikipedia.org/wiki/Hello_world
I would actually argue to pick a simpler language with fewer instructions. I personally learned on BASIC at home, as [did Jeff][1]. This way, you don't have to delve into more complicated issues like object oriented programming, or even procedures if you don't want to. Once he can handle simple control flow, then move on to something a little more complicated, but only simple features. Maybe start with very simple programs that just add 2 numbers, and then grow to something that might require a branch, then maybe reading input and responding to it, then some kind of loop, and start combining them all together. Just start little and work your way up. Don't do any big projects until he can grasp the fundamentals (otherwise it may very well be too daunting and he could give up midway). Once he's mastered BASIC or whatever you choose, move on to something more complicated. Just my $0.02 [1]: http://www.codinghorror.com/blog/archives/001104.html
Something you should be very mindful of while teaching your brother to program is for him not to rely too heavily on you. Often when I find myself helping others they will begin to think of me as answer book to all of their questions and instead of experimenting to find an answer they simply ask me. Often the best teacher is experimentation and every time your brother has a question like "What will happen if I add 2 to a string?" you should tell him to try it out and see for himself. Also I have noticed that when I cannot get a concept through to someone, it helps to see some sample code where we can look at each segment individually and explain it piece by piece. As a side note people new to programming often have trouble with the idea of object oriented programming, they will say they understand it when you teach it to them but will not get a clear concept of it until actually implementing it.
I agree with [NilObject](http://stackoverflow.com/questions/3058/what-is-inversion-of-control#3082), but I'd like to add to this: > if you find yourself copying an entire method and only changing a small piece of the code, you can consider tackling it with inversion of control If you find yourself copying and pasting code around, you're almost always doing *something* wrong. Codified as the design principle [Once and Only Once](http://c2.com/xp/OnceAndOnlyOnce.html).
I just noticed that Chromium was installed in AppData in both Vista and XP. If Google does that and if other applications does this, than is that becuase there is some form of protection? Should we write installers that does the same thing as Google?
|windows-installer|windows|
|windows|google-chrome|windows-installer|
Reconnecting JMS listener to JBossMQ
|java|jboss|jms|jbossmq|
We have a Java listener that reads text messages off of a queue in JBossMQ. If we have to reboot JBoss, the listener will not reconnect and start reading messages again. We just get messages in the listener's log file every 2 minutes saying it can't connect. Is there something we're not setting in our code or in JBossMQ? I'm new to JMS so any help will be greatly appreciated. Thanks.
The Chrome installer really ought to allow global installation (with elevation) in addition to per-user. I don't want to have to maintain an installation for every user; I want to be able to centrally manage upgrades and so on. Chrome doesn't allow that. That said, the option to install per-user is quite nice, as it means no permissions issues.
I think your best bet is to use Rewritable media for this. You can create your application easily, like HTML site or something like that, and after the last link or last page, however you decide to do you could execute a script with some command-line burner that would erase the rewritable media, or even write an ISO that you keep in CD with a text file or a flash that explains tath the CD is lost forever. Give a look at some Command Line Burners. Linux have several, that isn't worth to mention here, for windows you can use [Cheetah commandLine Burner][1] If you wish to do a CD without depending on the installed OS you should give a look at LIVE CDs. FreeDOS is a choice for "DOS Compatible applications" or my suggestioon you use a [Linux live CD][2]. Good luck on the race :D. Great idea BTW! [1]: http://www.google.com.br/search?rlz=1C1GGLS_pt-BRBR291&sourceid=chrome&ie=UTF-8&q=Cheetah+CommandLine+Burner [2]: http://www.frozentech.com/content/livecd.php
I think your best bet is to use Rewritable media for this. You can create your application easily, like HTML site or something like that, and after the last link or last page, however you decide to do you could execute a script with some command-line burner that would erase the rewritable media, or even write an ISO that you keep in CD with a text file or a flash that explains tath the CD is lost forever. Give a look at some Command Line Burners. Linux have several, that isn't worth to mention here, for windows you can use [Cheetah commandLine Burner][1] among several others. If you wish to do a CD without depending on the installed OS you should give a look at LIVE CDs. FreeDOS is a choice for "DOS Compatible applications" or my suggestioon you use a [Linux live CD][2]. Also you will have several options for small HTTP servers, like [lighthttpd][3] and even browsers in several flavors from text interfaces to the graphical ones. Good luck on the race :D. Great idea BTW! [1]: http://www.google.com.br/search?rlz=1C1GGLS_pt-BRBR291&sourceid=chrome&ie=UTF-8&q=Cheetah+CommandLine+Burner [2]: http://www.frozentech.com/content/livecd.php [3]: www.lighttpd.net/
I think trying to use XmlHttpRequest will be a huge headache, unless its the type of headache you don't mind - to do it properly you're almost reinventing the wheel. Then again, people like to reinvent wheels in their spare time, just to say, "Hey, I did it". Not me... I would get a framework like prototype or Extjs, that has alot of data loading functions built in for XML and JSON, plus you'll get more predictable results, as the frameworks have event handlers to make sure your XmlHttpRequest succeeded or failed. Plus you get support for all the various browsers.
If you will be deploying on IIS 6 or IIS 7, just use the built-in IIS compression. We're using it on production sites for compressing HTML, CSS, and JavaScript with no errors. It also caches the compressed version on the server, so the compression hit is only taken once.
From the [Sql 2005 February 2007 Feature Pack][1]: > The Microsoft OLE DB Provider for DB2 is a COM component for integrating vital data stored in IBM DB2 databases with new solutions based on Microsoft SQL Server 2005 Enterprise Edition and Developer Edition. SQL Server developers and administrators can use the provider with Integration Services, Analysis Services, Replication, Reporting Services, and Distributed Query Processor. Run the self-extracting download package to create an installation folder. The single setup program will install the provider and tools on x86, x64, and IA64 computers. [1]: http://www.microsoft.com/downloads/details.aspx?FamilyID=50b97994-8453-4998-8226-fa42ec403d17&DisplayLang=en
You can use the extended syntax: preg_match("/ test /x", $foo, $bar);
Whether you do it in classes or in a more procedural style, you simply need to check to ensure that: 1. There is a session; 2. That the session is valid; and, 3. That the user in possession of the session has proper privileges. You can encapsulate all three steps into one function (or a static method in a Session class might work). Try this: class Session { const GUEST = 0; const SUBSCRIBER = 1; const ADMINISTRATOR = 2; public static function Type() { session_start(); // Depending on how you use sessions on // your site, you might just check for the // existence of PHPSESSID. If you track // every visitor with sessions, however, you // might want to assign some separate unique // number (that you can track in a DB) to // authenticated sessions if(!$_SESSION['uniqid']) { return Session::GUEST; } else { // For the best security, don't store the // user's access permissions in the $_SESSION, // but rather check against the DB. This will // ensure that recently deleted or downgraded // administrators will not be able to make use // of a previous session. return THE_ACCESS_LEVEL_ACCORDING_TO_THE_DB } } } // In your files that need to check for authentication (you // could also do this in a controller if you're going MVC if(!(Session::Type() == Session::ADMINISTRATOR)) { // Redirect them to wherever you want them to go instead, // like a log in page or something like that. }
The XPath for this is: > /books/book/authors/author[contains(., > 'Ritchie')] In C# the following code would return "Ritchie, Dennis M.": xmlDoc.SelectSingleNode("/books/book/authors/author[contains(., 'Ritchie')]").InnerText;
The XPath for this is: /books/book/authors/author[contains(., 'Ritchie')] In C# the following code would return "Ritchie, Dennis M.": xmlDoc.SelectSingleNode("/books/book/authors/author[contains(., 'Ritchie')]").InnerText;
TFS Lifecycle Management for Build Environment
|tfs|msbuild|
How would you manage the lifecycle and automated build process when some of the projects (C# .csproj projects) are part of the actual build system? Example: A.csproj is a project that uses MSBuild tasks that are implemented in BuildEnv.csproj. Both projects are part of the same product (meaning, BuildEnv.csproj frequently changes as the product is being developed and not a 3rd party that is rarely updated)
I don't think that the well-known spoofability of MAC addresses is an issue in this case. I think tweakt is just wanting to use them for initial identification. The device can read its own MAC address, and the installer can (as long as it's printed on a label) read the same number and know, "OK - this is the box that I put at location A." tweakt - would these boxes be calling into the manufacturer's server, or the server of the company/person using them (or are those the same thing in this case)?
G'day, A good static analysis tool for security is [FlawFinder][1] written by David Wheeler. It does a good job looking for various security exploits, However, it doesn't replace having a knowledgable someone read through your code. As David says on his web page, "A fool with a tool is still a fool!" HTH. cheers, Rob [1]: http://www.dwheeler.com/flawfinder/
Please tell me what are you doing to /boot that you need more than 64MB on it? Unless you never intend to clean it, anything more is a waste of space. Kernel image + initrd + System.map won't take more than 10MB (probably less - mine weight 5MB) and you really don't need to keep more than two spares. And with the current prices of RAM - if you are needing swap, you'll be much better off buying more memory. Reserve 1GB for swap and have something monitoring it's usage (no swap at all is bad idea because the machine might lock up when it runs out of free memory).
As everyone else has said, it most certainly would not be faster to add an index than it would be to do a full scan of that column. However, I would suggest tracking the query pattern and find out which column(s) are searched for the most, and add indexes at least for them. You may find out that 3-4 indexes speeds up 90% of your queries.
I don't think there's anything magic about what you're doing here - couldn't what you're doing be described as: "At production we burn a unique number into each of our devices which is both readable by the end user (it's on the label) and accessible to the internal processor. Our users have to enter this number into our website along with their credit-card details, and the box subsequently contacts to the website for permission to operate" "*Coincidentally* we also use this number as the MAC address for network packets as we have to uniquely assign that during production anyway, so it saved us duplicating this bit of work" I would say the two obvious hazards are: 1. People hack around with your device and change this address to one which someone else has already activated. Whether this is likely to happen depends on some relationship between how hard it is and how expensive whatever they get to steal is. You might want to think about how easily they can take a firmware upgrade file and get the code out of it. 2. Someone uses a combination of firewall/router rules and a bit of custom software to generate a server which replicates the operation of *your* 'auth server' and grants permission to the device to proceed. You could make this harder with some combination of hashing/PKE as part of the protocol. As ever, some tedious, expensive one-off hack is largely irrelevant, what you don't want is a class-break which can be distributed over the internet to every thieving dweep.
If you are gonna be working through a release cycle, big feature, you get marooned to a branch. Otherwise we work in trunk, and branch for every production release at the moment we build. Previous production builds are moved at that time to old_production_<currentbuildlabel> and current prod release is always just production. All our build server knows about production is how to deploy the production branch, and we kick that build off with a force trigger.
You may get both added and removed lines with git log, like: git log --shortstat --reverse --pretty=oneline From this, you can write a similar script to the one you did using this info. In python: #!/usr/bin/python """ Display the per-commit size of the current git branch. """ import subprocess import re import sys def main(argv): git = subprocess.Popen(["git", "log", "--shortstat", "--reverse", "--pretty=oneline"], stdout=subprocess.PIPE) out, err = git.communicate() total_files, total_insertions, total_deletions = 0, 0, 0 for line in out.split('\n'): if not line: continue if line[0] != ' ': # This is a description line hash, desc = line.split(" ", 1) else: # This is a stat line data = re.findall( ' (\d+) files changed, (\d+) insertions\(\+\), (\d+) deletions\(-\)', line) files, insertions, deletions = ( int(x) for x in data[0] ) total_files += files total_insertions += insertions total_deletions += deletions print "%s: %d files, %d lines" % (hash, total_files, total_insertions - total_deletions) if __name__ == '__main__': sys.exit(main(sys.argv))
There is no way (that I know of) to do what you ask with typical WinForms. If you're doing custom painting/drawing, you can zoom that by using a zoom transform, but so far as I know there is no "Zoom" property for the form in the entire world of .NET and native Windows/C++ APIs combined. You could probably rig something yourself such that you scale controls by a constant factor. And you can probably find 3rd-party controls/surfaces which support this. And who knows what is possible with WPF. But in a typical WinForms world, no.
I'm not familiar with the specific services listed, but the field of natural language processing has developed a number of techniques that enable this sort of information extraction from general text. As Sean stated, once you have candidate terms, it's not to difficult to search for those terms with some of the other entities in context and then use the results of that search to determine how confident you are that the term extracted is an actual entity of interest. [OpenNLP](http://opennlp.sourceforge.net/) is a great project if you'd like to play around with natural language processing. The capabilities you've named would probably be best accomplished with Named Entity Recognizers (NER) (algorithms that locate proper nouns, generally, and sometimes dates as well) and/or Word Sense Disambiguation (WSD) (eg: the word 'bank' has different meanings depending on it's context, and that can be very important when extracting information from text. Given the sentences: "the plane banked left", "the snow bank was high", and "they robbed the bank" you can see how dissambiguation can play an important part in language understanding) Techniques generally build on each other, and NER is one of the more complex tasks, so to do NER successfully, you will generally need accurate tokenizers (natural language tokenizers, mind you -- statistical approaches tend to fare the best), string stemmers (algorithms that conflate similar words to common roots: so words like informant and informer are treated equally), sentence detection ('Mr. Jones was tall.' is only one sentence, so you can't just check for punctuation), part-of-speech taggers (POS taggers), and WSD. There is a python port of (parts of) OpenNLP called NLTK (http://nltk.sourceforge.net) but I don't have much experience with it yet. Most of my work has been with the Java and C# ports, which work well. All of these algorithms are language-specific, of course, and they can take significant time to run (although, it is generally faster than reading the material you are processing). Since the state-of-the-art is largely based on statistical techniques, there is also a considerable error rate to take into account. Furthermore, because the error rate impacts all the stages, and something like NER requires numerous stages of processing, (tokenize -> sentence detect -> POS tag -> WSD -> NER) the error rates compound.
I think your best bet is to use Rewritable media for this. You can create your application easily, like HTML site or something like that, and after the last link or last page, however you decide to do you could execute a script with some command-line burner that would erase the rewritable media, or even write an ISO that you keep in CD with a text file or a flash that explains that the CD is lost forever. Give a look at some Command Line Burners. Linux have several, that isn't worth to mention here, for windows you can use [Cheetah CommandLine Burner][1] among several others. If you wish to do a CD without depending on the installed OS you should give a look at LIVE CDs. FreeDOS is a choice for "DOS Compatible applications" or my suggestioon you use a [Linux live CD][2]. Also you will have several options for small HTTP servers, like [lighthttpd][3] and even browsers in several flavors from text interfaces to the graphical ones. Good luck on the race :D. Great idea BTW! [1]: http://www.google.com.br/search?rlz=1C1GGLS_pt-BRBR291&sourceid=chrome&ie=UTF-8&q=Cheetah+CommandLine+Burner [2]: http://www.frozentech.com/content/livecd.php [3]: www.lighttpd.net/
The only tool I found is [Kaxaml][1], which does nice formatting ("XAML Scrubber" entry in the left menu), but being a stand-alone editor doesn't quite make the cut. [1]: http://www.kaxaml.com/
You can't pass parameters to user scripts — instead, user scripts operate on the context you're working in (e.g. the selected file, the selected text, etc.). You should use the context to determine what the user really wants.
How do I become "test infected" with TDD?
|unit-testing|testing|tdd|
I keep reading about people who are "test infected", meaning that they don't just "get" TDD but also can't live without it. They've "had the makeover" as it were. The question is, how do I get like that?
In C foo() and foo(void) are different functions. foo() accepts an infinite number of arguments, while foo(void) accepts 0 arguments. In C++ they mean the same thing. I suggest that you use void consistently when you mean no arguments. If you have a variable a, "extern int a;" is a way to tell the compiler that 'a' is a symbol that might be present in a different translation unit (c compiler speak for source file), don't resolve it until link time. On the other hand, symbols which are function names are anyway resolved at link time. The meaning of a storage class specifier on a function (extern, static) only affects its visibility and extern is the default, so extern is actually unnecessary. I suggest removing the extern, it is extraneous and is usually omitted.
How about some simple testing? Used the code below: long start = System.currentTimeMillis(); String a = "a"; String b = "b"; for (int i = 0; i < 10000000; i++) { //ten million times String c = a.concat(b); } long end = System.currentTimeMillis(); System.out.println(end - start); The "a + b" version runned in 2500ms. The a.concat(b) runned in 1200ms. Tested several times. The concat version finished execution in an avarage half time.
where year(date1) = year(date2) and month(date1) = month(date2) and day(date1) = day(date2)
* You should add delimiters: the first character of the regex will be used to indicate the end of the pattern. * You should add the 'x' flag. This has the same result as putting (?x) at the beginning, but it is more readable imho.
Is it only CSS files that get corrupted? Do JS files (or any other static text files) come through ok? Also can you duplicate the behavior if you browse directly to the CSS file? I've only enabled compression on Windows 2003 server's IIS using this approach: 1. IIS → Web Sites → Properties → Service tab, check both boxes 2. IIS → Web Service Extensions → Right click, Add New<pre> Name Http Compression Required Files %systemroot%\system32\inetsrv\gzip.dll </pre> 3. IIS → Right click top node, Internet Information Services, check *Enable Direct Metabase Edit* 4. Backup and Edit `%systemroot%\system32\inetsrv\MetaBase.xml` 1. Find `Location ="/LM/W3SVC/Filters/Compression/gzip"` * Add `png`, `css`, `js` and any other static file extensions to `HcFileExtensions` * Add `aspx` and any other executable extensions to `HcScriptFileExtensions` * Save 5. Restart IIS (run `iisreset`) If you have a Windows 2003/2008 server to play with you could try that approach.
As Cheekysoft suggests, I would tend to move all major exceptions into an ExceptionHandler and let those exceptions bubble up. The ExceptionHandler would render the appropriate view for the type of exception. Any validation exceptions however should be handled in the view but typically this logic is common to many parts of your application. So I like to have a helper like this public static class Try { public static List<string> This( Action action ) { var errors = new List<string>(); try { action(); } catch ( SpecificException e ) { errors.Add( "Something went 'orribly wrong" ); } catch ( ... ) // ... return errors; } } Then when calling your service just do the following var errors = Try.This( () => { // call your service here tasks.CreateMember( ... ); } ); Then in errors is empty, you're good to go. You can take this further and extend it with custome exception handlers which handle _uncommon_ exceptions.
These are not really opposite choices. You will have to include the checking code anyway. I read your question as procedural programming vs. OO programming. Writing a few lines of code, or a function, and including it in your page header was how things were done in PHP3 or PHP4. It's simple, it works (that's how we did it in [osCommerce][1], for example, an eCommerce PHP application). But it's not easy to maintain and modify, as many developers can confirm. In PHP5 you'd write a user object which will carry its own data and methods for authentication. Your code will be clearer and easier to maintain as everything having to do with users and authentication will be concentrated in a single place. [1]: http://www.oscommerce.com/
My main Mac is a MacBook, juiced with 4GB of RAM, and I find that perfectly good for development (in either Windows or OSX). I could have got an iMac for a bit more money, but I already had a 20" LCD monitor laying around, and I wanted the portability. The MacBooks are as powerful as the iMacs (excluding the graphics card, which may or may not be important to you; it wasn't to me), and are perfectly suitable for development.
Windows Home Server versus Vista Backup and Restore Center
|windows-vista|backup|home-server|
I've been using Window Home Server for my backups here at home for most of a year now, and I'm really pleased with it. It's far better than the software I was using previously (Acronis). I'm thinking about a backup strategy for my work machine and I'd like to know how WHS compares with Vista's built-in backup and restore features. The plan is to do a full backup to a local external hard drive and backup the documents folder to a network drive on the server. Anyone have experience using the Vista backup feature like this?
No, but a wrapper is rather trivial: public class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue> { IDictionary<TKey, TValue> _dict; public ReadOnlyDictionary(IDictionary<TKey, TValue> backingDict) { _dict = backingDict; } public void Add(TKey key, TValue value) { throw new InvalidOperationException(); } public bool ContainsKey(TKey key) { return _dict.ContainsKey(key); } public ICollection<TKey> Keys { get { return _dict.Keys; } } public bool Remove(TKey key) { throw new InvalidOperationException(); } public bool TryGetValue(TKey key, out TValue value) { return _dict.TryGetValue(key, out value); } public ICollection<TValue> Values { get { return _dict.Values; } } public TValue this[TKey key] { get { return _dict[key]; } set { throw new InvalidOperationException(); } } public void Add(KeyValuePair<TKey, TValue> item) { throw InvalidOperationException(); } public void Clear() { throw InvalidOperationException(); } public bool Contains(KeyValuePair<TKey, TValue> item) { return _dict.ContainsKey(item); } public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) { return _dict.CopyTo(array, arrayIndex); } public int Count { get { return _dict.Count; } } public bool IsReadOnly { get { return true; } } public bool Remove(KeyValuePair<TKey, TValue> item) { throw new InvalidOperationException(); } public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() { return _dict.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return ((System.Collections.IEnumerable)_dict).GetEnumerator(); } }
No, but a wrapper is rather trivial: public class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue> { IDictionary<TKey, TValue> _dict; public ReadOnlyDictionary(IDictionary<TKey, TValue> backingDict) { _dict = backingDict; } public void Add(TKey key, TValue value) { throw new InvalidOperationException(); } public bool ContainsKey(TKey key) { return _dict.ContainsKey(key); } public ICollection<TKey> Keys { get { return _dict.Keys; } } public bool Remove(TKey key) { throw new InvalidOperationException(); } public bool TryGetValue(TKey key, out TValue value) { return _dict.TryGetValue(key, out value); } public ICollection<TValue> Values { get { return _dict.Values; } } public TValue this[TKey key] { get { return _dict[key]; } set { throw new InvalidOperationException(); } } public void Add(KeyValuePair<TKey, TValue> item) { throw InvalidOperationException(); } public void Clear() { throw InvalidOperationException(); } public bool Contains(KeyValuePair<TKey, TValue> item) { return _dict.ContainsKey(item); } public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) { return _dict.CopyTo(array, arrayIndex); } public int Count { get { return _dict.Count; } } public bool IsReadOnly { get { return true; } } public bool Remove(KeyValuePair<TKey, TValue> item) { throw new InvalidOperationException(); } public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() { return _dict.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return ((System.Collections.IEnumerable)_dict).GetEnumerator(); } } Obviously, you can change the this[] setter above if you want to allow modifying values.
As I understand it, random access is in constant time for both Python's dicts and lists, the difference is that you can only do random access of integer indexes with lists. I'm assuming that you need to lookup a node by its label, so you want a dict of dicts. However, on the performance front, loading it into memory may not be a problem, but if you use too much you'll end up swapping to disk, which will kill the performance of even Python's highly efficient dicts. Try to keep memory usage down as much as possible. Also, RAM is amazingly cheap right now; if you do this kind of thing a lot, there's no reason not to have at least 4GB. If you'd like advice on keeping memory usage down, give some more information about the kind of information you're tracking for each node.
Inversion of Control is what you get when you program callbacks, e.g. like a gui program. For example, in an old school menu, you might have: print "enter your name" read name print "enter your address" read address etc... store in database thereby controlling the flow of user interaction. In a GUI program or somesuch, instead we say when the user types in field a, store it in NAME when the user types in field b, store it in ADDRESS when the user clicks the save button, call StoreInDatabase So now control is inverted... instead of the computer accepting user input in a fixed order, the user controls the order in which the data is entered, and when the data is saved in the database. Basically, anything with an event loop, callbacks, or execute triggers falls into this category.
Recursion is a method of solving problems based on the divide and conquer mentality. The basic idea is that you take the original problem and divide it into smaller (more easily solved) instances of itself, solve those smaller instances (usually by using the same algorithm again) and then reassemble them into the final solution. The canonical example is a routine to generate the Factorial of n. The Factorial of n is calculated by multiplying all of the numbers between 1 and n. An iterative solution in C# looks like this: public int Fact(int n) { int fact = 1; for( int i = 2; i <= n; i++) { fact = fact * i; } return fact; } There's nothing surprising about the iterative solution and it should make sense to anyone familiar with C#. The recursive solution is found by recognising that the nth Factorial is n * Fact(n-1). Or to put it another way, if you know what a particular Factorial number is you can calculate the next one. Here is the recursive solution in C#: public int FactRec(int n) { if( n < 2 ) { return 1; } return n * FactRec( n - 1 ); } The first part of this function is known as a **Base Case** (or sometimes Guard Clause) and is what prevents the algorithm from running forever. It just returns the value 1 whenever the function is called with a value of 1 or less. The second part is more interesting and is known as the **Recursive Step**. Here we call the same method with a slightly modified parameter (we decrement it by 1) and then multiply the result with our copy of n. When first encountered this can be kind of confusing so it's instructive to examine how it works when run. Imagine that we call FactRec(5). We enter the routine, are not picked up by the base case and so we end up like this: // In FactRec(5) return 5 * FactRec( 5 - 1 ); // which is return 5 * FactRec(4); If we re-enter the method with the parameter 4 we are again not stopped by the guard clause and so we end up at: // In FactRec(4) return 4 * FactRec(3); If we substitute this return value into the return value above we get // In FactRec(5) return 5 * (4 * FactRec(3)); This should give you a clue as to how the final solution is arrived at so we'll fast track and show each step on the way down: return 5 * (4 * FactRec(3)); return 5 * (4 * (3 * FactRec(2))); return 5 * (4 * (3 * (2 * FactRec(1)))); return 5 * (4 * (3 * (2 * (1)))); That final substitution happens when the base case is triggered. At this point we have a simple algrebraic formula to solve which equates directly to the definition of Factorials in the first place. It's instructive to note that every call into the method results in either a base case being triggered or a call to the same method where the parameters are closer to a base case (often called a recursive call). If this is not the case then the method will run forever.
How about some simple testing? Used the code below: long start = System.currentTimeMillis(); String a = "a"; String b = "b"; for (int i = 0; i < 10000000; i++) { //ten million times String c = a.concat(b); } long end = System.currentTimeMillis(); System.out.println(end - start); The "a + b" version runned in 2500ms. The a.concat(b) runned in 1200ms. Tested several times. The concat version finished execution in an avarage half time. This result surprised me because the concat method always creates a new string (it returns a "new String(result)". It's well know that: > String a = new String("a") // more > than 20 times slower than String a = > "a" Why wasn't the compiler capable of optimize the string creation in "a + b" code, knowing the it always resulted in the same string? It could avoid a new string creation. If you don't believe the statement above, test for your self.
The win32 api has a function called [waveInGetNumDevs][1] for it. [1]: http://msdn.microsoft.com/en-us/library/ms713732(VS.85).aspx
Multiple threads and performance on a single CPU.
|performance|multithreading|
Is here any performance benefit to using multiple threads on a computer with a single CPU that does not having hyperthreading?
C# Console?
|c#|.net|console|
Does anyone know if there is a c# Console app, similar to the Python or Ruby console? I know the whole "Compiled versus Interpreted" difference, but with C#'s reflection power I think it could be done.
|c#|.net|console|interactive|
Does anyone know if there is a c# Console app, similar to the Python or Ruby console? I know the whole "Compiled versus Interpreted" difference, but with C#'s reflection power I think it could be done. **UPDATE** Well, it only took about 200 lines, but I wrote a simple one...It works a lot like osql. You enter commands and then run them with go. ![SharpConsole](http://www.gfilter.net/junk/sharpconsole.jpg) If anyone wants it, let me know.
In terms of speed of computation, No. In fact things will slow down due to the overhead of managing the threads. In terms of responsiveness, yes. You can for example have one thread wait on an IO operation and have another run a GUI at the same time.
The [LVN_ODCACHEHINT][1] notification message will let you know how many items it is going to ask. This could help you in deciding how big your cache should be. [1]: http://msdn.microsoft.com/en-us/library/bb774855(VS.85).aspx
How to start coding the "Dining Philosophers Problem" simulation?
|c#|puzzle|deadlock|homework|