2005-02-17

M(i|a)croscopic

This blog's been neglected, so I think I'll post some musings from the past few weeks.

Having recently returned to the city from a small country town, the difference amazes me. I've never lived in the country before in my life and it was a totally new experience.

Everyone's friendly, people get to know you quickly, yet for some reason that tends to make me uncomfortable and vaguely paranoid. There is a sense of security in the anonymity of the city that I was hitherto unaware of. And yet, out there, the atmosphere is more relaxed. World events push at the same rate, but somehow the country absorbs them more slowly. The days do not rush, they meander.

But the biggest difference is the people. In the city, a business suit and a laptop bag are marks of status, of acceptibility, There, I felt self-conscious walking down the street with my mp3 player and mobile phone. Here, people hurry, honed in on their targets, dodging and ducking through the obstacle course that is the city pavements. There, they stroll along, pausing to have a chat or see what takes their eye, and amicably give way to each other. Here, a university degree is how you get a decent career. There, leaving school at Year 10 and helping your father work the farm is the sign of a good future.

In this day and age, what makes the difference? A country town is no less connected than the city, news reaches there as quickly as it does here, so wherein lies the vastly separated mindset? I think it's because it's always been like that, and now it's self-perpetuating. People go to the city to be connected, to be on the cutting edge, at the centre of things. People go to the country to slow down, to get back to the land, to enjoy a sense of community.

Out there, the world is at once very big and very small - and sometimes it's hard to tell the difference.

M.

2005-02-01

Creating OS X application bundles step by step

Introduction

This guide is the result of attempting to package a network visualiser (tcprose) I wrote so that it can be distributed as an application bundle. I gathered information from many places, and while I try to be accurate as possible should you notice any bugs feel free to contact me.

Step 1 - The folder hierachy

Each application bundle is on disk a file that ends in .app and contains a strict folder hierachy. The folder hierarchy is the form:
  • application.app
    • Contents
      • Info.plist
      • Frameworks
        • dependent non-standard libraries
      • MacOS
        • executable binary
      • Resources
        • icons and other support files
The first thing you need to do then is to create such a folder tree somewhere.

Step 2 - The binaries

The binaries of your program reside in the MacOS folder. If your program depends on libraries that are not present by default, then you need to do the following:
  1. Figure out what libraries your application depends on, and figure out what libraries need to be distributed with the program. In order to see the dynamic libraries your binaries depend on, use the otool thus:
    otool -L binary
    In my case:
    solaris:~/code/tcprose steve$ otool -L tcprose
    tcprose:
    /sw/lib/libSDL-1.2.0.dylib (compatibility version 8.0.0, current version 8.1.0)
    /System/Library/Frameworks/Cocoa.framework/Versions
    /A/Cocoa (compatibility version 1.0.0, current version 9.0.0)

    /System/Library/Frameworks/OpenGL.framework/Versions
    /A/OpenGL (compatibility version 1.0.0, current version 1.0.0)

    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 71.1.1)
    /sw/lib/libpcap.0.dylib (compatibility version 0.8.3, current version 0.8.3)
    solaris:~/code/tcprose steve$
  2. Anything in /System or /usr can be safely assumed to be present on all default systems. Notice then the 2 libraries in /sw/lib. For those unfamiliar with fink, its where it installs all its packages. Those 2 libraries need to be copied into the Frameworks folder. Do be careful however that you copy the actual file, not the symbolic links. For example:
    solaris:/sw/lib steve$ ls -l libpcap.0.dylib
    lrwxr-xr-x 1 root admin 19 20 Aug 03:35 libpcap.0.dylib -> libpcap.0.8.3.dylib
    solaris:/sw/lib steve$
    Notice that libpcap.0.dylib is in fact a symlink to libpcap.0.8.3.dylib, thus you need to copy /sw/lib/libpcap.0.8.3.dylib, not /sw/lib/libpcap.0.dylib.
  3. Once the required libraries have been copied into Frameworks folder, its time to do some linking manipulation. Use the install_name_tool to remapped the dynamically linked libraries so your binary links against the libraries in Frameworks folder. To do this you issue the command:
    install_name_tool -change old_library_path new_library_path binary
    In tcprose's case:
    solaris:/sw/lib steve$
    install_name_tool -change /sw/lib/libpcap.0.dylib @executable_path/../Frameworks/libpcap.0.8.3.dylib ./tcprose
    Notice the use of @executable_path: this is what makes it "tick". @executable_path will automatically map to the path where the executable is located. Now if you move the binary into the MacOS directory, it will link against the libraries you have copied into the Frameworks folder
