onsdag 28 januari 2009

Myror är arkitekter

Fantastisk video som visar hur någon hällt cement i ett myrbo för att se hur gångarna ser ut.


null - Watch more free videos

Running apt-get through ssh SOCKS proxy using tsocks

I had to update two debian servers behind a firewall which allowed outgoing ssh connections but only allowed http (and ftp) access via a proxy with a username/password I did not have access to.

The problem was solved with tsocks and requires an ssh server working normally.
Let the ssh server be ssh.server.com and the host behind the firewall be called "host".
Regular syntax with
hostname$command

meaning I run command on host hostname is used. The guide is for debian but works similarily for other distributions.

Install tsock on the host, if not done already.
This might be a chicken-and-egg problem because in order to install it you may need to download it which is not possible because you are behind that proxy. I did it by downloading the correct package (right distribution, right architecture) on a computer with working internet connection (I call this "other" below). The package page is here, which has links to the deb packages. Then I transferred it with scp to host with sftp:
other$ scp tsocketXXX.deb ssh.server.com:

On host, I then got the package from the ssh server:
host$ scp ssh.server.com:tsocketXXX.deb .

and then installed it (as root, of course)
host$ dpkg -i tsocketXXX.deb

The dependencies for tsocket are most likely already met on a standard install.

I then created settings for the socket by creating ~/.tsocks.conf on host for the user which needs to go through the proxy. Because apt-get runs as root, I did this as the root user. The content of ~/.tsocks.conf is
server = 127.0.0.1
server_port = 8080

(Note: this did not work for me on debian etch, I had to edit /etc/tsocks.conf instead)

I then set up the SOCKS proxy with ssh, as a regular user on host
host$ ssh -D8080 ssh.server.com


I then (in a another parallel session) run apt-get:
host$ tsocks apt-get update && tsocks apt-get upgrade

which then runs just fine (as usual, apt is really a great tool!).

What happens is that the traffic goes through port 8080 on host, then tunnels encrypted through ssh to the ssh server. From there, it opens the connection just as if I had requested the url from inside the server.
Once apt-get finishes, you can quit the ssh session (the one with -D8080)

Security concerns: Someone else (local user) will be able to use your SOCKS proxy while you have it open. That might be a problem if you do not trust the local users on the server.

fredag 23 januari 2009

Generate static version of mediawiki site

Here are some random notes on how to generate a static dump of a mediawiki site
  1. Download the DumpHTML.php extension:
    cd /var/tmp/
    svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/DumpHTML
  2. Copy the extension to the mediawiki installation (mine is in /var/lib/mediawiki, I use the packaged version for Debian Lenny).
    Become root.
    cp -r /var/tmp/DumpHTML /var/lib/mediawiki/extensions/
  3. Decide where to put the content (I use /var/www/staticdump here) and call the script:
    php /var/lib/mediawiki/extensions/DumpHTML/dumpHTML.php -d /var/tmp/staticdump --image-snapshot --force-copy --no-overwrite
Then my other web server (not apache, which serves mediawiki) can show the pages in /var/tmp/staticdump which is a lot faster than generating them with php.
The drawback is that some pages are not generated, such as the page listing all pages on the wiki.

The manual page for the extension is here: http://www.mediawiki.org/wiki/Manual:DumpHTML.php

torsdag 22 januari 2009

Skapa excelfiler i perl

use Spreadsheet::WriteExcel;
Den här perlmodulen går att använda för att skapa excelark. Jag är ingen varm anhängare av hemliga format (xls), men just nu har jag ett uppdrag som ska levereras i detta format. Innehållet i arket genererar jag med ett annat program.

Modulen har många bra exempel och funktioner.

Läs mer på http://search.cpan.org/dist/Spreadsheet-WriteExcel/

Modulen går att installera i debian (och ubuntu) med
apt-get install libspreadsheet-writeexcel-perl

lördag 17 januari 2009

Musiktips: black cab sessions

Via tips på buzz kom jag till blackcabsessions.com, en sida med musikvideor inspelade i en taxi. Kul ide!Rekommenderas varmt, jag hittade flera artister jag aldrig hört talas om som jag tycker är riktigt bra. Flera av dom låter som Cocorosie, ett annat band jag gillar.

måndag 5 januari 2009

Trähamburgaren är död


Denna sak gjorde jag i mellanstadiet - det är en förvaringsburk i trä som ser ut (nåja) som en hamburgare. Märkligt nog är det ingen som förstått sig på den, designen och funktionen är ju fulländade.Nu har den tjänat ut (sisådär 20 år senare). Leve trähamburgaren!