Rants of a madman
Dec
6

OMG im such a nerd. I cant sit down and enjoy a game, without ending up programming something related to it.

The latest thing i couldnt leave alone, was the Computer Terminals in FallOut 3. After understanding the logic behind it, i had to code a script that would calculate the correct word to enter.

fallout3_computer_screen.jpg

After telling my collegues about it, they asked if i could make it webbased and i said yes.

3 weeks of not keeping my promise, here it finally is :)..

http://perl.hacker.dk/cgi-bin/fallout_hack.pl



  - Dan
Oct
25

Dropbox (dropbox.com) has been getting a lot of attention in the open source community lately, mainly due to the fact that people think the client is open source.

Before i start, id like to say that i do think Dropbox is pretty neat and i also think close source has its place in the world, though i would always personally choose the open alternative.

Anyway… “Dropbox is not open?!?” you say, “But the source is available on their webpage?”. This is correct and very very wrong at the same time. The Nautilus plugin is open, but contrary to common belief, it is NOT the dropbox client. Once you’ve installed the Nautilus plugin (which is 66k) it will download 35megs of closed souce in the background into the folder ~/.dropbox-dist. Without asking permission.

The Nautilus plugin only does a few things like enabling the dropbox right-click menu, handling the icon-overlay in nautilus and so forth. Basically the Nautilus plugin only handles the “visual stuff”:

Dropbox Nautilus plugin ui

All the “real stuff”, network- and filewise, happens in a “small” 7.8meg (closed-source) daemon called “Dropboxd”.
The plugin talks to the daemon through a named pipe (fifo pipe) located in ~/.dropbox/. Dropboxd itself is made in python and compiled into a binary.

dropbox-dist

It uses a lot of well known libraries like rsync, zlib, the bz2-lib, SDL, libfreetype, openssl, sqllite ect.ect, all downloaded in binary form through the before mentioned background process and saved to ~/.dropbox-dist.I havent checked the licenses of the libs used, but i assume they all allow for closed source distribution.

It doesnt bother me that people make closed source software using open source libraries* (except when Microsoft does it), but what does bother me, is the feeling of being tricked into installing a closed-source app on my open source system.

* when they give a little code back to the community. Imagine how fast open source would move if all proprietery projects gave back 5-10% code.



  - Dan
Jul
16

Presenting “sapi2wav”. (name choosen because text2wav was already taken)

Its a simple windows tool that allows you to do Text-To-Speech on command line.

The program will play a text given as argument or read a file and output to a wave file. It also allows you to choose other voices, if eg. you have NeoSpeech voices or AT&T Natural voices.

Its free (unlike any other commandline SAPI program ive found) and its Open Source (GPL).

Commandline processing is a MUST for any form of scripting or automation. I wanted to automaticly transfer daily news-stories to and MP3 player and now i can :)
Usage is as simple as:

sapi2wav.exe c:\out.wav 1 -t “Hello world”

TextAloud has a commandline mode, but its very oddly written, pretty beta and doesnt run under Linux. I wrote to Text Aloud (or NextUp.com) explaining my very insignificant problem and of course they didnt reply. So instead of buying their product, i ended up making an open source alternative :).

So if you install SAPI5 under wine (must be installed in windows ME compatability mode), then you can run this tool under wine as well and do commandline magic :)

Downloads:

Setting up MS-SAPI5 under wine should be as easy as configuring your wine to run in Windows ME mode, then download and run MS’s Sapi5 installer (msi - the Win ME version)

Winehq has an article on how to do this.

The tool SayPad from this page should have sapi5 included in the 95/98/me installer.. Though i havent testet it, i guess if you can install SayPad under wine, youll get the needed api’s.

please send me any changes you might make to this sapi to wav tool.



  - Dan
May
23

Problem:PHP displays its version along with the normal webserver response headers. Apparently the only way to change this, is recompiling PHP. Which i find annoying to do after every PHP update.. So i decided to make a one-liner to patch the binary PHP module.

Solution:

This has been tested only on PHP4 and PHP5 on Debian, but i see no reason why it shouldnt work on other distro’s.

Locate your libphp4.so, libphp5.so or the likes. Mine is in /usr/lib/apache/1.3/libphp4.so (on Debian). And make a backup of it just in case ;)
Run the following command:

perl -pi -e "s/(X-Powered-By: PHP).([^\x00]+)/$1\x00$2/" /usr/lib/apache/1.3/libphp4.so

