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.
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!
In Perl you have this:
% perl -e 'print "a" x 5, "\n"' aaaaa With that you can easily create a separator string consisting out of 60 spaces.
I always missed this in my shell - until now.
In Zsh have the following expansion:
l:expr::string1::string2:
Pad the resulting words on the left. Each word will be truncated if required and placed in a field expr characters wide. See zsh.dotsrc.org. There is also a r: variant which operates in the same way.
I’ve told a few times about how to build a library.
But there a some extra things that must be done before you can call yourself a complete librarian.
ID-ing the books you have Storing the information Marking the books Sorting and shelving the books Remembering who borrowed what ID-ing books For this I bought a barcode reader that reads the ISBN number of the book’s backcover. With book_get (Perl code) I can retrieve the author, title, genre and year published from Google.
I wanted to pretty print my labels on my (new) Dymo 400 label writer. All the howtos I found were detailing how to use LaTeX to print a sheet of labels. But I needed some LaTeX-foo to print only one. So /me to the rescue…
My labels are 36mm X 89 mm (Dymo part #99012) after some trial and error and four misprinted labels I came to the following LaTeX code which fits the text on the labels:
Not wanting to miss anything on this short urls business, I’ve implemented something similar in nanoblogger.
How? With a shell script and symlinks, my dear Watson. As with all shell scripting this is probably something you can do drunk.
First I need to get a list of all my articles so that I can link to them. Next I take this permalink address, pipe it through sha1sum, take the last 10 characters and make a symlink from the permalink path and presto: short urls
All these wordpress blogs have a related articles line below the blog entries. Sadly nanoblogger does not have such a capability, so I wrote my own. It’s not a plugin in the nanoblogger sense of the word, it may be possible to rewrite it as a regular plugin, but I do not now how…
So for now a simple shell script, which you can find here.
Usage within a template In your templates you should include the following:
For the past year or so I’ve been trying to learn a new language called Erlang.
I’ve found this nice document, which can be used when learning the language. So here I am on Saturday evening doing some Erlang exercises :-)
Anyhow, I was doing exercise 3.4:
Erlang provides a function lists:append which joins two lists together, implement you own function append that performs the append operation. (Do NOT peek; the answer is given in figure 3.
A colleague of mine had some nice improvements to gitvi.
Right now gitvi can be edited by itself, because the magic sequence $Hash$ is escaped like this
sed -i -e 's/\$[H]ash:.*\$/$H''ash$/' "$base" (This was Ton’s idea)
Some other improvements like a -m MSG switch which allows you to enter a commit message for all files you are editing.
And of course it then also needs to have a -h switch.
Update (200911-08): I’ve stopped using this, because it made the archive generating fail in mysterious ways…
As you might have seen I have now these nice (opinions may vary) “more…” links in my blog. This is done with some JavaScript and shell foo and in this entry I will explain how I did it.
The setup also works with text browsers and people who disable JavaScript. In the latter case you will get the normal nb behavior where you see the entire article.
Basicly these blog items serve as a personal reminder and documentation. Also the code needs to be refactored a bit and some html tags need to be removed from it.
Files needed The following files are needed for this comment system:
comment.php, this is the PHP file the implements everything
nbadmin, a small shell script that implemented the comment moderation (just a mv of the comment to the correct directory)
I’ve implemented a simple comment system in which
there are no user accounts has a preview function once a comment is submitted you cannot edit it anymore all comments are moderated a small set of BB tags are allowed implemented as one PHP file the PHP script has some html in it needs a writeable directory in your document root You need this file: comment.php.
The first few lines allow for some customization:
I’ve been thinking about comments on my blog ever since I started using nanoblogger. While nb is great (with VIM and markdown) I’m starting to miss the comment stuff.
Comment systems for nb I’ve been searching for a good comment system that I want to use for nb. It should meet the following criteria:
Simple moderation system. With all the spam nowadays every comment made should be moderated. Should not require a database, the filesystem is enough of a database to handle these tasks.
Or how to create new builtins for use in bash. Short answer: you can, but it is not enabled by default (at least on my distribution, Ubuntu)
This is also something that is done much better in zsh.
Why do want this? SPEED!
Shell scripting is a very easy way to program, but forking all these helper programs takes a lot of time. So one way to speed up your shell program is to load these programs into the shell and making them a builtin.
I’ve written quite a few LaTeX documents during the last few years, but only recently I’m starting to discover very powerful new packages, like memoir and xelatex.
So I just wanted to share my “new” way of writing LaTeX docs.
First read the memoir class documentation. And the fontspec doc.
preamble This now looks like
\documentclass{memoir} \usepackage{eurosym} %% for the EURO \usepackage{fontspec} \usepackage{xltrxta} %% \XeTeX if you need it Usually this is hidden in one of my class files which implement a new look for a document.
Steps:
Read: How to use nice fonts in LaTeX
Install the software:
sudo apt-get install texlive-xetex
sudo apt-get install lcdf-typetools
The latter one is needed for otfinfo to determine the font family name.
Read /usr/share/doc/texlive-doc/xetex/XeTeX-reference.pdf
Use xelatex to create the pdf of your LaTeX documents
If you get the following error install the package lmodern
LaTeX Error: File `lmodern.sty' not found. Finally I can use truetype fonts in my LaTeX documentation.
I had this small problem, how to you check if a directory is empty in the shell? Suppose I want to do
cmd po/* this fails, if the po directory is empty, which in turn makes my compile barf, but that is another story. I needed something to would check the emptiness of the directory, and if it is not empty perform the command, otherwise it skip it.
The trick here is to remember that if a shell wildcard can not be expanded it will be left alone.
I’ve made a small plugin which generates a tag cloud for your nb style blog. It’s probably a bit rough aroudn the edges, but it works, as you can see on the right.
You can fetch it here.
I’m using the gallery plugin for the photos on this site. This plugin works great and easy, but there wasn’t an easy way to create a slide show. So that you can click ’next’ and go to the next photo. So I’ve added this functionality to the script.
I’m putting this up for download, so that other people may use this too. gallery.sh If you want to regenerate the slides, you can just remove the html and slides directories.