Active Gibberish

📜

This post was written in 2008. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
The Gibberish plugin and this entire approach are long dead. Rails 2.2 (2008) added built-in I18n support, and since Rails 3 the standard way is config/locales/*.yml with the i18n gem. ActiveRecord error messages, field names, and all UI strings are handled natively — no plugins, no monkey-patching.

UPDATE: you don’t need this code, because starting from the 2.2 version of Rails, localization support is built-in.

Localization for Active Record error messages

Today I had to answer one of the questions every non-English Rails developer stumbles upon sooner or later.. how to localize AR error messages for pleasant appearance to a non-english customer ;).

First off, thanks to defunkt’s excellent gibberish plugin and to the way AR validation errors are exposed, the task was accomplished in an easy and clean manner, without messing too much with AR’s internals.

I started by translating every default AR error message, with this translation file located in lang/it.yml:

# Active Record errors
#
ar_accepted:     "deve essere accettato" 
ar_not_a_number: "non è un numero" 
ar_blank:        "è un campo obbligatorio" 
ar_empty:        "è un campo obbligatorio" 
ar_inclusion:    "non è nella lista dei valori validi" 
ar_too_long:     "è troppo lungo (massimo %d caratteri)" 
ar_exclusion:    "è riservato" 
ar_too_short:    "è troppo corto (minimo %d caratteri)" 
ar_invalid:      "non è valido" 
ar_wrong_length: "è errato, dovrebbe essere di %d caratteri" 
ar_confirmation: "non corrisponde" 
ar_taken:        "esiste già" 
# This one is not a default key, but I use it in my validations
ar_greater_zero: "deve essere maggiore di zero" 

and four lines in config/environment.rb:

Gibberish.current_language = :it
ActiveRecord::Errors.default_error_messages =
  ActiveRecord::Errors.default_error_messages.inject({}) {|h, (key, string)|
    h.update(key => string["ar_#{key}".intern]) # <em>Gibberish magic</em>
}

The first one simply sets Italian (:it) as the default language, the inject builds a new error_messages hash using Gibberish to translate the default ones. I named every AR error key in my translation file with an “ar_” prefix, in order to avoid possible future key clashes. Finally, AR array is overwritten with the new one freshly built.

Extracting data from Apple Safari's cache

📜

This post was written in 2008. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
Safari abandoned this SQLite cache format years ago. Since roughly Safari 10 / macOS Sierra (2016), the cache moved to com.apple.WebKit.Networking in a binary blob format — the old Cache.db no longer exists.

Five minutes ago, I overwrote 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 kiddie 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/com.apple.Safari, let’s inspect how it is structured:

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

sqlite> .tables
cfurl_cache_blob_data       cfurl_cache_schema_version
cfurl_cache_response      

sqlite> .schema cfurl_cache_response 
CREATE TABLE cfurl_cache_response(
  entry_ID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  version INTEGER,
  hash_value INTEGER,
  storage_policy INTEGER,
  request_key TEXT UNIQUE,
  time_stamp NOT NULL DEFAULT CURRENT_TIMESTAMP);

sqlite> .schema cfurl_cache_blob_data
CREATE TABLE cfurl_cache_blob_data(
  entry_ID INTEGER PRIMARY KEY,
  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.

Today's row

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

How to compile python2.5 on SCO_SV

📜

This post was written in 2008. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
Both Python 2.5 (EOL 2011) and SCO OpenServer are extinct. SCO/Xinuos went bankrupt, and Python 2 itself reached end-of-life in January 2020. This is a digital fossil.
  • 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 _curses.so, _curses_panel.so, _locale.so and readline.so 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

📜

This post was written in 2007. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
Ruby 1.9 reached end-of-life in 2015. Ruby is now at 3.x, and Symbol.all_symbols no longer includes this easter egg — it was removed long ago. The answer to life, the universe, and everything remains 42.
22:33:24 vjt@voyager:~$ irb19 -f
irb(main):001:0> Symbol.all_symbols.grep /^the/
=> [:the_answer_to_life_the_universe_and_everything]

unluckily, the answer isn’t 42:

irb(main):002:0> _.first.object_id
=> 5048

:\

Thanks for this strange finding, nextie! :D

When Sysadmins Ruled the Earth

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.

📜

This post was written in 2007. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
Apple added native SMB-based Time Machine support in macOS High Sierra (2017) and deprecated AFP in Big Sur (2020). Today any NAS with a plain Samba share works out of the box — no Netatalk, Avahi or marker files needed. Time Capsule was discontinued in 2018.

Ingredients: Debian, Netatalk, Avahi, some trickery.

Step 1: Recompile Netatalk with SSL Support

Recompile Netatalk with SSL Support.

You can safely ignore the “.passwd” stuff, because afpd uses PAM for user authentication.

Hint: Disable the atalk protocol handlers in /etc/default/netatalk for a faster startup:

# Set which daemons to run (papd is dependent upon atalkd):
ATALKD_RUN=no        # appletalk protocol
PAPD_RUN=no          # printer sharing daemon (printers are soooo '90s)
CNID_METAD_RUN=yes   # don't remember but is needed, rtfm!
AFPD_RUN=yes         # you will always need this
TIMELORD_RUN=no      # my time lord's name is <a href="http://openntpd.org">openntpd</a>
A2BOOT_RUN=no        # boot? nah! :P

Step 2: Create a share for time machine backup data, by adding e.g.

# path         name           perms     charset
/some/where/tm "Time Machine" allow:vjt volcharset:"UTF8" 

into /etc/netatalk/AppleVolumes.default.

Step 3: Let the AFPD server show up in finder

Download the avahi service file, put it into /etc/avahi/services and reload avahi with /etc/init.d/avahi-daemon reload (sorry, original links are broken).

Step 4: Set Up Time Machine Backup

You need two files on your afp network share: .com.apple.timemachine.supported and a dot-file named with your en0 MAC address. To create it, the easier way is to attach an USB/Firewire disk, rename it with the name of the intended network share (specified in the AppleVolumes file) and enable time machine on it.

Sux Services 0.2.8

📜

This post was written in 2003. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
Twenty-three years later, I recovered the CVS history from SourceForge — 954 commits, three authors, a continuous trail from September 2002 to November 2005. The full retrospective covers what I built, what I never finished, and why. There’s a companion piece on the Bahamut IRC server fork that this depends on.

So I just tagged 0.2.8 and I think this thing is getting close to usable.

Quick recap for those who don’t know: Sux Services are IRC services I’m writing from scratch in C for the Azzurra IRC Network. The idea is: multithreaded, modular, SQL backend instead of flat files, and not a complete mess to maintain. We’ll see about that last part.

What works right now: NickServ does registration, identification, password change, ghost kill. ChanServ has channel registration, access lists (CF/SOP/AOP/VOP/AKICK) with masks support, and it actually enforces access on join. MemoServ sends and reads memos, notifies you on connect if you have new ones. OperServ has AKILL, server MAP, STATS. There’s even a RootServ for the really scary stuff.

The whole thing connects to a Bahamut IRCd, negotiates the server link, syncs all users and channels, and then the five service agents boot up as virtual users. Modules are compiled as .so files and loaded at runtime via GLib’s GModule. If I want to reload NickServ I just unload and reload the module, no restart needed. Pretty cool.

I’m testing it with netxplode which is a perl script that spawns 100 IRC clients and hammers services with random commands – IDENTIFY, INFO, REGISTER, JOIN, you name it. Basically 100 bots going completely nuts on NickServ and ChanServ at the same time. Found a lot of bugs this way. Also found an SQL injection in the nickname handling last week which was fun. Fixed now, we use sql_printf() to escape everything, but yeah, that could have been bad.


On this page