Five minutes ago, I overwritten the super-shining-new CSS stylesheet that implements the current color scheme, because i wanted to restore the original one and put it in a new theme for this site, so that people who enjoyed the old theme could continue to use it. But, as the most kiddiest system administrator, i uncompressed the original files from the backup archive OVER the current ones..

Safari to the rescue! Every cached item by safari is stored into a SQlite3 database located in ~/Library/Caches/, let’s inspect how it is structured:

 13:54:42 vjt@voyager:~/Library/Caches/$ sqlite3 Cache.db 
SQLite version 3.5.1
Enter ".help" for instructions

sqlite> .tables
cfurl_cache_blob_data       cfurl_cache_schema_version

sqlite> .schema cfurl_cache_response 
CREATE TABLE cfurl_cache_response(
  version INTEGER,
  hash_value INTEGER,
  storage_policy INTEGER,
  request_key TEXT UNIQUE,

sqlite> .schema cfurl_cache_blob_data
CREATE TABLE cfurl_cache_blob_data(
  response_object BLOB,
  request_object BLOB,
  receiver_data BLOB,
  proto_props BLOB,
  user_info BLOB);

sqlite> select * from cfurl_cache_response limit 3;
1|0|1897220634|0|http://..../|2008-01-19 11:10:33
2|0|-662909776|0|http://..../|2008-01-19 11:10:33

Wow. Impressive. That’s why i love Apple products, because they are so well structured that you can freely inspect them and use them and their resources for every unplanned task you could have to complete.. even to fix your own mistakes ;). And it’s also intriguing, because you have to scratch your own itch and find the solution while exploring a beautifully constructed software product.

To make a long story short, every cached URL is stored into the request_key field of the cfurl_cache_response table, while in the receiver_data field of the cfurl_cache_blob_data there is the actual cached data. Now we can look for the overwritten bbs theme CSS stylesheet:

sqlite> select entry_ID, request_key from cfurl_cache_response
   ...> where request_key like '%bbs/style.css';

Now, let’s search in the blob_data table the entry with ID 1950:

sqlite> select receiver_data from cfurl_cache_blob_data
   ...> where entry_ID = 1950;
 * Themetastic, for Drupal 5.0
 * Stefan Nagtegaal, iStyledThis [dot] nl
 * Steven Wittens, acko [dot] net`
 * If you use a customized color scheme, you must regenerate it after
 * modifying this file.
[ of the stylesheet removed.....]

YAY! Found it! A quick cut&paste.. and the lost theme is back! :D

05:01:24 vjt@voyager:~/Antani/trunk$ replace(){ sed -e "s|$1|$2|g" 
< $3 > ${3}X; mv ${3}X $3; }; egrep -r 'XP_[A-Z_]+[[:space:]]+-?[[
:digit:]]' Headers |ruby -ne "f,m=scan(/(.+):.+(XP_[\w_]+)/).first
;puts '%s %s %s' % [ f, m, 'kXP'<<m.scan(/(_[A-Z])([A-Z]+)/).map {
|a,b| a[1..1]<<b. downcase }.join ]" | while read hdr from to; do
replace $from $to $hdr; for src in `grep -rl $from Sources`; do
replace $from $to $src; done; done
  • You must have PTH installed, and maybe other libs.
  • This was tested on SCO_SV os507 3.2 5.0.7 i386

If you have UDK, run:

$ CFLAGS='-I/usr/local/include -belf' LDFLAGS='-L/usr/local/lib' \
  ./configure --with-threads --with-pth --disable-shared --disable-ipv6
  • Add /usr/local/include to BASECFLAGS in Makefile (autocrap sucks).
  • Patch Modules/ctypes/_ctypes_test.c by putting an #ifdef HAVE_LONG_LONG around functions that use PY_LONG_LONG (hints: lines 384 and 318).
  • Patch Objects/longobject.c and on line 817 put the IS_LITTLE_ENDIAN macro before the #ifdef HAVE_LONG_LONG block, and put _PyLong_FromSsize_t and _PyLong_FromSize_t after the HAVE_LONG_LONG block.

If you have GCC, run:

$ CFLAGS='-I/usr/local/include' LDFLAGS='-L/usr/local/lib'            \
  ./configure --with-threads --with-pth --disable-shared --disable-ipv6

Either with UDK or GCC:

  • Edit pyconfig.h and comment out the socklen_t define
  • Edit Modules/socketmodule.c and on line 226 add || defined(SCO5) in order to define INET_ADDRSTRLEN.
  • Run make (or gmake if you wish)
  • You will be left without,, and if using GCC and also pyexpat, elementtree and sha512 if using UDK.
      __   ____  __ __  ____     __
      \ \ / /  \/  |  \/  \ \   / /
       \ V /| |\/| | |\/| |\ \ / / 
        | | | |  | | |  | | \ V /_ 
        |_| |_|  |_|_|  |_|  \_/(_)
[vjt@os507 ~/Python-2.5.1-vjt] $ python
Python 2.5.1 (r251:31337, Sep 13 2007, 22:40:33) 
[GCC 4.2.1] on sco_sv3
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
[vjt@os507 ~] $ hg clone http://code.wuhrer.thc/hg/Antani
destination directory: Antani
http authorization required

!! YAY! :D

Novel logo

A really, really, really NERD novel by Cory Doctorow that tells about a bunch of sysadmins that strive to keep the good ol’ Net online after a catastrophic event that brought the entire world to its knees. They fight with scarce power and food supplies and communicate over the Usenet… using the good old alt. hierarchy.

Vote: 10+ for the geekiest thing I’ve ever read. It’s really worth the hour needed to read it completely. Enjoy it