Word of caution: as far as I know there is no way to re-map the paths of any files in the binaries. Thus if you open files by using fopen("file", "rw"); then it will fail, because the working directory will be the directory that contains the application bundle, not the directory where the binary is stored. You will therefore need to take this into account, and adjust your paths accordinly.

Note
: It might be possible to set the environmental variable PWD via Info.plist (see next step) to certain directory so that the working directory is somewhat more manageable. I didn't have any luck with this, so kindly let me know if you figure something out.

Update - 6/3/05: as pointed out by a reader, you can extract the path of the executable from argv[0], and thus determine the relative paths of whatever resources your program needs.

Step 3 - Info.plist

Now we come to the most important step of creating an application bundle: creating a proper Info.plist inside the Contents folder. Info.plist is an xml file that describes properties that finder reads Info.plist and determines many things, including which binary inside MacOS to execute, what icon inside Resources to display, etc. The best tool to use for editing it is no doubt Property List Editor in /Developer/Applications/Utilities. You can of course do this by hand. Apple has a detailed document on how to create a proper Info.plist file, but at the absolute minimum the following keys are required:
Extra: if you want to specify a custom icon, first create a .icns file with Icon Composer found in /Developer/Applications/Utilities then save the .icns file in the Resources folder, and add the CFBundleIconFile key.

Conclusion

Creating an application bundle is a relatively easy affair, the most difficult part being remapping the dynamically linked libraries and adjusting any hardwired paths and generating a proper Info.plist file. Have fun, and if you have any suggestions or bug reports, do let me know!

Cheers,
Steve

2005-01-24

Preserving stdin when using SDL

SDL has a "feature" where by it redirects stdin/out/err on certain platforms, including OS X. This presented problems since tcprose (an opengl network visualiser) depended on stdin for interprocess communication. After much mucking about, I arrived eventually at a 3 line solution to the problem:

First we duplicate the stdin file descriptor so when SDL calls close() on 0 the stream remains open.
int dup_fd = dup(0);
Then we initalise SDL, and let it redirect stdin as it does.
SDL_Init(SDL_INIT_VIDEO);
Here is where we do our little trick: close 0, then duplicating the original stdin stream back onto 0, so scanf etc will continue to work.
close(0);
dup2(dup_fd,0);
And viola! We have stdin back again, no longer redirected. This solution won't work for window users though. See discussion at gmane.org.
Cheers,
Steve

2005-01-06

FSAA using SDL

Taking a break from working on emmap, I got back into the wonderful of C/OpenGL/SDL programming again.

SDL is a wonderful library that does... well a lot, but in a portable fashion that works on many platforms. One of these include Full Screen Anti Aliasing (FSAA), which makes things Look Good. I won't go into detail on how its done via SDL, there are resources a plenty. What I will impart is however a small piece of knowledge I gained after debugging a visualisation I am writing: FSAA through SDL will only work reliably cross platform only if the screen color depth is 24 or less.

Its a small thing, but it took a while to work out. Hope this helps some one :-)

Cheers,
Steve

2004-12-20

bugmenot

Some news sources, like the new york times and sunday morning herald, have an annoying "feature" - they require the viewer to first register before allowing them to view the contents. Many other sites are guilty of the same, and bugmenot was setup so one doesn't have to lose one's privacy to these data sinks.

To aid in a better, faster, and more private surfing experience, there exists a bugmenot pluging for firefox, which will fill out any required forms with valid usernames and passwords contributed by its members.

Now thats what I call user friendly.

Cheers,
Steve

2004-12-14

mChat - php chat room

M was stuck in a rather, for the lack of a better word, tightass network. So to facilitate communications, I wrote mChat in php. It grew from a simple (and rather smugly) script into one that supports avatars from atomicmpc with auto refresh, /me and user highlighting.

Try it out, there is almost always some one there. If you are interested it using the script on your site, just drop me a line.

Cheers,
Steve

2004-12-13

