Te hard gewerkt vandaag, pas nu lwn.net lezen...
Tweets of June 30 2010
Warm welkom voetballers Noord Korea: http://tinyurl.com/2cz7l4c Warm lood wrs
Wed Jun 30 10:08:59 +0000 2010
Replying to @danielaukes
je moet gewoon veel drinken, dan komt het wel goed
Wed Jun 30 12:24:21 +0000 2010
En toen was het officieel: per 1 sept treed ik in dienst bij SIDN. Jeuh!
Wed Jun 30 14:28:47 +0000 2010
\(even algemeen\) dank. Ja, ik ga met DNSSEC pielen, maar ook nog \(veel\) andere zaken. DNSSEC is toch al bijna af :P
Go Book Building
I’m still “writing a Go Book” which boils down to playing with
, Go
and Vim.
Building the whole document might be a bit tricky, because of all the packages you may need.
Assuming you already installed TexLive on your system, you will
further need to apt-get install:
texlive-xetexttf-droidlatex-cjk-commonlatex-cjk-japanese-wadalablatex-cjk-xcjklatex-xft-fontslatex-fonts-recommendedttf-sazanami-gothicinkscape(for.svgto.pdfconversion)
Which should make it build. If not, please let me know.
Fuzzy fonts in Chromium Browser Under Linux
I did a small upgrade to the newest version of Chromium and all of the sudden the fonts in the browser area were all blurry and fuzzy…
After some searching it turned out that WebKit (which Chromium uses for
the rendering) uses the settings from font-config instead of the whatever
you click inside your DE’s configuration tools.
% fc-match -v Arial | egrep 'family|hint'
family: "Arial"(s)
familylang: "en"(s)
hintstyle: 1(i)(w) <- '1' means slight hinting
hinting: FcTrue(w)
autohint: FcFalse(s)
And to remedy the situation:
Remember text in LaTeX
After reading the Android Book from O’Reilly I saw some nice use
of bullets alongside source code which allowed for extra explanation to
be given after the code. I thought only one thing: I want to use that
too, but then in
.
After fiddling around for an evening it finally looked like this:
There are two ways you can do this. The easy way is to write a few macros which create numbered bullets in the code and then use these numbers manually after the code to add your explanation. There are however problems with this approach; You need to manually keep the numbers in sync and thus it distracts you from focussing on the text.
Tweets of May 31 2010
In ubuntu 10.04 gebruikt openoffice nog steeds z’n eigen print dialog... Geef mijn maar Abiword
Mon May 31 20:45:33 +0000 2010
@snavaes eet morgen niet mee. Nu dus een dilemma. Friet of Chinees?
Go Book
I’m writing a book about Go. It is very much a work-in-progress, but I just wanted to mention this work and publish a snapshot. The aim is to explain Go and to provide many (many) exercises (and answers) so people may learn this wonderful language.
It is written using
(of course), see
gitweb for the code.
Help is appreciated. The pdf of today (aka daily build) can be
found here.
The title page looks like this:

Tweets of April 30 2010
Dronken in #Utrecht, altijd goed
Fri Apr 30 16:55:07 +0000 2010
Op weg naar huis, misschien nog een biertje in de voortuin
Tweets of March 31 2010
@gielium heel soms gezien, maar dat was met oude versie. Zou nu \(6\.30\.x\) gewoon moeten werken
Hibernate and suspend with Ubuntu 9.10
I have an Asus EeePC on which I’ve installed Ubuntu 9.10. But now I wanted a working hibernate (suspend to disk) and suspend (suspend to memory).
Hibernate was working out of the box (well the going to sleep part, at least), but resuming took almost as long as a cold boot. Another thing was that my wireless was broken after a resume. On my happiness scale (range: 0-10) this scored a 3.
Tweets of February 28 2010
@digiplace heh :) Ik ga nu precies hetzelfde doen. Op naar de kelder!
Sun Feb 28 14:11:50 +0000 2010
Goed nog 100G backuppen en ik kan beginnen met installeren
Sun Feb 28 15:21:07 +0000 2010
Hmmm, zo weer ff de single user mode in om /home ext4 te maken en dan weer alles fixen \(kerberos, ldap, etc\)
Sun Feb 28 17:16:28 +0000 2010
Tip: maak een text dump van je ldap database als je van 32 bit naar 64 bit upgrade
Ubuntu Lucid Alpha-3
I want to upgrade my server to the new Ubuntu and switch to 64 bit on my main server. This is how I managed to get Ubuntu Lucid (Alpha 3) running on my (test) machine, with RAID1 + BTRFS and 64 bit. It is a running story on how I spend my Saturday afternoon, you might need some decent Linux knowledge to follow my lead.
Here we go.
The following lists sums up my needs and troubles:
LaTeX Nirvana
I’m no fan of Word or OpenOffice for that matter, all that WYSIWYG stuff is not for me. For years now I’m using LaTeX for my editing needs. An added bonus for using LaTeX is that the output is stunning.
But for really nice looking output I wanted the following:
- Fonts in images/graphics should match the font of the main document
- TrueType fonts, instead of the standard TeX fonts. To avoid the “Heeh, that looks like a LaTeX document”-reactions;
- UTF-8 support and international character support;
- Easy integration of images (SVG based);
- Automatic building.
I’m using the following tools for this:
Tweets of January 31 2010
’t was ff pielen, maar nu heb ik een mooie LaTeX mal voor Go, nu dan het moeilijkste: content
Sun Jan 31 11:41:05 +0000 2010
met fdisk /dev/sda kijken of je uberhaupt nog Windows hebt, maar die is dus echt weg \(dan maar geen HTC rom flash\)
Sun Jan 31 12:51:30 +0000 2010
redelijk in mijn nopjes met de layout: http://tinyurl.com/yezh73l
Sun Jan 31 15:39:24 +0000 2010
Fout gemaakt door 24 te gaan kijken
Go tutorial in Dutch
During the last few weeks I’ve attempted to translate the Go tutorial to Dutch. This was a lot more work than anticipated and I’m still not finished, but I just wanted to share what I’ve got up to now.
You can get the text version here.
Things do
- Finish translating the last few paragraphs;
- Proof read;
- Spell check;
- Update it to the latest Go release;
- Get this included in Go?
upstart and booting with init=/bin/bash
One of the oldest tricks in the sys admin’s arsenal is
booting with init=/bin/bash. You’ll need this when
you want to reset the password for root for instance.
It used to go like this: Boot with init=/bin/bash and
after some time you greeted with a prompt ala
root@(none):/#
Most often I then took the following steps:
mount -o rw,remount /
/etc/init.d/networking start
Now you also have networking, so you may upgrade the
system with apt-get or whatever… You are now a
happy puppy.
My f() function in Zsh (and maybe Bash)
Familiar with the following?
You are aware of (shell)file which contains a interesting line and you think: “I want to execute this line on the command prompt”. Most people will do the following:
% more <file>
[select interesting bit with your mouse]
[paste]<enter>
And the code gets executed.
I propose the following function: f(), which does the following:
- It opens the file in $EDITOR (:=
vimof course); - You delete everything you don’t want to execute;
- What’s left gets executed;
- And it is added to your shell’s history.
The code of the function looks like this:
map function in Go
There is better stuff in the standard Go release but I wanted to try
something for myself. In Go, this function is also called Map(), but is
(of course) nicer. Anyhow, I’m liking this Go stuff more and more. Next I
want to rewrite the DNS stuff in Go.
package main
import (
"fmt"
)
type e interface{}
func mult2(f e) e {
switch f.(type) {
case int:
return f.(int) * 2
case string:
return f.(string) + f.(string)
}
return f
}
func Map(n []e, f func(e) e) {
for k, v := range n {
n[k] = f(v)
}
}
func main() {
m := [...]e{1, 2, 3, 4}
s := [...]e{"a", "b", "c", "d"}
Map(&m, mult2)
Map(&s, mult2)
fmt.Printf("%v\n", m)
fmt.Printf("%v\n", s)
}
Tweets of December 29 2009
morgen nog lekker niksen en dan overmorgen naar huis
Inotify
This is a translation from this article which is published in Dutch
During our work at Octrooicentrum Nederland somebody came up with the following question. During the night a file was created in a directory and he wanted to know who (which process) was responsible for that. My first reaction was: “Can’t be done”.
However, that evening I thought of inotify which could be of help.
With inotify you can watch your file system
and get notified when “something” (read, write, create, etc.)
happens. For (much) more detailed information look in inotify(7).
Tweets of November 29 2009
PS3 met modern warfare gekocht. VET!!
Prime sieve (in Go ofcourse)
After reading up on the prime sieve, and playing with Go for the past week I thought needed to implement this algorithm in Go and make it parallel.
I want to create a set (n in 2..N) goroutines. Each of these routines will check if it can divide a number (i) by n (integer division). If so the number i is not prime, otherwise it is given to the next goroutine. Communication between the goroutines is done via channels as in this example.
More Go
Still learning and playing with Go, I’ve
rewritten my
cat experiment, to
use a *bufio.Reader, which is more correct I think. I’m also slowly
wrapping my mind around the concept of
Interfaces. As a
non-OO programmer (C and non-OO Perl) is starting to see why this is
useful.
So today’s exercises:
- Write a cat implementation in Go. See below.
- Write a grep implementation in Go. See below.
Cat in go
package main
// A implementation of cat in Go
import (
"os";
"fmt";
"bufio";
"flag";
)
var numberFlag = flag.Bool("n", false, "number each line")
func cat(r *bufio.Reader) bool {
i := 1;
for {
buf, e := r.ReadBytes('\n');
if e == os.EOF {
break
}
if *numberFlag {
fmt.Fprintf(os.Stdout, "%5d %s", i, buf);
i++
} else {
fmt.Fprintf(os.Stdout, "%s", buf)
}
}
return true;
}
func main() {
flag.Parse();
if flag.NArg() == 0 {
cat(bufio.NewReader(os.Stdin))
}
for i := 0; i < flag.NArg(); i++ {
f, e := os.Open(flag.Arg(i), os.O_RDONLY, 0);
if e != nil {
fmt.Fprintf(os.Stderr, "%s: error reading from %s: %s\n",
os.Args[0], flag.Arg(i), e.String());
continue;
}
if !cat(bufio.NewReader(f)) {
os.Exit(1)
}
}
}
Grep in go
package main
// A implementation of Unix grep in Go
// TODO(mg) better error handling
import (
"os";
"fmt";
"bufio";
"regexp";
"flag";
)
var numberFlag = flag.Bool("n", false, "number each line")
var filenameFlag = flag.Bool("l", false, "print names of matching files")
func grep(r *bufio.Reader, reg string) (match bool) {
i := 0;
for {
buf, e := r.ReadBytes('\n');
i++;
if e == os.EOF {
break
}
if m, _ := regexp.Match(reg, buf); m == true {
match = true;
if *filenameFlag {
return match
}
if *numberFlag {
fmt.Fprintf(os.Stdout, "%5.d: %s", i, buf)
} else {
fmt.Fprintf(os.Stdout, "%s", buf)
}
}
}
return match;
}
func main() {
flag.Parse();
if flag.NArg() < 1 {
fmt.Fprintf(os.Stderr, "%s: missing regexp\n", os.Args[0]);
os.Exit(1);
}
if flag.NArg() == 1 {
if grep(bufio.NewReader(os.Stdin), flag.Arg(0)) {
if *filenameFlag {
fmt.Fprintf(os.Stdout, "(standard input)\n");
}
}
}
for i := 1; i < flag.NArg(); i++ {
f, e := os.Open(flag.Arg(i), os.O_RDONLY, 0);
if e != nil {
fmt.Fprintf(os.Stderr, "%s: error reading from %s: %s\n",
os.Args[0], flag.Arg(i), e.String());
continue;
}
if grep(bufio.NewReader(f), flag.Arg(0)) {
if *filenameFlag {
fmt.Fprintf(os.Stdout, "%s\n", flag.Arg(i))
}
}
}
}
cat in Go
After spending every free minute to Go I’m starting to get a feel
for the language. Every one has to start somewhere, so I decided to
“port” Unix utils to Go. I’m starting with cat, and thanks to
the Go tutorial this is the result.
package main
// An implementation of Unix cat in Go
import (
"os";
"fmt";
"flag";
)
func cat(filename string) bool {
const NBUF = 512;
var buf [NBUF]byte;
if f, e := os.Open(filename, os.O_RDONLY, 0); e != nil {
fmt.Fprintf(os.Stderr, "cat: error reading from %s: %s\n",
filename, e.String());
return true;
} else {
for {
switch nr, _ := f.Read(&buf); true {
case nr < 0:
os.Exit(1)
case nr == 0: // EOF
return true
case nr > 0:
if nw, ew := os.Stdout.Write(buf[0:nr]); nw != nr {
fmt.Fprintf(os.Stderr,
"cat: error writing from %s: %s\n",
filename, ew.String());
return false;
}
}
}
}
return true;
}
func main() {
flag.Parse(); // implement -n TODO
if flag.NArg() == 0 {
cat("/dev/stdin")
}
for i := 0; i < flag.NArg(); i++ {
if !cat(flag.Arg(i)) {
os.Exit(1)
}
}
}
In something like 50 lines you have a cat program. I’m really starting
to like Go. Next up: extra features and a grep command.
First steps with Go
I joined the go-nuts mailing list a few days ago and it really feels good to receive 200+ emails per day again. Just like in the good old days before good spam filtering (and anti-spam laws).
I also re-watched the presentation Rob Pike gave for Google Tech Talks
on youtube.com. In there he presented the following program chain.go:
(Formatted with gofmt as it should)
package main
import (
"flag";
"fmt";
)
var ngoroutine = flag.Int("n", 100000, "how may")
func f(left, right chan int) { left <- 1+<-right }
func main() {
flag.Parse();
leftmost := make(chan int);
var left, right chan int = nil, leftmost;
for i := 0; i < *ngoroutine; i++ {
left, right = right, make(chan int);
go f(left, right);
}
right <- 0; // bang!
x := <-leftmost; // wait for completion
fmt.Println(x); // 100000
}
In this short program we make a chain of 100000 goroutines which are connected to each other. Each one adds 1 to the value it gets from its right neighbor. We start it of by giving the last one (right) a value of 0. Then we wait until they are finished and print it.
Go language
I’ve been wanting to learn (and do something) with the language
Erlang for over two years now. But every time
I fire up vim and start typing a get a this-is-not-Unix feeling (aka
Java-sickness). The syntax is just not right for me.
But now Google, by the creators of Unix and C, give us Go! Which promises to give us Erlang functionality in a C-like language. Just what I wanted!
Basically just follow the steps on golang.org. In short it boils down to: