instruction
stringlengths
0
30k
I think the answer is: it depends. *It depends upon whether you need to configure and store the generated code as an artefact. For example, people very rarely keep or configure the object code output from a c-compiler, because they know they can reproduce it from the source every time. I think there may be a similar...
I would try Mercurial with [TortoiseHG](http://tortoisehg.sf.net) for Explorer integration. It's easy enough to use that I could without problems: * teach it to a not-that-computer-savvy-collegue for writing text together. * guide a friend by phone through installing Mercurial (TortoiseHG), creating a reposit...
Check this: [Powershell Which][1] The code provided there suggests this: ($Env:Path).Split(";") | Get-ChildItem -filter notepad [1]: http://www.codeassassin.com/blog/PermaLink,guid,fd1967d1-f844-4e29-82e2-f2d6424b4ef9.aspx
I see [my answer][1] came rather late, i.e. several other had written the same. Therefore I present an alternative method using regular expressions to validate and divide the string. class Program { //Accepts one or more groups of one or more digits, separated by commas. private static rea...
As a follow up, there is a little more information in the Apple Developer Connection (ADC) FAQ section: [http://developer.apple.com/faq/datatype.html][1] [1]: http://developer.apple.com/faq/datatype.html
As a follow up, there is a little more information in the FAQs at the Apple Developer Connection (ADC) website: [http://developer.apple.com/faq/datatype.html][1] [1]: http://developer.apple.com/faq/datatype.html
Based on the advice, moved the answer to the answers section: There are tools out there that give you a GUI for setting this easily, but you can also do it relatively easily by editing the registry. Under the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon Add ...
For an example of javascript accessing a local file, you might try taking a look at the source of [TiddlyWiki][1], specifically the saveFile, mozillaSaveFile, and ieSaveFile functions. Just click the download link, open the html file it sends you, and search for those functions. Of course, tiddlywiki is supposed to ...
I recommend that you read [Steve Krug's Don't Make Me Think][1] first. The book has a great checklist of things that you have to take into consideration when designing your UIs. While it's focused on web usability, a lot of the lessons therein are valuable even to desktop application designers. That being said, whet...
I recommend that you read [Steve Krug's Don't Make Me Think][1] first. The book has a great checklist of things that you have to take into consideration when designing your UIs. While it's focused on web usability, a lot of the lessons therein are valuable even to desktop application designers. That being said, whet...
You can also use pipes if you need bidirectional communication (i.e. with netcat): mknod backpipe p nc -l -p 80 0<backpipe | tee -a inflow | nc localhost 81 | tee -a outflow 1>backpipe ([via][1]) [1]: http://clug.net.nz/index.php/netcat "via"
//Note: if you have access to Java5+, //use StringBuilder in preference to StringBuffer. //All that has to be replaced is the class name. //StringBuffer will work in Java 1.4, though. appendWithDelimiter( StringBuffer buffer, String addition, String delimiter ) { if ( b...
You can use CGI and an (x)html combinator library, as in <http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell>. A larger overview of libraries, frameworks etc. for web programming in haskell is at <http://www.haskell.org/haskellwiki/Applications_and_libraries/Web_programming>.
You could use [Clojure][1] today to write tests and scripts on top of the Java VM. While there are other Lisp languages implemented on the JVM, I think Clojure does the best job of integrating with Java. There are times when the Java language itself gets in the way of writing tests for Java code (including "traditi...
I second **test anything that can possibly break** and **don't write silly tests**. But the most important tenet is **test anything that you find is broken**: if some method behaves oddly write a test to outline the data set that makes it fail, then correct the bug and watch the bar go green. Also test the "boundary" d...
C# with 27 non-whitespace characters - includes the call. Action a = null; a = () => a(); a();
I believe you can include radio buttons in a grid, though that's more cumbersome than it needs to be. Also, I don't think it'd be that hard to make your own control that creates the radio buttons dynamically using a flowlayout panel.
I think when you're trying to make your markup meaningful, these are rarely useful. There are, however, new tags that produce some of the same results, but which provide even more semantic value. I like to use the &lt;cite&gt; tag when I'm referring to the name of a book, for example, as it still gets italicised, bu...
The standard is [IEEE 754][1]. Of course, there are other means to store numbers when IEE754 isn't good enough. Libraries like Java's `BigDecimal` are available for most platforms and map well to SQL's number type. Symbols can be used for irrational numbers, and ratios that can't be accurately represented in binary ...
A quick linear-time solution in C#3 for the first problem is:- IEnumerable<int> ProductExcept(List<int> l, List<int> indexes) { int prod = l.Aggregate(1, (x, y) => x * y); return from i in indexes select prod == 0 ? 0 : prod / l[i]; }
A linear-time solution in C#3 for the first problem is:- IEnumerable<int> ProductExcept(List<int> l, List<int> indexes) { if (l.Count(i => i == 0) == 1) { int singleZeroProd = l.Aggregate(1, (x, y) => y != 0 ? x * y : x); return from i in indexes select l[i] == 0 ? singleZeroPr...
I haven't ever used this tool, but it looks like TypeMock has a tool called Racer that can handle this. Roy Osherove blogged about it [here][1]. Another post with a better preview is [here][2]. [1]: http://weblogs.asp.net/rosherove/archive/2008/09/04/finding-deadlocks-with-readerwriterlock-and-typemock-racer.asp...
Yes there is the [IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754)][1] The number is split into three parts, sign, exponent and fraction, when stored in binary. [1]: http://en.wikipedia.org/wiki/IEEE_754-1985
I dont have programed in Java ME, but i found in it's reference for optional packages the [Advanced Graphics and User Interface API][1], and it's used like the Java SE API to create these dialogs with the [JOptionPane Class][2] >int JOptionPane.showConfirmDialog(java.awt.Component parentComponent, java.lang.Object ...
The [STR function][1] has an optional length argument as well as a number-of-decimals one. SELECT STR(123.45, 6, 1) ------ 123.5 (1 row(s) affected) [1]: http://msdn.microsoft.com/en-us/library/ms189527.aspx
Let's take your example of a Dog and a Cat class, and let's illustrate using C#: Both a dog and a cat are animals, specifically, quadruped mammals (animals are waaay too general). Let us assume that you have an abstract class Mammal, for both of them: public abstract class Mammal This base class will proba...
I have a large table with 1 million+ records. Unfortunately, the person who created the table decided to put dates in a varchar(50) field. I need to do a simple date comparison - datediff(dd, convert(datetime, lastUpdate, 100), getDate()) < 31 But it fails on the convert(): Conversion failed when co...
For primitives just use `(string)$var` or print this variable straight away. PHP is dynamically typed language and variable will be casted to string on the fly. If you want to convert objects to strings you will need to define `__toString()` method that returns string. This method is forbidden to throw exceptions.
A nice looking, default, off the shelf, complete website could be more impressive than a poorly done, broken, tacked together, incomplete website. Perhaps start with something "off the shelf" but nice looking, keep it simple, professional, and then eventually add more custom functionality, style and content. Potential ...
A nice looking, default, off the shelf, complete website could be more impressive than a poorly done, broken, tacked together, incomplete website. Perhaps start with something "off the shelf" but nice looking, keep it simple, professional, and then eventually add more custom functionality, style and content. Potential ...
regex for parsing resource (.rc) files
|c++|regex|mfc|internationalization|
Ulimately I just wanted to extract strings from the .rc file so I could translate them, but anything that goes with .rc files works for me.
In order to export from Navision, you will need to have Microsoft Excel 2003 or 2007 installed on the machine (because export process is using automation calling Excel). However, after that, you definitely can open exported files using Open Office. But, you cannot export to OpenOffice directly. At least, not without...
What does 'foo' really mean?
|language-agnostic|coding-style|
I hope this qualifies as a programming question, as in any programming tutorial, you eventually come across 'foo' in the code examples. (yeah, right?) what does 'foo' really mean? If it is meant to mean **nothing**, when did it begin to be used so? Cheers
I think it's meant to mean nothing. The wiki says: "Foo is commonly used with the metasyntactic variables bar and foobar."
It's a [metasyntactic variable][1]. [1]: http://en.wikipedia.org/wiki/Metasyntactic_variable
Using a dynamic scripting language like Python, BOO, Ruby, etc. to create and maintain build scripts might be a good alternative to an XML based one like NAnt. (They tend to be cleaner to read than XML.)
How to control IIS 5.1 from command line?
|iis|windows-xp|
I found some informations about controlling IIS 5.1 from command line via adsutil.vbs (http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d3df4bc9-0954-459a-b5e6-7a8bc462960c.mspx?mfr=true). The utility is available at c:\InetPub\AdminScripts. The utility throw only errors like the following:...
I use a commercial software, [Automated Build Studio][1] for the build purpose. [1]: http://www.automatedqa.com/products/abs
As definition of "Foo" has lot's of meanings: * bar, and baz are often compounded together to make such words as foobar, barbaz, and foobaz. [www.nationmaster.com/encyclopedia/Metasyntactic-variable][1] * Major concepts in CML, usually mapped directly onto XMLElements (to be discussed later). [wwmm.ch.cam.ac.uk...
We use a combo of, taking backups from higher environments down. As well as using ApexSql to handle initial setup of schema. Recently been using Subsonic migrations, as a coded, source controlled, run through CI way to get change scripts in, there is also "tarantino" project developed by headspring out of texas. ...
In addition to your database CREATE script, why don't you maintain a default data or sample data script as well? This is an approach that we've taken for incremental versions of an application we have been maintaining for more than 2 years now, and it works very well. Having a default data script also allows your Q...
Can I have polymorhic containers with value semantics in C++?
|c++|stl|
As a general rule, I prefer using value rather than pointer semantics in C++ (ie using vector&lt;Class&gt; instead of vector&lt;Class*&gt;). Usually the slight loss in performance is more than made up for by not having to remember to delete dynamically allocated objects. Unfortunately, value collections don't work w...
Can I have polymorphic containers with value semantics in C++?
Yes, you got my question right. Sorry that I was a little bit confused yesterday. Now I have corrected the code by following your suggestion and mixing two pieces of code in the question together: Vector3f toScreenVector = new Vector3f(0, 0, 1); Transform3D t3d = new Transform3D(); canvas.getImagePla...
Let's take your example of a Dog and a Cat class, and let's illustrate using C#: Both a dog and a cat are animals, specifically, quadruped mammals (animals are waaay too general). Let us assume that you have an abstract class Mammal, for both of them: public abstract class Mammal This base class will proba...
If you MUST do this in SQL you can use the folowing code (This code assumes that you have no numerics that are bigger than 40 chars): SELECT REPLICATE(' ', 40 - LEN(CAST(numColumn as varchar(40)))) + CAST(numColumn AS varchar(40)) FROM YourTable
What is the best way to send large batches of emails in ASP.NET?
|asp.net|email|batch-file|
I'm currently looping through a datareader and calling the System.Net.Mail.SmtpClient's Send() method. The problem with this is that it's slow. Each email takes about 5-10 seconds to send (it's possible this is just an issue with my host). I had to override the executionTimeout default in my web.config file (it default...
There are a number of ways to solve this. The two primary are to use either visibility rules or highlights to create conditional formatting. The visibility is particularly attractive since it is easy to only apply the format rules to particular types of output (e.g. HTML). For this particular case, there are two p...
This is all starting to sound a bit like [Yesterday's TDWTF][1]. :-) [1]: http://thedailywtf.com/Articles/SUSBSTITUTE_CODE.aspx
I've been doing Eclipse RCP development for almost 2 years now. When I first started, I wanted a book for help and many people told me, with Eclipse you're better off using the [Eclipsepedia][1] and Google. However, I started with "[The Java Developer's Guide to Eclipse][2]" by D'Anjou et al, and I still reference ...
You can represent your formula as a tree of operations and sub-expressions. You may want to define types or constants for Operation types and Variables. You can then easily enough write a method that recurses through the tree, applying the appropriate operations to whatever values you pass in.
Multiple classes in a header file vs. a single header file per class
|c++|performance|file-organization|
For whatever reason, our company has a coding guideline that states: `Each class shall have it's own header and implementation file.` So if we wrote a class called MyString we would need an associated MyStringh.h & MyString.cxx. Does anyone else do this? Has anyone seen any compiling performance repercussions...
The problem is most likely how the data is stored, there are only two safe formats ISO YYYYMMDD ISO 8601 yyyy-mm-dd Thh:mm:ss:mmm(no spaces) these will work no matter what your language is. You might need to do a SET DATEFORMAT YMD (or whatever the data is stored as) to make it work
I think it's the right way to go. Considering that [GPUs have been tapped to create cheap supercomputers][1], it appears to be the natural evolution of things. With so much computing power and R&D already done for you, why not exploit the available technology? So go ahead and do it. It will make for some cool re...
Thank you all for your thoughts. Printing directly to the serial port is likely the most flexible method. In this case we didn't want to replicate all of the work that was already built into the Intermec dll for handling the port, printer errors, etc. We were able to get this working by sending the printer the appropri...
altering the sequence's INCREMENT value, incrementing it, and then altering it back is pretty painless, plus you have the added benefit of not having to re-establish all of the grants as you would had you dropped/recreated the sequence.
First, your class should limit the generic parameter to primitives ( public class Fraction<T> where T : struct, new() ). Second, you'll probably need to create [implicit cast overloads][1] so you can handle casting from one type to another without the compiler crying. Third, you can overload the four basic oper...
How do you unit test business applications?
|unit-testing|
How are people unit testing their business applications? I've seen a lot of examples of unit testing with "simple to test" examples. Ex. a calculator. How are people unit testing data-heavy applications? How are you putting together your sample data? In many cases, data for one test may not work at all for another tes...
How are people unit testing their business applications? I've seen a lot of examples of unit testing with "simple to test" examples. Ex. a calculator. How are people unit testing data-heavy applications? How are you putting together your sample data? In many cases, data for one test may not work at all for another tes...
Take a look at the [Boost.Python][1] library. It looks like it should be fairly straightforward to do what you want. [1]: http://www.boost.org/doc/libs/1_36_0/libs/python/doc/index.html
The easiest way is to pad left: CREATE FUNCTION PadLeft(@PadString nvarchar(100), @PadLength int) RETURNS nvarchar(200) AS begin return replicate(' ',@padlength-len(@PadString)) + @PadString end go print dbo.PadLeft('123.456', 20) print dbo.PadLeft('1.23', 20)
I don't think you'd need to process the dump file like that. Do a streaming dump/restore, and process that. Something like: createdb -h scratchserver scratchdb createdb -h scratchserver sanitizeddb pg_dump -h liveserver livedb --schema-only | psql -h scratchserver sanitizeddb pg_dump -h scratchs...
Basically what you need to worry about in floating point numbers is that there is a limited number of digits of precision. This can cause problems when testing for equality, or if your program actually needs more digits of precision than what that data type give you. In C++, a good rule of thumb is to think that a ...
keyword for the outer class from an anonymous inner class?
|jave|anonymous-inner-class|
In the following snippet public class a{ public void otherMethod(){} public void doStuff(String str, InnerClass b){} pubic void method(a){ doStuff("asd", new InnerClass(){ public void innerMethod(){ otherMethod(); } ...
|java|anonymous-inner-class|
Here's a comparison from HP on the differences between shells: <br/><a href="http://docs.hp.com/en/B2355-90046/ch15s03.html" target="new">http://docs.hp.com/en/B2355-90046/ch15s03.html</a> Here's a great set of UNIX shell tutorials from Richard's Shell Scripting Universe: <br/><a href="http://www.injunea.demon.c...
> What we did notice however, when an > object is in a hashed collection > object (a hashtable, a dictionary > etc), when 2 objects are not unique > but their hashcodes are, the hashcode > is only used as a first option lookup, > if there are non-unique hash codes > being used, the equality operator is > always...
How to get whois information of a domain name in my program?
|c#|java|whois|domain-name|
I want to get whois information of a domain name from my c#/java programs. Is there a simple way to do this?
Consider uploading them to "Style Library" in the root of the site collection. <p>If you don't have a "Style Library" at the root, consider making one -- it's just a document library. <p>Make sure the permissions are set correctly so everyone who needs to read it can. <p>You can reference them using "/Style%20Librar...
How to deal with poorly informed customer choices
|methodology|customer|
Here's a scenario I'm sure you're all familiar with. 1. You have a fairly "hands off" customer, who really doesn't want to get too involved in the decision making despite your best efforts. 2. An experienced development team spend hours discussing the pros and cons of a particular approach to a problem and co...
I always use the system types - e.g., Int32 instead of int. I adopted this practice after reading Applied .Net Framework Programming - author Jeffrey Richter makes a good case for using the full type names. Here are the two points that stuck with me: 1. Type names can vary between .Net languages. For example, in ...
No, you can escape any character that Java doesn't allow in String literals but the filesystem allows. Also, if trying to port an Windows app to Mac or Unix it is best to use: File.separator To determine the correct file separator to use on each platform.
Further to my previous answer, if you want to see exactly what's going on under the hood in detail, run your script in the debugger with trace mode on (<tt>perl -d filename.pl</tt>, then say "t" to trace, then "r" to run the script; expect a lot of output though!).
I can highly recommend that you take a look at [Luabind][1]. It makes it very simple to integrate Lua in your C++ code and vice versa. It is also possible to expose whole C++ classes to be used in Lua. [1]: http://sourceforge.net/projects/luabind/
If you need to list all rows where all the column values are NULL, then i'd use the COLLATE function. This takes a list of values and returns the first non-null value. If you add all the column names to the list, then use IS NULL, you should get all the rows containing only nulls. SELECT * FROM MyTable WHERE COLLATE...
In MySQL, you can execute SHOW DATABASES; and SHOW TABLES; to see what you have at least minimal access to. Are you looking for something more programmatic?
Splitting a file and its lines under Linux/bash
|linux|bash|largefile|filesplitting|
I have a rather large file (150 million lines of 10 chars). I need to split it in 150 files of 2 million lines, with each output line being alternatively the first 5 characters or the last 5 characters of the source line. I could do this in Perl rather quickly, but I was wondering if there was an easy solution using b...
Whatever it wants to use as default. Changing that is just asking for trouble later.