A Web Worker makes it possible to run Javascript code without blocking the user interface. That is, computations can be made in the background without locking the user interface.
A Web Worker is created as follows
// Main script
var worker = new WebWorder( url );
where url must point to a Javascript file. The script is started immediately. This article describes the ‘standard’ Web Worker, not the ‘shared’ Web Worker.
Subversion holds various information in .svn directories placed in all directories and sub-directories under version control. Sometimes it is desireable to clean out these files, for example, prior to emailing a zip of the files. I use the awesome tool Total Commander for the job.
The procedure is as follows
Start Total Commander and make a directory in a scratch area such as c:\temp.
Copy the directories to this tempoary directory
If you use more than one computer chances are that you use DropBox to keep a number of often used files syncronized and at hand.
I also like to have at least a somewhat similar configuration of various programs on systems. With respect to emacs I have the following .emacs
;; For convenience add the dropbox directory as a variable
;; and set the default directory to that very same one
;; Thus, when storing files you 'start path' will be in
;; the dropbox.
I had my old Windows Pocket PC 2003 stolen from my office and until now I have developed on the emulator. However, now the need for a physical device has come up and I got the HP IPAQ 214.
The old PDA was plug’n’play with respect to developing, that is, deploying from Visual Studio and so is the emulators. However, the iPAQ 214 did not allow me to deploy due to some security permissions.
Project Euler problem number #24 deals with permutations in lexicographical order. A non-brute force approach involves a mixed base number system based on factorials.
This problem is one of those that I solved using pen and paper after some research. I used the following Wikipedia pages:
Permutation where I learned that there is a connection between the lexicographical order of a permutation and
the factorial number system representation of that particular number
Finally, you will need to remember that the Wikipedia articles both counts 0,1,2,… while the Euler problem counts 1,2,3,….
I have never completely understood why Visual Studio had to start another (graphical) utility in order to create GUIDs. I’m all for the UNIX kind of small (text based) utilities than can be combined. Furthermore, this utility creates GUID in formats that are useful to C++ programmers. Why have they not used the built in Macro system?
On the other hand it makes it possible for me to try out Visual Studio macro programming.
For a long time I had a strange problem on my workstation. Some programs crashed before showing a window. For example, I was unable to run programs in the standard Visual Studio projects folder under my documents and settings. But they ran fine when moved somewhere else. I suspected some permission problem but I could not find and thus fix it.
Another program that I have helped develop, FarmGuard, had an even more bizarre behaviour.
The familiar for loop featured in most if not all impertive langagues is not part of most functional languages if any because it has the mutable loop index. The standard way of looping in F# is to use recursion.
In the solution to Project Euler problem 7 I have the following function
let rec findprime primes test =
if isprime primes test then test
else findprime primes (test+2)
Notice that the recursive call is placed as the very last operation in the function and it is therefore a tail call.
My previous task switcher application had a serious performance problem as it was programmed in .NET. In order to start the small utility you had to load up the CLR and a bunch of assemblies (dlls). If you are a .NET developer it might not be that big a problem as most of the code was already loaded up. However, for general use it was not the best option.
Hence, I ported the utitly to C++ with the MFC framework to help me.
F# has a nice syntax for creating sequences where elements are created on demand. For instance
let asequence1 = seq { 1 .. 20 };;
creates a sequence of the numbers 1 to 20. No supprise here. We are also able to include steps, that is,
let asequence2 = seq { 2 .. 2 .. 20 };;
where we only take even numbers. However, in several of the Euler problems we do not have an upper limit on the search space.