emmap online store

I am selling some merchandise from the emmap project through cafepress. If you are looking for some unusual stuff, try them out :*) All of them contain maps of the world wide web in one form or another.

Cheers,
Steve

2004-12-09

O Discordia

Its finally happening, the freedom of information (aka intellectual property) is restricted in this great country of ours (australia). Due to the FTA, copyright laws in Australia now lets some one other then the copyright holder to issue cease-and-decease orders to ISP in order to protect their "intellectual property".

Feck, and if that isn't bad enough, we are going to welcome the new year with the FTA coming into effect. Money over social morals once again.

In other news, if you ever have to deal with processing large number of files with Java, instead of using File.listFiles() iterating through the returned array, I strong recommend you implement FileFilter so that the processing is done with in, and use File.listFiles(FileFilter filter) instead. This gave significant speeds boosts to the post-processing tools used to produce the maps from the data set, also reduced the amount of required processing power.

Ocean's 12 by the by, is a good movie.

Cheers,
Steve

2004-12-03

Addicted to computers

A lot of people accuse me of being addicted to computers: sitting in front of them all day long, tapping away at the keyboard, eyes burning with intensity normally associated with heroin addicts.

They make it sound like a bad thing, that some how I am wasting my life, not enjoying the "outdoors" enough. They think I am one of those information junkies, those bums of the net who do naught but browse, and browse, and browse.

Yet the same people look on with awe and praise at master painters who spent all day and night inside their studio, facing the same piece of canvas, brushes moving rapidly from pools of color to canvas and back in fluid practiced strokes whilst their eyes burn with an intensity similar to mine. Understand I do not compare myself to the likes of Da Vinci, I simply draw parallels between a candle's flame to that of a roaring bon fire.

I would like for my accusers to know that I am addicted not to computers but to one part of life. Imagine if you will being able to realise your dreams in an instant. The old peopled call it magic, and rightly so. Through programming we can offload our very thoughts into silicon, then preserve and distribute them to the world and ultimately when executed they become reality. This marvelous ability to encapsulate segments of our mind and share them so the world may see what we see in our mind's eye is simply magic. Building on other's ideas and thoughts we can create works of art that defies tradition, music that no instrument or vocal chord can produce, and even more astoundingly, add to other's ideas. Computers give us a collective mind of sorts, bringing together the brightest and best ideas so the pictures we see in darkness, music we hear in silence, insights we have in stillness can all be made real. To this tool I am addicted; to this task of turning dreams into the tangible I am addicted; to this one vital aspect of life, I am addicted.

Humanity has always sought the means through which its ideas can manifest themselves in reality, some mechanism to turn abstract thought into physical constructs. For aeons we utilised the arts: music, painting, writing and more. We gave vent to our imagination through what talents and tools we had, and those who were blessed rose to become giants immortalised in history. Now humanity has at its disposal technology to materialise its thoughts more then ever, and not only of a single gifted individual, but of all of humanity. Never in history have we been so saturated in magic.

Instead of pointing the finger, why not join us? Expand your mind and give birth to your imagination - become an addict today.

2004-11-26

When mailing lists go wrong

Thanks to Scott, I can bring to you a hilarious example of what happens when mailing lists are mis-configured:
Subject: Email Problems
Date: Thu, 25 Nov 2004 21:38:37 +1100 (EST)
From: Mick Houlahan
To: undisclosed-recipients: ;

Over the last week we have had a number of problems with the student email
service.

Last Thursday, a large number of students were invited by email to
participate in a survey. Unfortunately the list mechanism that was used to
issue this invitation was incorrectly configured. The end result was that
each reply to the survey instead of being directed to the survey author
was copied to each and every other member of the list. With some 20,000
students invited to participate, one can imagine the flow on effect of
each reply generating a further 20,000 emails.

Although the UWS IT Group became aware of this on Friday morning and took
immediate steps to adjust the list processing configuration, much of the
damage had already been done. Mail queues on the student email server were
saturated with close to half a million messages in the queue at its
peak. The server was still severely stressed on Monday of this week having
been spent the weekend trying to handle the mail load. As well as the
sheer number of emails, the file systems on the server filled up and
exacerbated the problem.

A disk failure on Tuesday no doubt brought on by the severe processing
load didn't help things at all!

