By default, Mac OS X 10.6 (Snow Leopard) bundles with Apache/MySQL/PHP. However, they do not quite work out of the box. Follow these extra steps and you’ll get your web server up and running in no time.
- Author: arimbun
- Published: Jul 20th, 2010
- Category: Programming
- Comments: None
PHP: echo and print
Both commands are used to display some output, so what’s the difference? I chanced upon an interesting article that covers the differences between the two. I’ll put up the summary here:
echois (marginally) faster thanprint. Providing that the statement is in a large enough loop, one will notice a slight performance gain by usingecho. It’s probably advisable in the long run, unless you’re already used toprint.- passing mutiple string parameters is faster than concatenating multiple
echocalls. See example below:
// "." signals concatenation and is slower echo "hello" . "world" // "," signals multiple arguments and is faster echo "hello", "world"
- Author: arimbun
- Published: Jul 19th, 2010
- Category: Programming
- Comments: None
The Pathfinder
Artificial Intelligence (AI) has always been one of my interests. I was lucky enough to enrol in possibly one of the best courses offered at The University of Sydney, namely COMP3308 Introduction to Artificial Intelligence. My first assignment touched on path search algorithms which form the basis of “smart robots”. The problem in a nutshell is to write a program that, given a start node and a finish node, finds a path through a given maze (8×8 or 16×16) in the most efficient way. Five different algorithms were used: breadth-first search, depth-first search, greedy best-first search, A* search and hill-climbing search.
You can download the Python source code and documentation on my GitHub.
I am planning a version 2 which will incorporate a GUI for visual aid of the simulation, but first I’ll need to get my Python GUI programming up to speed…
Jobs admits antennagate on iPhone 4
It took a while, but Steve Jobs finally admitted in a press conference that poor signal calculation algorithm was to blame for the wireless signal problem. I find this one particularly interesting; I would have thought that the built-in antenna design was responsible, but algorithm? Is the problem really inherent to the software?
Update: It appears that the software update was only meant to improve the phone’s calculation of signal strength and did not actually solve the problem it had with signal loss.
Introduction to rsync — quick file synchronisation
rsync is a very good utility for synchronising files over a network. It works based on the delta-transfer algorithm—only data in the source that do not exist on the destination are copied over. This method saves plenty of time and bandwidth compared to the standard cp command.
Example: rsync $SRC $DST
On your local machine, you can use this to:
1. Copy files in a directory into another. Below code will match all files in the home directory that have the .txt extension and copy them all into /path/to/heaven.
rsync -v /home/login_name/*.txt /path/to/heaven
2. Copy directories (recursively) from a directory into another. The command below is similar to the previous, except that all directories (and their contents) are copied as well.
rsync -vr /home/login_name/* /path/to/heaven
Rework by David Hansson
David Hansson—the creator of Ruby on Rails and partner at 37signals— co-wrote Rework, a book designed to target bad business practices and how they could change. There is a free excerpt available if anyone is interested. Its succinct language is a common trait today and should come across as easy to understand.
The book’s key mottos—as seen on the back cover—sum it up quite nicely.
- Author: arimbun
- Published: Jul 7th, 2010
- Category: Programming
- Comments: None
The Friends problem
This is a good programming practice of creating a recursive descent parser besides the calculator itself. The Friends problem calculates the set union(s) or set difference(s) between a given number of sets.
Sample input
{ABC}
{ABC}+{DEFG}+{Z}+{}
{ABE}*{ABCD}
{ABCD}-{CZ}
{ABC}+{CDE}*{CEZ}
({ABC}+{CDE})*{CEZ}
Sample output
{ABC}
{ABCDEFGZ}
{AB}
{ABD}
{ABCE}
{CE}
Source code is available on my GitHub.



Recent Comments