I adore it. →Link
A great lecture. “He did, however, mention that he experienced a near-deathbed conversion: he switched and bought a Macintosh computer.” →Link | →Link to YouTube Video

When it comes to UNIX shell-scripting I need all the help I can get.  It’s hard trying to do something new because getting to the right info requires reading many manual pages.  Here are commands I learned to find the latest version of a file that has a timestamp in its filename.  Suppose the files are

myFile.2008-05-01.12.45.01

myFile.2008-05-01.12.46.02

myFile.2008-05-01.12.47.03

and they’re in a directory with many other files, and you want to find the myFile with latest time, then issue this command in the directory of myFile:

ls -l | awk '/myFile/ {print $NF}' | tail -n 1
 

Ok, so what does this do?

“ls -l” prints the files in the current directory, one file per line, in ascending sorted order.  This output is passed to awk, which evaluates each line, searching for the pattern myFile, and for each line with myFile, it separates the words by whitespace, and prints the last field, which is the filename.  The list of such filenames is then passed to tail -n 1, which simply prints the last file in the list.  The result should be what we want.  Of course, if there are other files such as myFileABC, then this command won’t work.  We’ll need a more specific regular expression pattern in the awk command.

Can anyone do it simpler?  Please share.  Thanks.

In a UNIX shell terminal, a prompt indicates the shell is ready for a command. An example:

$

PS1 is the environment variable that determines what the prompt is.  Change it to change the prompt.

For example: PS1=${PWD}> ‘ will set the prompt to display “current_directory> “.  Pay attention to the single quotes.  Using double quotes may have a different effect.

To keep your new prompt each time you log in, set PS1 in your .profile file in your home directory.

Play around.  Different shells require different symbols.  Here are some more examples.

In bash, I use: PS1=’\[\e]0;\w\a\]\n\[\e[32m\]\u@\h\[\e[0m\]\n\$ ‘

In ksh, I use: PS1=’${HOSTNAME?}:${PWD?}’`echo “\n> “‘

Tell me what you are using.

“Ben Fry analyzes the data from an intelligence test administered to all incoming NFL players and displays the results by position.” [Via Kottke.org] →Link
Creating art pieces with simple algorithm and minimum amount of code.[Link]
The irony is, 5 years later, Vista managed to be a worse product than XP. It seems something is wrong with both MS and Windows that even Bill couldn’t fix it. Architecture, perhaps? [Link]

Jonathan Schwartz, the CEO of Sun, has posted an insightful article on the why and how behind ZFS. The link is here.

b2cf816df4ec5dfa6da3ef9ba89bed49 A little blue screen for everyone

The blue screen is back, brought you by Adobe!
Ok not exactly by Adobe. It’s done by this guy.

Here’s how it works.
When you enter fullscreen mode in Flash 9 there’s a little message telling you that you can exit fullscreen by pressing escape. What this guy discovered was that it’s not difficult to obscure that message and make it appear as though the machine has crashed(Windows crash).
Don’t worry about future variations(read:future pranks) though, because when Flash goes fullscreen, keyboard input is disabled.
Now if only someone is smart enough to come up with a fake OS flash done this way..

So I was trying to set up Apache on Leopard for my laptop, then I realized that Apple has already installed Apache 2.2 in OS X. You can activate the Apache server by turning on Preference>Sharing>Web Sharing. Then I thought Apple might just have set up everything I needed already, and all I needed was AMP(Apache, MySQL and PHP). Well, not really. It turned out that PHP 5 was installed but for some reason, disabled. That’s like selling you a house but forgot to give you the key.

And I don’t get why.

Actually the only reason I can think of is iWeb, which is PHP-free. A simple Drag-and-save will get you a nice html page uploaded in your /user/Sites/ folder.
So I guess Apple is suggesting normal user to forget PHP and simply use iWeb to publish their sites. That’s kind of lame and unnecessary, but again, I can easily be wrong.
And in case you are wondering how to activate PHP in leopard, there’s an all-in-one package that’s going handle all the hassles activating PHP. It will also set up phpMyAdmin for you. The download link is here. It seems that there was also some way to manually activate PHP, now though that way no longer work.

I tried MAMP and it worked without problem on Leopard, and is definitely worth considering if you don’t want to waste too much mess with terminal commands. To make it work copy the downloaded MAMP folder to Applications, and then double-click the MAMP icon inside the MAMP folder. I suggest that you select Preferences > Ports, and click “Set to default Apache and MySQL ports”. If you do this, it’s important not to switch on Web Sharing in System Preferences. You must also close down any existing MySQL server. It’s also important to realize that the Apache and MySQL versions installed by MAMP are completely independent. The site root and MySQL data store are in different locations. Any databases created in a previous installation of MySQL must be exported, and reimported into the MAMP version of MySQL. The need to move things around detracts from the attraction of MAMP if you already have several databases stored in an existing installation of MySQL.

P.S. Quote from the site of MAMP.

Will MAMP work if the MAMP folder is not located in the Applications directory?
No. In order to work properly the MAMP folder has to be located in the Applications folder.

Quake 3: Arena

 float InvSqrt(float x){

    float xhalf=0.5f*x;

    int i=*(int*)&x;    

    i=0×5f3759df - (i>>1);    

    x=*(float *)&i;

    x=x*(1.5f-xhalf*x*x);    

    return x;
}

Analysis coming soon.

A little bit Google searching got me the usage of this Inverse Square function in Quake 3. Mind you it was written prior 2000.

Read more

48265978c187f49852dc5cee337a4386 My Free Software Runs Your Company

This is the creator of MySQL, Michael Widenius. He’s not boasting at all.
Thanks for your creation bro XD

[Photo Via Jonathan Schwartz]

b5c92e6e1510e1e06bd9eb158f0cf0fe Observation of Forbes 400

Top 20:
#1 William Gates III Net Worth $59.0 billion Harvard University, Drop Out
#3 Sheldon Adelson Net Worth $28.0 billion City College of New York, Drop Out
#4 Lawrence Ellison Net Worth $26.0 billion University of Illinois, Drop Out
#7 Kirk Kerkorian Net Worth $18.0 billion High School, Diploma
#8 Michael Dell Net Worth $17.2 billion University of Texas Austin, Drop Out
#11 Paul Allen Net Worth $16.8 billion Washington State University, Drop Out
#19 Jack Taylor & family Net Worth $14.0 billion Washington University, Drop Out
There are more but it gets kind of meaningless.
Among Top 11, 6 are in IT industry. 4 of those 6 are drop-outs.

Oh did I mention Steve Jobs?
Steve Jobs Net Worth $5.7 billion Reed College, Drop Out
Update: Mark Elliot Zuckerberg Net Worth $1.5 billion, Harvard University, Drop Out