(replace /usr/lib/apache/1.3/libphp4.so with YOUR path)

Restart apache. Now headers only reveal “X-Powered-By: PHP"



  - Dan
Mar
22

Ive been coding some perl for my Nokia 770 that needed to play sounds and i found that play-sound should do the trick. However the volume is very low and a lot of googling turned up nothing but other people with the same problem.

After analysing ‘play-sound’, i found out 2 things.

  1. It does use “esd” to play waves, which is good since its “non-blocking”.
  2. It’s made for playing “system-alert” sounds

So looking in the sound configuration, you can choose the volume level of system-alert sounds. The options are “none”,”level 1″ and “level 2″ and after raising my sound to level-2, it still wasnt loud enough. Also, i really dont want all other alert sounds at that volume.

So based on my (simple) analysis, the play-sound program reads a config option called “system_alert_volume”. So i thought there might also be a “master_volume” defined as well and did a small patch. And i was right.

So my solution is this (and requires perl on the tablet or an “offline” hex-edit):

Make a copy of play-sound:
$ cp /usr/bin/play-sound /usr/bin/play-sound2

Patch /usr/bin/play-sound2 to use “master_volume” instead. With perl, do this:
$ perl -pi -e 's/system_alert_volume/master_volume\x00...../' /usr/bin/play-sound2

Problem solved ;). Now you can use the command:
$ play-sound2 test.wav

to play sounds at the set master volume.

To do the same patch in a hex-editor, locate “system_alert_volume” and overwrite the string with “master_volume”, plus a “null” char (\x00) to terminate the string. If you forget to null-terminate, play-sound2 will segfault.

I like this solution, since “play-sound” is only 10k large and no extra dependencies needs to be filled.. And the “copy & patch” could be done from an install script.



  - Dan
Jan
4

I run DHCP at home. Having a crappy linksys router, every time i reboot it, all DHCP leases are lost. As a consequence all SSH servers on my home net gives me this error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
de:ad:be:ef:ff:59:fe:1b:39:55:fe:e5:ac:6b:13:fe.
Please contact your system administrator.
Add correct host key in /home/dan/.ssh/known_hosts to get rid of this message.
Offending key in /home/dan/.ssh/known_hosts:39
RSA host key for 192.168.1.51 has changed and you have requested strict checking.
Host key verification failed.

Finally i got fed up with manually editing my known_hosts file and deleting the conflicting line every time. I started by googling to see what others were doing, but it appears that people just edit the file like me. So i hacked up a shell script to do it for me.

EDIT: Actually, the correct way of doing this (and easy way) is simply “ssh-keygen -R”. I kept this script online anyway, because the new regex support in bash is pretty cool and this script serves as a great example.

ssh_keyclean.sh:

#!/bin/bash
DATA="`ssh $1 echo 2>&1|grep known_hosts:`"

if [[ "$DATA" =~ ([^ ]+):([0-9]+) ]]
then
        echo "SSH KeyCleaner v. 0.1";
        echo -n "Delete key from line"
        echo -n " ${BASH_REMATCH[2]} in"
        echo -n " ${BASH_REMATCH[1]}? "
        read -n1 -p"(y/n) : " A
        echo
        if [ "$A" == "y" ]
        then
                sed -i " ${BASH_REMATCH[2]}d"  ${BASH_REMATCH[1]}
                echo "Cleaning"
        fi;
else
        echo "Bad output from ssh command. Sorry.";
fi;

Copy and paste this into a file, ie. /usr/bin/ssh_keyclean.sh (and remember to use an editor that keeps the backquotes .”joe” doesnt) then “chmod +x /usr/bin/ssh_keyclean.sh”

Whenever you get the message that the key has changed, all you have to do is type:

$ ssh_keyclean.sh <ip_address>

eg.

$ ssh_keyclean.sh 192.168.1.51

How it works:

It runs the ssh command, grepping the line containing “known_hosts:”. It then uses bash’s new built-in regex support to extract 2 vars: The filename and the linenumber. Lastly it prompts you if youre sure, and if you are, it uses “sed” to delete the linenumber reported by ssh in the ~/.ssh/known_hosts file.

Requirements:

  • Bash shell v. 3+

Tested on Ubuntu Linux. Should work on all Linux distro releases newer than ~2 years i guess.

Let me know if you find it useful.



  - Dan
Oct
20

This is a small extension that helps generate a download list for FlashGot.
Heres what it does. It adds a link to the “Par Viewer” called “FlashGot linklist”:


