Monthly Archive for November, 2008

Shell Script for Looping Each Directory

Let’s say you are creating a batch script to loop through each “folder” you have in an directory- run:

$./list_dirs.sh /app

inside the shell script:
#list_dirs.sh
for i in $(ls -l $1 | awk ‘/^d/ { print $NF }’) ; do
echo $i # replace with actions to be done
done
#end script

basically ls -l will display all files+folders with their attributes.
awk filters to those lines starting with d attribute (/!d/) and strips out to the last field ($NF)

blog>logout

Visualising Disk Space

The first PC I used had a 512MB hard drive. It wasn’t long before I had to do clean up when the disk was reaching its capacity.

More than 10 years later, having use over 10 hard disks with the capacity of 1000x before, I still face the problem of storage shortage. Perhaps it was my poor management skills that puts me in a spot of doing a serious cleanup job when free space is critical.

Back in DOS (and still application to the windows command line), the “dir” command is used for checking free and used space. In Linux/*nix, “df” and “du” are the priceless tools for disk usage. Moving to the present, Windows Vista provides bar chart like displays under My Computer showing the disk usage. Yet with these and Windows Live searching and indexing, I fail to visualise what is utilising my drive, where and what they are.

Scanner 2 Disk Space Tool

Here’s my favourite program from years ago (during windows 98 period iirc)- a delphi (pascal) written lightweight freeware called Scanner. Years later, with many other diskspace visualizing software listed on software directories and search engines, Scanner is usually no where at the top. Its still, however, as useful and preferred for me as it displays in an interactive circular pie chart, as oppose to many bar and block charts (concentric pie charts vs treemaps/voronoi), where you can “drill down/up” or “zoom in/out”.

Overdrive

The only other free tool with “donut” charts I’ve used is Overdrive with more statistical information. If you’re feeling geeky on this topic, lifehacker recommends a couple more software. And for more? Plenty at freeware directories.

So go ahead, graph and see visually what’s taking the space, and manage your drive the way you wouldn’t have notice.

Simple Countdown Javascript App

I found this draft saved during January 14, 2007 at 8:28 pm, make a little changes such that I can publish it now (jump to last paragraph to avoid history).

That was my first “web coding” of the year after a time of isolation from web development during my national service.

In fact, that piece of js/web app I coded wasnt for the internet, nor on the intranet, but on a desktop of a workstation used in my unit. Its purpose was to display the time before I had left in the army.

There were other spreadsheet and applications some other soldiers did which counted the number of days to their ORD (Operational Ready Date), but I chose to create and personalise mine which

1. Tells me the absolute number of days, instead of working days
2. Updates and display the time change every milliseconds
3. Display visualisations of time spent instead of just numbers
4. Integrate it seamlessly on the workstation without doing any unauthorized stuff.

The result? Progress bars and numbers updating itself on the desktop automatically using- yup, active desktop. (We were using military computers, not developer’s machines, yes notepad was used). Colleagues thought it was pretty cool, while some of wanted it for themselves, others questions my reason for creating this as it seem that I couldn’t wait to finish my term in army. It wasnt surprising, as I knew some who counted the days they had to serve left in NS, and that me counting down with hours, minutes to fraction of a second seemed more extreme. The reply I had was that I lose track of time easily, and I wasn’t even counting, that my counter would not only tell me how much time I went though but to treasure the time I had left.

Noc Ord Counter Desktop

Previous Next Close
Noc Ord Counter Desktop

Fast forward to the present day, I thought I should treasure the time over here in noc silicon valley that I should use that I used over a year ago. I did have a non electronic copy of the source code I wrote and decide to modify it for my usage here. As seen on the screenshot, I use
+ a progress bar to tell the % of working hours left currently each day,
+ a progress on the percentage of time spent/left in NOC
+ a photo to appear as desktop wallpaper
+ configuration of active desktop
+ no, I wasn’t play games during office hours.

This running copy can be found over here, and you can follow the link and look at its source. Do take note of various limitations
- bad coding? it was coded as quickly as the idea came
- has bad browser compatibility. it was built for ie+active desktop
- resources hog. perhaps due to rapid reload

Another quick hack to the code I had was using gauge charts using google’s visualisations api.

Treasure every amount we have.