instruction
stringlengths
0
30k
I'm considering switching to a Dvorak-based keyboard layout, but one optimized for programming (mostly) Java and python (e.g. [DDvorak][1], [Programmer Dvorak][2], etc.). What particular keyboard would be best for such an undertaking? I'd consider either natural or straight keyboards. Thanks. [1]: http://www.si...
|keyboard|dvorak|
This is happening because you have a random.py file in the python search path, most likely the current directory. Python is searching for modules using sys.path, which normally includes the current directory before the standard site-packages, which contains the expected random.py. This is expected to be fixed in ...
extern "C" determines how symbols in the generated object file should be named. If a function is declared without extern "C", the symbol name in the object file will use C++ name mangling. Here's an example. Given test.C like so: void foo() { } Compiling and listing symbols in the object file gives: ...
extern "C" determines how symbols in the generated object file should be named. If a function is declared without extern "C", the symbol name in the object file will use C++ name mangling. Here's an example. Given test.C like so: void foo() { } Compiling and listing symbols in the object file gives: ...
This is actually a problem that I have seen come up before a lot in my works and the following bit of code is my answer to the problem. // checkDateEntries - Checks to ensure that the values entered are dates and // are of a valid range. function checkDateRange(start, end) { // Parse the...
Not only did Matt Trout write an article about a REPL, he actually wrote one - [Devel::REPL][1] I've used it a bit and it works fairly well, and it's under active development. BTW, I have no idea why someone modded down the person who mentioned using "perl -e" from the console. This isn't really a REPL, true, but...
What's the recommended best practice for using IEqualityComparer<T>?
|c#|comparison|
Title says it all :)
I'm looking for real world best practice, how other people might have implented solutions with complex domains
For what it's worth, I've been testing for 15 years, and to this day have never seen ROI on tests created in this fashion. Automated testing, is obviously a good thing, but if you are just taking test cases that should be manual test cases and having minimum wage workers "automate" them, you will almost always end up w...
As others have said, there is nothing built in to do that task. Use [iTextSharp][1] with this [example code][2]. [1]: http://itextsharp.sourceforge.net/ [2]: http://www.steedsoft.com/itextsharp/tutorial01/ap01Concat.cs.html
I'd consider REST-style frameworks as well as the other recommendations here- <a href="http://restlet.org">Restlet</a> or <a href="https://jersey.dev.java.net/">Jersey</a> may be good choices for the backend, while you use something like JQuery or GWT on the front end. Both frameworks can easily produce JSON, and the R...
Because some browsers treat the width as the total width of the element including the padding and the margins, and others treat the width as the base width to which the padding and margins are added. As a result your design will look different in different browsers. For more information, see the [W3C page on Box Mo...
I'm not sure why using Guice make's Justin's option not work for you. What exactly is getting injected in? I'm not sure if this would help you at all because it is very similar to what Justin wrote above but if you do it this way, Jetty will do the actually instantiating. Context context = new Context(se...
You can put using statements together before the opening braces like so: using (StreamWriter w1 = File.CreateText("W1")) using (StreamWriter w2 = File.CreateText("W2")) { // code here } http://blogs.msdn.com/ericgu/archive/2004/08/05/209267.aspx
You could use this syntax to condense things down a bit: using (FileStream fs = new FileStream("c:\file.txt", FileMode.Open)) using (BufferedStream bs = new BufferedStream(fs)) using (StreamReader sr = new StreamReader(bs)) { } This is one of those rare occasions where not using { } for al...
[Moose][1], definitely. package Person; use Moose; has age => ( isa => Int, is => 'rw'); has name => ( isa => Str, is => 'rw'); 1; Immediately, you have for free a new() method, and accessor methods for the attributes you just defined with 'has'. So, you can say: my $person = Pers...
I have only used the Ferret/acts_as_ferret combo (legacy decision) on a client project. I strongly recommend looking at the **other** options first. aaf is very fragile and can bring your Rails app to a screeching halt if you make a mistake in the config or if for some reason you hit a bug in aaf. In such a case, in...
I have only used the Ferret/acts_as_ferret combo (legacy decision) on a client project. I strongly recommend looking at the **other** options first. aaf is very fragile and can bring your Rails app to a screeching halt if you make a mistake in the config or if for some reason you hit a bug in aaf. In such a case...
Why doesn't **sort** sort the same on every machine?
|unix|bash|ksh|sorting|
Using the same sort command with the same input produces different results on different machines. How do I fix that?
|unix|bash|sorting|ksh|
|unix|bash|sorting|ksh|
Using the same **sort** command with the same input produces different results on different machines. How do I fix that?
I'm not aware of any virtual machine in widespread use that saves statistical usage data between program invocations -- but it certainly is an interesting possibility for future research. What you're seeing is almost certainly due to disk caching.
I recommend *The C++ Programming language* by Bjarne Stroustrup. It's not a suitable book for new programmers, but I found it quite effective as programmer who was experiences in other languages and didn't want to waste too much time with learning how while loops work. It's a dense but quite comprehensive book.
Java JVM (actually might change from different implementations of the JVM) when first started out will interpret the byte code. Once it detects that the code will be running enough number of times JITs it to native machine language so it runs faster.
I would create an HTTPHandler that responds with the desired data read from the db. Just associate the HTTPHandler with the particular filename 'example_link_list.js' in your web-config. Make sure you set context.Response.ContentType = "text/javascript"; then just context.Response.Write(); your list of exter...
Plone-like search box in Django?
|django|search|
Plone has a beautiful search box with a "Google suggest" like functionality for its site. It even indexes uploaded documents like PDFs. Does anyone know of a module that can provide this kind of functionality in a Django site?
Anything written by [Meyers][1], recommended by [same][2], or written by [Sutter][3]. [1]: http://www.aristeia.com/books.html [2]: http://www.artima.com/cppsource/top_cpp_books.html [3]: http://www.gotw.ca/publications/
What you are proposing is not new. Plenty of people have tried it... most have found that they chase "infinite" flexibility and instead end up with much, much less than that. It's the "roach motel" of database designs -- data goes in, but it's almost impossible to get it out. Try and conceptualize writing the code for ...
**EDIT: made some changes and new suggestions** What about a sliding window... ABCBAbabaBBCbcbcBVbvBCbcbcAB __ABCBABABABBCBCBCBVBVBCBCBCAB (the lower case letters are the matches) now we removed strings of length two and get: ABCBA*BbC*BV*BC*AB _ABCBA*BBC*BV*BC*AB (* denote t...
**EDIT: made some changes and new suggestions** What about a sliding window... REMOVE LENGTH 2: (no other length has other matches) //the lower case letters are the matches ABCBAbabaBBCbcbcbVbvBCbcbcAB __ABCBABABABBCBCBCBVBVBCBCBCAB REMOVE LENGTH 1 (duplicate characters): //* de...
What OS are you targeting? If it's Linux there are a lot of GPS libraries available ([here's a good list](http://tuxmobil.org/linux_gps_navigation_applications.html)). [GPSd](http://gpsd.berlios.de/) and [GpsDrive](http://www.gpsdrive.de/) are two of the more popular ones I've seen. I haven't see any GPS devices...
Continue is a really useful function in most languages, because it allows blocks of code to be skipped for certain conditions. One alternative would be to uses boolean variables in if statements, but these would need to be reset after every use.
According to the Microsoft documentation, "You must enclose a Date literal within number signs (# #). You must specify the date value in the format M/d/yyyy, for example #5/31/1993#. This requirement is independent of your locale and your computer's date and time format settings." Are you saying that this is not ...
You should be able to use rake db:migrate:up to force it to go forward, but then you risk missing interleaved migrations from other people on your team if you run rake db:migrate twice, it will reapply all your migrations I encounter the same behavior on windows with sqllite, it might b...
By following some formatting and commenting standards, first of all you show your respect to other people that will read and edit code written by you. If you don't accept rules and write somehow esoteric code the most probable result is that you will not be able communicate with other people (programmers) effectively. ...
In practice many sites use `id` attributes starting with numbers, even though this is technically not valid HTML. The [HTML 5 draft specification][1] loosens up the rules for the `id` and `name` attributes: they are now just opaque strings which cannot contain spaces. [1]: http://www.w3.org/html/wg/html5/#id
I would suspect the permissions on the library. Can you do a strace or similar to find out the filenames it's looking for, and then check the permissions on them?
I think your code looks like this at the moment: l = "a very long ... text".split() for e in l: cursor.execute("INSERT INTO yourtable (yourcol) VALUES ('" + e + "')") So try to change it into something like this: l = "a very long ... text".split() for e in l: cursor.execute(...
I wouldn't. Anything that could change per "user" is usually not good in source control. .suo, .user, obj/bin directories
This appears to be Microsoft's opinion on the matter: [http://social.msdn.microsoft.com/forums/en-US/vssourcecontrol/thread/dee90d75-d825-4c76-a30f-016eab15ef7f][1] [1]: http://social.msdn.microsoft.com/forums/en-US/vssourcecontrol/thread/dee90d75-d825-4c76-a30f-016eab15ef7f
if you want this design for image processing or visulization, you can find a good ressource in [itk][1]. And if you want a gui for this (data/work)flow you can use [devide][2]. My 2cents, Johan [1]: http://www.itk.org/ [2]: http://devidenews.wordpress.com/
My own blog posting on this: http://www.codersbarn.com/post/2008/05/07/Beginning-Silverlight-First-Steps.aspx Anthony :-)
Automated testing of FLEX based applications
|web-services|testing|apache-flex|web-applications|
What tools, preferably open source, are recommended for driving an automated test suite on a FLEX based web application? The same tool also having built in capabilities to drive Web Services would be nice.
Ran the SQL commands below and the issue appears to be resolved. USING database_name GO EXEC sp_changedbowner 'sa' ALTER DATABASE database_name SET TRUSTWORTHY ON
There are additional minor differences that I have attributed to Chrome using a different (older?) version of Webkit (525.13) than the current release of Safari uses (525.21 for me). Example: [https://woot.campfirenow.com/login][1] In Safari, the password label and input box are directly below the email label...
Are you looking for the keyword "Nothing"?
There's a `.MousePosition` property which returns `System.Drawing.Point` and "Gets the position of the mouse cursor in screen coordinates" but I'm using an older version of their UltraWinGrid (2003). They have a [free trial download][1], so you could see if they've added it to their latest and greatest :o) ...
Thanks for all the responses. I guess I'll just have to go with what I'm doing now. For those who wanted to know why I asked the above question. I have the following function: string sMessages(ArrayList aMessages, String sType) { string sReturn = String.Empty; if (aMessages.Count > 0) { sReturn += "<p ...
<a href="http://www.cacti.net/">Cacti</a> is a good web-based monitoring/graphing solution. Very complete, very easy to use, with a large userbase including many large Enterprise-level installations. If you want more 'alerting' and less 'graphing', check out <a href="http://www.nagios.org/">nagios</a>. As for 'wh...
What is the .NET Control.Margin property for?
|c#|controls|margin|
i assumed that the C# margin property had a meaning like in CSS - the spacing around the outside of the control. But Margin values seem to be ignored to matter what values i enter. Then i read on the SDK: > Setting the Margin property on a > docked control has no effect on the > distance of the control from th...
you can omit the curly braces, like: using (FileStream fs = new FileStream("c:\file.txt", FileMode.Open)) using (BufferedStream bs = new BufferedStream(fs)) using (StreamReader sr = new StreamReader(bs)) { // use sr, and have everything cleaned up when done. } or use the regul...
If you are using Visual Studio 2005 or later, project files are MSBUild files. Inside the MsBuild file, there is an "AfterBuild" target. I would recommend using this to do your deployment tasks, instead of the Post Build Event. By using MSBuild tasks, you are more prepared to move into a Continuous Integration sys...
Mastering C++ from Tom Swan. It was the best kind of book, it had examples which were simple enough to teach concepts but useful enough to solve other problems. It was very readable, it was the first book I read when got to college, and it only needed to be read once.
Make VS compiler catch signed/unsigned assignments?
|c|c++|visual-studio|
The Visual Studio compiler does not seem to warn on signed/unsigned assignments, only on comparisons. For example the code below will generate a warning on the if statement but not the initial assignments. Is there anyway to make it catch these? I'm already at W4 but thought (hoped) there may be another setting some...
Personally, I'd create a VBA subroutine to do it, and connect to the database using ADODB, DAO or RDO (in that order of preference). Off the top of my head, the code to do it should look something like: Sub InsertLots () Dim SqlConn as ADODB.Connection SqlConn.Connect("your connection string...
Personally, I'd create a VBA subroutine to do it, and connect to the database using some form of sql connection. Off the top of my head, the code to do it should look something like: Sub InsertLots () Dim SqlConn as Connection SqlConn.Connect("your connection string") SqlConn.Execut...
[Think Python: An Introduction to Software Design][1] [1]: http://www.greenteapress.com/thinkpython/thinkpython.html
If you need a fast and reliable proxy server, it might make sense to try some of those that already exist. But if you have custom features that are required, then you may have to build your own. You may want to collect some more information on the expected load: hundreds of users might be a few requests a minute or a h...
The <a href="http://perldoc.perl.org/perl.html">perldoc</a> documentation is the best source for understanding how to use the language <em>well</em>. The camel book "Programming Perl" is an excellent printed reference with thorough explanations written by the same people who wrote the perldocs (other books with anim...
The name scrambling is used to ensure that subclasses don't accidentally override the private methods and attributes of their superclasses. It's not designed to prevent deliberate access from outside. For example: >>> class Foo(object): ... def __init__(self): ... self.__baz = 42 .....
According to the Microsoft documentation, "You must enclose a Date literal within number signs (# #). You must specify the date value in the format M/d/yyyy, for example #5/31/1993#. This requirement is independent of your locale and your computer's date and time format settings." Are you saying that this is not ...
I wouldn't say it is critical, but if you are going to go much further with the app, I would recommend doing it now while it is not as much of a monumental task. I would say the maintainability of a well written OOP program could far outweigh the up front costs. Especially when you consider that you will be able to ref...
I never found an easy way to convert from Vault to svn. Basically we took our latest branches and trunk and started new in svn. Honestly I went two or three labels back, just because. I kept the vault db around for six months and we never needed to go back to it for data. So I assume you want to carry forward your ...
Do you need to have the center div change size? If you're just trying to make sure that it appears that its background (#8080ff) appears between the header and the footer, why not just have the containing div's background be #8080ff. The header and footer background would override that, and the rest of the div's backgr...
[OpenEmbedded][1] is a good place to go to get started. A lot of embedded products use ARM and other processors, so cross-compiling is a big deal. [Buildroot][2] is another resource for building custom linux kernels for small systems. You can also find lots of manufacturers with Single Board Computers (SBCs) that ...
After installing the converting app on the linux/window machine you're running your Rails application on, use the "system()" command in Ruby to invoke the converting application on the system. system("command_here");
Re-using soft deleted records
|deletion|soft|
If I have a table structure that is: code+description+isdeleted where code is the primary key. The user creates a record, then later on deletes it. Because I am using soft deletes the isdeleted will be set to true. Then in my queries I would be doing a select with the where clause: and not isdeleted N...
In Applescript, how can I find out if a menu item is focused?
|applescript|menu|focus|
I have an script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help men...
|menu|applescript|focus|
I have an script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help men...
You need an Oracle Client to connect to an Oracle database. The easiest way is to install the [Oracle Data Access Components][1]. To minimize the footprint, I suggest the following : - Use the Microsoft provider for Oracle (System.Data.OracleClient), which ships with the framework. - Download the [Oracle Ins...
Perl testing scripts aren't special or magic in any way. As such, they can contain the exact same things that any other Perl script can. You can name routines anything you want, and call them before, after, and intertwingled with, your tests. You can have any amount of initialization code before any tests, any am...
It's not guaranteed to be safe. Here's a relevant link in the C++ FAQ lite: [16.13] Can I drop the [] when deleteing array of some built-in type (char, int, etc)?] [http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.13][1] [1]: http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16...
#include<stdio.h> #include<limits.h> #define TYPE_BITS sizeof(TYPE)*CHAR_BIT typedef unsigned long TYPE; TYPE reverser(TYPE n) { TYPE nrev = 0, i, bit1, bit2; int count; for(i = 0; i < TYPE_BITS; i += 2) { /*In each iteration, we swap...
You want to wrap your code in a transaction, then SQL server will handle locking the appropriate rows or tables. begin transaction --Grab the next message id declare @MessageId uniqueidentifier set @MessageId = (select top(1) ActionMessageId from UnacknowledgedDemands); --Acknowledge the ...
Learning object oriented techinques will be really useful, especially for programming in other languages in the future. Since you have only just started the application, you could rewrite and improve the parts you have written. It depends on your deadline.
I think you will need to make a secondary thread and poll for a key on the console. I know of no built in way to accomplish this.
phpED ([http://www.nusphere.com/products/phped.htm][1]) also offers great debugging and profiling, and the ability to add watches, breakpoints, etc in PHP code. The integrated profiler directly offers a time breakdown of each function call and class method from within the IDE. Browser plugins also enable quick integrat...
Are you trying to calculate the total days/months/years of an age? do you have a starting date? Or are you trying to dissect it (ex: 24 years, 1 month, 29 days)? If you have a start date that you're working with, datediff will output the total days/months/years with the following commands: Select DateDiff(d,'...
You don't need the swapObjectAtIndex method. exchangeObjectAtIndex:withObjectAtIndex: already exists.
Typical answer: "It depends." I tend to write the display page as a start-to-finish, < html > to < /html > scripted page. But the things that happen on that page were objects. Kinda like a poor man's ASP. While you *can* have OOP-base output, I alwasy thought it too cumbersome for a task as tedious as dumping data t...
If you create a binary file , you can write any file to it . The only drawback is that you have to know exactly where it starts and where it ends .