Month: May 2010

Playing around with RaphaelJS

Recently I stumbled across what I later found out is known as Morley’s trisector theorem.


“Trisect the angles of any triangle and you’ll find an equilateral triangle at its heart.”

A Better Nature

This inspired me to do some javascript coding with the help of RaphaelJS (a very nice crossbrowser graphics library) . It’s been a while since I last wrote any real geometry stuff but I got it in the end.

Start interactive demo for Morley’s trisector theorem.

Links:

Scripting JSON

Doing a lot of web stuff and fiddling around with CouchDB, I really got to like JSON as versatile format for things. Installing the JSONView extension for firefox really helps with working with JSON in the browser, but what I’ve been missing so far is an easy way to deal with JSON from bash scripts. Fiddling around with the very interesting NodeJS, I came up with a small node js script that makes JSON handling much easier, the JSON command: It reads a JSON object from stdin and feeds it to a javascript function body with “v” and NodeJS’ “sys” as parameters. The return value of the function is written to stdout. If it was a string, it is written as-is, if it is another object it will be pretty-JSONified.

Simple Example

$ curl -s http://localhost:5984/test | json "return v;"
{
 "db_name": "test",
 "doc_count": 0,
 "doc_del_count": 0,
 "update_seq": 0,
 "purge_seq": 0,
 "compact_running": false,
 "disk_size": 79,
 "instance_start_time": "1274021449672284",
 "disk_format_version": 5
}

Use curl to fetch the status of CouchDB database “test” from the local CouchDB node and then just pretty print it by returning the implicit value v.

$ curl -s http://localhost:5984/test | json "return v.disk_size;"
79

Just print the disk_size of CouchDB database “test”. You can use all the modern JavaScript functions v8 offers plus the implicit “sys” object that lets you log stuff to stderr or inspect objects. A little script that I find highly useful:

#!/bin/bash
# Delete all jcouchdb test databases
DBS=$(curl -s http://localhost:5984/_all_dbs | \
json 'return v.filter( function(db) { return db.indexOf("jcouchdb") == 0; }).join("\n");')

for i in $DBS
do
 curl -X DELETE http://localhost:5984/$i
done

Filter the list of database to only contain those that start with “jcouchdb”, then loop over them to delete.

Links:

Update: Added “return v;” as default function. now also supports “-h” and “–help”.

Installing Ubuntu 10.04

I was kind of looking forward to the new Ubuntu 10.04 aka Lucid Lynx. New LTS version with promising features and a good occasion to redo my badly partitioned desktop computer. I had not thought of the additional space requirements of a 64 bit Linux, so the partitioned 8GB for the root system were not really enough.

Seeing that the new incompatible MythTV version in 10.04 would require me to do at least my desktop and the mediahub computer in one go, I did not do the install immediately but put it on my TODO list. So my first actual exposure to Ubuntu 10.04 was last week, when I tried to get it installed on my new company laptop.

First their were strange issues with the computer not booting anymore. After some searching I discovered that Grub was creating a /boot/grub/grub.cfg file that was somehow broken, because it kept changing its name every time I listed it from the Grub shell. Suddenly its name would be «grub.cfgw» or even stranger something like «grub.cfg ☺~_.q». The issue could be fixed by booting from the cd in rescue mode, moving the “grub.cfg” to “grub.cfg.bogus” and copying it back. Maybe just touching it would have been enough, too.

But then I was facing hard crashes related to the intel video driver which could just not be fixed. Either randomly or consistently every time I either had an external monitor connected at bootup or connected it afterwards and pressed “Detect monitors”, the laptop would crash hard and needed to be force-shutoff.

I tried finding a way to fix it, tried reverting back to 9.10, changing to newer driver versions, nothing helped. So in the end, I had to give up and give the laptop back to our IT guys.

Bummer.

Given those troubles I was kind of afraid of rolling it out in my local LAN. But it was nearly problem-free. On my desktop computer, the graphics  mode was kind of borked. Linux believed to be correctly displaying a 1680×1050 display while the monitor seemd to disagree and switch to some 1680×900 mode that would cut off the lower part of the desktop. That issue vanished with the proprietary nvidia drivers though. The graphics pad was auto-discovered flawlessly. The only thing that was missing was actually to select the rubber tool for the rubber tip and save that. Since I have two sound cards in the desktop, I blacklisted the driver for the on-board sound-card by creating a /etc/modprobe.d/blacklist-intel-sound.conf with

blacklist snd_hda_intel

to not have to ease audio device configuration. After that only the one correct sound card is visible to Linux and I don’t need to configure ALSA and Pulse etc to use the correct device. Configuring the gnome multi-media and MythTV to use both Pulse Audio solved the issue of MythTV blocking Rhythmbox or Flash from playing sound even in paused mode.

The installation on the Eee Box B202 was also almost trouble free. Initially I had problems with MythTV because I forgot to install the mythtv-database package which led to the database not being created in MySQL (D’oh). Then MySQL wasn’t listening on all IPs (0.0.0.0) because it need to be restarted. The remote control of my DVB-T stick ( TerraTec Cinergy DT USB XS Diversity , newer hardware-rev) needed its usual

options dvb_usb_dib0700 dvb_usb_dib0700_ir_proto=0

which I wrote into a newly created /etc/modprobe.d/terratec-remote.conf.

All in all much less trouble than I feared.

FDP: Hopeless ideologists?

No translation yet.

© 2024 fforw.de

Theme by Anders NorénUp ↑