Making a Time Capsule using Debian Squeeze

Posted in HOWTO on May 18th, 2011 by Simon – 4 Comments

Note: This tutorial is deprecated. Word in the street is that the new version of netatalk supports TimeMachine out of the box. Havn’t confirmed it though..

Now that Debian 6 (Squeeze) has been released, many of the packages are now also updated to the latest version. This means, no more hacks and fixes (for a while).

I have for a long time used Matthias Kretschmann‘s guide on “HowTo: Make Ubuntu A Perfect Mac File Server And Time Capsule Volume” to get my time capsule to work on my Debian Machine. Not anymore. With Debian 6, everything seems to work; out of the box.

So here we go.

First we install and set up netatalk:

$ sudo apt-get install netatalk
Go in and add your shares:
$ sudo nano /etc/netatalk/AppleVolumes.default
These are mine:
/mnt/time_machine/TimeMachine “TimeMachine” cnidscheme:dbd options:usedots,upriv,tm ea:ad

/mnt/big_disk “BigDisk” cnidscheme:dbd options:usedots,upriv ea:ad

Note the options:tm (for Time Machine)

 

Now, install and configure Avahi:

$ sudo apt-get install avahi-daemon libnss-mdns
Go in and make sure “mdns” is at the end of the line that starts with “hosts:”, in:
$ sudo nano /etc/nsswitch.conf
edit services/afpd.service:
$ sudo nano /etc/avahi/services/afpd.service
and add the following:
<?xml version="1.0" standalone='no'?><!---nxml--->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service><type>afpovertcp.tcp</type><port>548</port></service>
<service><type>device-info.tcp</type><port>0</port><txt-record>model=TimeCapsule</txt-record></service>
</service-group>
Note: Make sure the quotes-signs are correct. Sometimes WordPress will mess them up.

 

Restart the servers:

$ sudo /etc/init.d/netatalk restart; sudo /etc/init.d/avahi-daemon restart
 

Make sure everything is OK:

You can follow the messages from afpd and avahi-daemon, by tailing /var/log/daemon.log

 

Installing the python bindings for ØMQ in Debian

Posted in Developement, HOWTO on January 22nd, 2011 by Simon – 2 Comments

The following is a list of things to do to get the Python bindings for ØMQ to work in Debian Lenny:

  1. Make sure ØMQ is installed
  2. Make sure you have all the modules needed installed: $ sudo apt-get install python2.5-dev python-simplejson
  3. Get the latest stable version from: http://github.com/zeromq/pyzmq/downloads
  4. Unpack the archive and enter the directory
  5. Copy “setup.cfg.template” to “setup.cfg” $ cp setup.cfg.template setup.cfg
  6. Install the bindings: $ sudo python setup.py install
  7. Set the correct path to the libraries $ sudo python setup.py build_ext –rpath=/usr/local/lib –inplace
This should be it. You can test it with:

$ python setup.py test

I get two errors:

  1. “test non-copying numpy array messages … ERROR”
  2. “test messages from memoryview (only valid for python >= 2.7) … ERROR”
But I’m only using Python 2.5 , so I will ignore the last error. The first one I hope won’t make any trouble. I don’t know. Write it in the comments if you have an explanation.

Installing ØMQ on Debian

Posted in Developement, HOWTO on January 22nd, 2011 by Simon – Be the first to comment

What is ØMQ? The following is from Wikipedia: “ØMQ (also spelled ZeroMQ, 0MQ or ZMQ) is a high-performance asynchronous messaging library aimed to use in scalable distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ØMQ system can run without a dedicated message broker. The library is designed to have a familiar socket-style API.”

It is not an implementation that you can run out of the box. In fact it is not implemented at all. That’s up to you and me as programmers. It is just a library to get that pesky sockets programming going a whole lot smoother.

How to install the darn thing on Debian (Lenny)?

  1. Make sure you have all the libraries installed: $ sudo apt-get update && sudo apt-get dist-upgrade $ sudo apt-get install libtool autoconf automake uuid e2fsprogs
  2. Get the latest stable release from http://download.zeromq.org/
  3. Unpack the .tar.gz source archive. $ tar zxvf zeromq-<tab>
  4. Run ./configure, followed by make: $ ./configure && make
  5. To install ØMQ system-wide: $ sudo make install
  6. Last step: $ sudo ldconfig