Pardon the ugly colors.. I hate white backgrounds.

Clicking this link, pops up a window where a “hidden” list of links is generated. Looks like this:

As i said, theres an invisible linklist inside the window. It contains links to all the files that arent “par2″ files and arent “autounrar”. Then it adds the first par2 file (the smallest one) to this list as well.

So you end up with a fine list containing eg. *.rar and 1 small par2 file to do verification (if youre into to that sorta stuff) :).

Rightclicking (as youre told) and clicking the “FlashGot all” starts your download manager. Mine is FDM. Like this:

Makes it a hell of a lot easier downloading large stuff.

Install script by clicking here.



  - Dan
Oct
20

Ive created this little Greasemonkey script for the MS Exchange OWA (Outlook Web Access) that does 2 things for your firefox experience:

  • Keeps your session alive
  • Shows you number of unread mails in Inbox

A script already exists1 that does this, however it simply refreshes the entire OWA page, and only as long as youre on the Inbox page. Thus while eg. writing a new mail, youre session isnt kept alive. In my script, it is :).

Visually, it doenst change that much:


number of unread emails in title bar, updates even though im composing a message


updates process bar while minimized

The cool thing is that there isnt any “refreshing” to see. Hence, the page doenst visually refresh. Its all done in the background, inside a hidden “iframe”. Here, the Inbox page is refreshed and re-read every 60 seconds so you dont get disconnected from the OWA and so we can update the “unread mails” counter. The iframe is hidden inside the menu-frame to the left (because that frame never reloads).

Click here to install (greasemonkey firefox plugin required)


1. MsExchangeRefresh by Jehiah Czebotar (which inspired me to make my script)



  - Dan
Sep
17

Getting this one when insmod’ing or modprobing AppArmour?

FATAL: Error inserting apparmor - Resource temporarily unavailable

Well after long time searching and testing (and reading German forums.. And i SuCK at German) i found the solution.

The error occurs because some other security module is loaded. Many forums suggested it might be the Dazuko module, however i dont have that installed. Actually as it turns out, my Feisty loads the “capability” module on boot.. And that conflicts with apparmor. This can be seen using ‘lsmod’ and looking for ‘commoncap’ in the left column. Whatever is in the right column, is your conflict.

sudo rmmod capability
sudo modprobe
apparmor

Problem solved.



  - Dan
Aug
18

Så kom vi hjem, fik sovet ud, pakket ud og tømt de sidste billeder ud af vores kameraer.. Så som afslutning på 5 fantastiske dage, poster vi her de sidste billeder vi aldrig fik vist, som bla. inkluderer oversvømmelser pga. et kæmpe regnskyl, Opsendelse af en vejrballon, Flammekastere der “skyder” i takt til musikken og meget meget mere. Et lille “post CCC image gallery”.

Billederne er ikke sorteret i rækkefølge.

CCC2007/CIMG3552_resized.JPG CCC2007/CIMG3569_resized.JPG

CCC2007/CIMG3576_resized.JPG CCC2007/CIMG3589_resized.JPG

CCC2007/CIMG3598_resized.JPG CCC2007/CIMG3619_resized.JPG

CCC2007/CIMG3620_resized.JPG CCC2007/DSC_0002.JPG

CCC2007/DSC_0004.JPG CCC2007/DSC_0005.JPG

CCC2007/DSC_0006.JPG CCC2007/DSC_0008.JPG

CCC2007/DSC_0009.JPG CCC2007/DSC_0011.JPG

CCC2007/DSC_0012.JPG CCC2007/DSC_0013.JPG

CCC2007/DSC_0018.JPG CCC2007/DSC_0024.JPG

CCC2007/DSC_0028.JPG CCC2007/DSC_0031.JPG

CCC2007/DSC_0033.JPG CCC2007/DSC_0034.JPG

CCC2007/DSC_0050.JPG CCC2007/DSC_0057.JPG

CCC2007/DSC_0058.JPG CCC2007/DSC_0061.JPG

CCC2007/DSC_0064.JPG CCC2007/DSC_0075.JPG

CCC2007/DSC_0077.JPG CCC2007/DSC_0078.JPG

CCC2007/DSC_0079.JPG CCC2007/DSC_0081.JPG

CCC2007/DSC_0084.JPG CCC2007/DSC_0094.JPG

CCC2007/DSC_0095.JPG CCC2007/DSC_0096.JPG

CCC2007/DSC_0101.JPG



  - Dan