Lectures about Gödel Escher and Bach

July 7, 2009 by Ettore

Here, they’re free and they look nice :)

UNIX Network Programming by Stevens

July 6, 2009 by chris

UNIX Network Programming Volume 1, Third Edition: The Sockets Networking API
by W. Richard Stevens; Bill Fenner; Andrew M. Rudoff

can be found online at safari books.

in addition:

just realised that it is not the complete version, just previews. sorry!

Profiling Code Using clock_gettime

July 6, 2009 by chris

Find a good explanation here written by Guy Rutenberg.

Set Thunderbird to use Gmail’s Trash folder

March 31, 2009 by chris

Sorting all my mail the other day, I realised that Gmail still keeps a copy of every email in the “All Mail” folder. Only if the messages are moved to Gmail’s “Trash” folder, they are eventually deleted. This cannot be set in Thunderbird directly afaik. Here is what you have to do.

sed one-liners

March 24, 2009 by chris

Handy one-liners for UNIX stream editor sed.

Replacing text in XSL, the dirty way

February 24, 2009 by beppe

Here the example replaces quotes with escaped quotes \”, but can be generalized.

First define a template:

<xsl:template name="cleanQuote">
<xsl:param name="string" />
<xsl:if test="contains($string, '"')">
<xsl:value-of select="substring-before($string, '"')" /> \"
<xsl:call-template name="cleanQuote">
<xsl:with-param name="string">
<xsl:value-of select="substring-after($string, '"')" />
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="not(contains($string, '"'))">
<xsl:value-of select="$string" />
</xsl:if>
</xsl:template>

Then use it at the appropriate point by calling:


<xsl:call-template name="cleanQuote">
<xsl:with-param name="string">
<xsl:value-of select="text" />
</xsl:with-param>
</xsl:call-template>

Statistics Textbook Online

February 19, 2009 by chris

This might be useful.

How do I read a huge file line by line in Python?

February 4, 2009 by chris

This is taken from here and was written by rupe.

In Python, the most common way to read lines from a file is to do the following:

for line in open('myfile','r').readlines():
do_something(line)

When this is done, however, the readlines() function loads the entire file into memory as it runs. A better approach for large files is to use the fileinput module, as follows:

import fileinput
for line in fileinput.input(['myfile']):
do_something(line)

the fileinput.input() call reads lines sequentially, but doesn’t keep them in memory after they’ve been read.

scp file completion on remote host.

November 21, 2008 by agreenhalgh

Next time you try to scp a file to or from a remote host, try and see if autocompletion is support in the same way it works for cp. You probably need to have ssh keys setup and an ssh agent running.

e.g. scp host.example.com:<press tab tab to autocomplete and see a list of time>

Using ssh forwarding to retrieve papers instead of VPN

November 5, 2008 by Ettore

So far I was using VPN to connect to my university network when I needed to download a paper from home, but that meant to temporarily lose my network connection, with all the hassle attached.

Today I discovered a much simpler method:

1) Open a ssh port forwarding to the remote machine (university server with IEEE or ACM subscription) in this way:

ssh -D 8080 -N <username>@<server address> &

where -D indicated the local port to forward, and -N avoid opening a shell.

2) Download the FoxyProxy Firefox extension, and configure in order to use a proxy on localhost:8080.

3) Add rules to FoxyProxy so that the proxy is active only when needed (*.ieee.*, *.acm.* etc…).

Thanks to Timo Reimann for having suggested that.