There. Everything should be working. It’s time for you to get to work. Enjoy.

Status-beskeder fra DSB

Posted in ByensPuls on November 14th, 2010 by Simon – Be the first to comment

Vidste du at min AJAX version af Byens Puls også viser status-beskeder DSB? Det er ikke noget nyt. Det har den gjort hele tiden, men der er åbenbart ikke så meget at rapportere.

Men i dag kan jeg se at der har været grund; Så der ligger lige nu en meddelelse fra DSB på byenspuls.dsb.dk:

Som man kan se er der noget galt med tegnsættet i DSB’s java-applet. Det er ret pineligt, så det har jeg naturligvis rettet op på i min AJAX version af Byens Puls:

Rart og fint; i bund og grund den samme tekst, look og feel. Bare efter bogen :-)

AJAX version af Byens Puls

Posted in ByensPuls, Developement, PHP on March 26th, 2010 by Simon – 10 Comments

Applikationen kan findes på: http://apps.simonpaarlberg.com/ByensPuls/

DSB S-tog har i mange år haft web-applikationen Byens Puls på deres hjemmeside. Applikationen viser hvor S-togene kører i realtid og er en sjov side at følge med på hvis man har udsigt til en del af baneteregnet.

Systemet er baseret (efter hvad jeg har kunne finde) på et ældre system, hvor et system kan opfange togets magnetfelt igennem to sorte kabler der er ført mellem sporene. Systemet er fra før GPS blev hver-mands-eje og hvor alt kommunikation med togene foregik over håndradioer.

I dag positionere togene med GPS der giver en meget bedre detaljegrad, men det gamle system virker endnu. Jeg ved ikke hvorfor de ikke har pensioneret det, men det har nok noget med signalerne at gøre. Det korte af det lange er at Byens Puls er baseret på dette system.

Hvor kommer jeg så ind i billedet henne? Jo. Jeg besluttede mig for, for godt et år siden at lave en Android applikation der kunne vise indholdet af informations-tavlerne på stationerne på min telefon. Applikationen kunne fortælle om jeg skulle skynde mig at få toget, eller om jeg bare skulle tage det næste.

Det første jeg besluttede mig for at gøre, var at indsamle noget data. Det blev i første omgang til dataen fra Byens Puls, men inden jeg bare blindt ville bruge dataen, måtte jeg starte med at måle om den data der blev oplyst var god nok. Altså om detaljegraden var god. Problemet var bare at Byens Puls bliver afviklet igennem en Java Applet. Husk på at systemet er af ændre dato. Hvert fald 10 år gammel. Der er sket meget med asynkron opdatering af hjemmesider.

Mit problem gik ud på at, jeg gerne ville kunne sidde i toget fra tid til anden og se om toget nu også kørte der hvor de små pile viste at toget kørte, men da jeg ikke kunne åbne Java Applets på min Android telefon, måtte jeg finde på noget.

Det andet jeg fandt på, var at konvertere applikationen til ren AJAX. Systemet foregår ved at jeg har levet et PHP script der kan konvertere feedet fra DSB til json og vise det i en javascript enabled browser. Implementationen er meget simpel, men det tog mig noget tid at finde ud af hvad der sker i feedet fra DSB. Det er ikke ligefrem open source.

Nu er applikationen efterhånden færdig og kan findes på: http://apps.simonpaarlberg.com/ByensPuls/ . Jeg fik det til at virke i min Android browser, men fandt derefter også ud af at Byens Puls simpelthen er for unøjagtig, da jeg skal vide indenfor minuttet hvornår toget kommer og det forsyner Byens Puls mig ikke med.

Det næste forsøg jeg vil lave er at bruge en blanding mellem køreplanen i tabelform og information omkring forsinkelser fra Bane Danmarks hjemmeside. Men indtil jeg får det til at virke kan du måske have brug for en AJAX version af Byens Puls til din iPhone eller Android eller noget helt 3.

Jeg har desuden lagt sourcen op på github. Den kan findes her.

