setting up geeklets on Mac OS X

GeekTool is an application for Mac OS X (Snow Leopard onwards), which lets you display various kinds of information on your desktop via 3 default plug-ins.

geektool

Similar desktop customization tool are available for Ubuntu (Conky) and Windows (Rainmeter)

You can install GeekTool from AppStore and then create your own geeklets or get them from internet. In this post I am putting up some very basic geeklets but that is all I want. Too much information tends to be distracting.
(more…)

installing ImageMagick

ImageMagick is one of the best tools to have, especially if you blog. It lets you manipulate images (resize, convert, …) in batch from command line.

On Mac OS X it is available as part of Mac Ports. Simplest way to install Image-Magick is to install Mac Ports using installers for respective version of Mac OS X. Installer will take care of adding directories to various relevant path environment variables.

Once installed open terminal and fire these commands:

sudo port selfupdate
port search ImageMagick
sudo port install ImageMagick @6.8.5-5

It will figure out the dependencies and install the tools appropriately in /opt/local directory.

little-endian

Found this interesting piece of information about why accidentally intel chips are little-endian:

The ia32 is a little-endian architecture. When a chip is designed the choice between these two possibilities is pretty much arbitrary. In the case of the ia32, the decision was forced by considerations of compatibility, since all previous Intel chips are also little-endian, and Intel did not want to have incompatible data layouts between different chips, because otherwise transition from one chip to another would be more complicated. If you trace the history of Intel chips ( ww.i-probe.com/i-probe/ip_intel.html has a nice account of this history), the very original chip was the 4004. The 4004 was little-endian, because it was the product of a research project which aimed to show that a single chip could duplicate the capabilities of an existing computer. The computer chosen happened to be little-endian, and the reason for that was interesting. This was from the early days of computing (over forty years ago), and the machine they were copying had delay line memories. This memory technology basically stores data on a rotary electronic device very much like a hard disk, in that you have to wait for the data stream to rotate till you can access the byte you want. When you are doing multi-byte additions, it is convenient to access the least significant byte first, so that you can propagate carries to more significant bytes. This makes a little endian arrangement more efficient, since otherwise you would have to wait a rotation between bytes.

Source

generating stack traces on UNIX/Linux systems

This is follow up on the previous post for generating stack trace. The code demonstrated earlier holds good for both Linux & Mac OS X. However retrieving filename and line numbers is non-trivial. There is no API that can do it. But it’s hackable.

Here are few ways of doing it:

  1. use addr2line for each address and fetch information, this is overkill as for each frame you will have to execute a process
  2. code up something similar to addr2line, but Licenses spoil the party. It’s either GPL or APSL. Both are not permissive licenses
  3. Look at what LLDB does, but it has it’s own engine and assumes you are debugging, which you may be not
  4. Find and read the symbol files. This for sure will be better that others in terms of performance, but then you have to deal with whole lot of debug binary formats (a.out, STABS, DWARF and what not)

For now I am going to stick with what I have for now, it gives me library and function name with offset. Implementing same on windows is relatively easy (maybe a post on that later).