The end result for most students has been an unreliable email service for
much of the last week with a large number of students receiving numerous
messages responding to the survey.

The University does apologise for any inconvenience that these disruptions
have caused. The survey department has been briefed on the appropriate
procedures to be followed for any future surveys in order to avoid a
recurrence in the future.

Mick Houlahan


Cheer,
Steve

Tales from the post office .01

Once up on a time an old lady lived by herself in a tidy little cottage, tugged away in a corner of Sydney suburbia. She lived alone after her husband died and her children moved away, spending her last days in solitude, as time ruthlessly chip away at her body, her mind, her memories.


Each day at 10 past 3, the postman would rumble by in his orange safety vest and AusPost issued bike laden with letters. Eagerly our lady (not old lady any more, for old is a such sad word) would wait for communicate from her bloodline, some tenuous link to her once glorious youthful past.


On a post card summer day (blue skies, white clouds, birds in the trees, the works), the postman arrived with clockwork precision at 10 past 3. He bent down from his seat and inserted a letter into post box no. 11 Evergreen Rd. If you were right above him, and the angle just so, I bet you would have seen in his helmet's reflection, our lady dismounting her front porch stairs with great vigour and marching towards that little imitation of a house mounted on a pole. Flashing a big grand-motherly smile at the postman, she bent forward in that stuttering manner that betrays her advancing arthritis and delicately extracts a small white envelope addressed to "My dearest Grand Mother". As the postman rode off to his next appointment our lady walked back to her cottage with her precious letter.


Once inside she placed it carefully on the drawing table and with hands shaking slightly picked up a rarely used letter opener. With precision that comes to all women through a life time of sewing and stitching, she neatly sliced the envelop open and its content came tumbling out. A printed letter with all the usual niceties, sentimental words (generated by a script somewhere on the net), and a not so subtle reminder - "My birthday next week, I am really looking forward to it." With joy in her heart, our lady packed her bag: wallet, jewellery, spare keys, and other stuff old ladies put in their bags (probably pepper spray too, in that day and age). After locking her door she sets off on a 40minute journey to the post office, her mind's eye saw a face vaguely remembered from obligatory family functions, made handsome and adorable by time's passage (with a disturbing resemblance to her dead husband when he was young).


A slightly fluttered and out of breath is how we found our lady when she arrived at the post office, cheeks flushed with a healthy glow, one outshone by the glow of her eyes. After waiting in line, she was finally served. A few short minutes later a carefully made money order was ready, a card selected with great consideration and finally a package of adoration and love was made and sent on its way across the land. Bursting with ecstasy of her accomplishment our lady starts her long trek home, every one she encountered a receiver of her smile.


The post office lady looked on with great sadness and helplessness at her departing back as it vanishes into the harsh glare of the afternoon sun. For the 4th time in 2 month, she helped our lady craft her packets of affection destined to the same grand child.

2004-11-17

501 years from now

A new star will be born in the sky. An incandescent flare of rainbow colors shall crown its descend from amongst the stars. Its birth shall herald not the second coming of Christ, but messages from the past.

Welcome home KEO.

KEO is a time capsule for all of humanity. It is designed to take a snap shot of where humanity stands now, our culture, our dreams, our knowledge. 501 years from now, roughly the time it took modern civilisation to evolve, it shall come back to Earth as its orbit decays, to provide our great-great-great-great-great-children a treasured and diverse glimpse back into a critical moment in humanity's history.

Every one is invited to store a message. Only then can KEO provide a complete picture of the state of humanity, across a range of incomes, background, religion, political alignment, tv-show fandom, geological location, the list goes on. When KEO is opened by our descendents, it will contain sufficient data for them to fully appreciate who we are: human beings trying to do what is right.

Regardless of who you are, I implore you to act now. Entry for messages closes soon, so don't miss out on this once in a life time opportunity. Who knows, one day your descendents might read your message :)

If you have no idea what to write, then write about your dreams and aspirations. For what reveals better who we are then what we strive to achieve? It defines our life, for it drives it.

Picture of the day

I finished all my exams today, so I am now FREE!!!!!!! I was going to make a post about it, but decided not to. In the course of finding a suitable link however, I came across this:



Get well soon emma! :*)

Cheers,
Steve