Bemærk venligst at jeg ikke har noget at gøre med DSB og at jeg bare er en 3. part der benytter mig af deres data direkte fra deres feed.

Class for checking DR Radio Status

Posted in PHP on October 4th, 2009 by Simon – Be the first to comment

I have recently updated my PHP class for retrieving play status from Denmarks Radio (dr.dk) . The class relies on a javascript feed that is a part of their net-radio player. The extraction o information is very — but then what isn’t once you figured it out!?

The class includes methods for retrieving a list of stations, that then can be passed as argument to get the information for the station. The class extends the PersistentCurl class although you probably could hack it so it works with filegetcontents or fopen instead.

The page the class retrieve the information from is: http://netradio.dr.dk/update_nowplaying.asp

The class and a code example can be downloaded from here: http://github.com/drweberdk/DRRadioStatus

CurlGetPage is now PersistentCurl

Posted in PHP on October 1st, 2009 by Simon – Be the first to comment

I have just renamed CurlGetPage to PersistentCurl since I found this to be more accurate and catchy. After all, I want people to find the class and also use it.

You can find the lastest updates at github: http://github.com/drweberdk/PersistentCurl

CurlGetPage class has been updated

Posted in Developement, PHP on September 30th, 2009 by Simon – Be the first to comment

I started to use CurlGetPage for various tasks (like pulling information from Telmore and DTU’s Campusnet — more on both later), but while fiddling around with the login prodecure at cn.dtu.dk the redirection took forever and the trail was about 4 redirects for every GET-request. Something was clearly not working corectly.

After some research, it seemed like important cookie information got lost, when I was telling cURL to do the redirection (Follow location). The solution was to do the redirection myself and store the cookie- and session-information myself. I did and it worked. It looks like my implementation makes the same amount of request as my browser so I think we’re good to go.

I have updated the unit-tests and the use of the class it straight forward.

Find the source on github: http://github.com/drweberdk/Simons-PHP-classes/tree/master/CurlGetPage/

Enjoy!

PHP Class for cURL

Posted in PHP on September 4th, 2009 by Simon – Be the first to comment

cURL is great! I love cURL! and I know cURL loves me! Sometimes cURL is written as curl, but the homepage writes it: cURL – and that’s what I tend to to (don’t freak out if I slip..)

Ohh well. I use cURL A LOT! Why!? Because I like love to make hack-API’s for pages that for some reason don’t make them theirselves — and often-times I need the data in there for fancy graphs and statistics — or just fun!

Since most of wanted functionality is the same from job to jon and the sites with relevant content is hidden behind a authentication system, the session ID for the page-session needs to be stored and used again when retrieving the data. This is a trivial task and theirfore needs to be capsulated inside a class that can handle all that magical stuff.

So a couple of years ago (more like 5-6 or so) I made some function calls for handling my requests – and although it was mostly spagetti-code it worked — and worked well.

Since then PHP has matured and now handles classes much more elegant, so I decieded to rewrite the functions to a nice abstract class, that I could use to make other classes from for various jobs.

This abstract class is what I’m now sharing with you — and everyone like you. So if you’re interested pick it up at GitHub. The main focus of the class is it’s ability to store the session ID and reuse it at every page request.

Please read the readme-file for more information and usage.

Running IE7 and IE8

Posted in HOWTO, Splunk on August 17th, 2009 by Simon – Be the first to comment

Update: It turns out you don’t need IE7 standalone. You can emulate IE7 behaviour with IE8. Just push the little green icon next to the address bar and the page will load as IE7: IE7_emulate

Although I’m a happy Linux-running-kinda-guy I can’t dismiss the fact, that a lot of people run Windows and Internet Explorer. So naturally I need to test my pages also in Microsoft’s big-ol’ swampy OS (I run a VM in VirtualBox). I couple of days ago the new IE8 got released and with it, IE7 got flushed down the toilet. So I found myself not being able to test in IE7.

Fortunately the guys over at TredoSoft has already made it really easy for people like me. They are the same guys that brought us Multiple-IE and now they have made a standalone IE7, so it’s possible to run all IE3, IE4, IE5, IE5.5, IE6, IE7 and IE8 on one Windows install.

Thanks TredoSoft!