svn-tools: mysvn

January 11th, 2010

Scenario: subversion repository installed on a home-server. Sometimes you need to interact with it from the L.A.N. and sometimes from internet.

This script other then being a wrapper for svn, checks whether the working copy needs to be relocated or not before the operations.

#!/usr/bin/env bash

GATEWAY_IP=192.168.0.254
GATEWAY_MAC=00:14:6c:ab:d2:ca
REPO_LOCAL=192.168.0.4
REPO_REMOTE=code.matteolandi.net

arp -a | grep $GATEWAY_MAC > /dev/null
if [ $? -eq 0 ]; then
 source=$REPO_REMOTE
 destination=$REPO_LOCAL
else
 source=$REPO_LOCAL
 destination=$REPO_REMOTE
fi

url_before=$(svn info | grep URL | cut -d ' ' -f 2)
url_after=${url_before/$source/$destination}

if [ "$url_before" != "$url_after" ]; then
 echo "Relocating ${url_before} -> ${url_after}"
 svn switch --relocate $url_before $url_after
 if [ $? -ne 0 ]; then
   exit 1
 fi
fi

svn $@

I know you could create a new entry inside /etc/hosts and use it depending on the situation, but easy solutions are not my best!

Obviously you will find it inside the hacks/svn-tools repository.

Rename a MySql database

January 10th, 2010

This morning I needed to rename my database and found these three commands I’m going to show you:

mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql

[ source: stackoverflow.com ]

Backup and restore your linux workstation

January 4th, 2010

Take this as a note rather than a guide, by the way don’t forget to execute these commands as root.
Backup:

cd /
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found \
    --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/dev /

Restore:

tar xvpfz backup.tgz -C /
mkdir proc lost+found mnt sys dev

[ source Ubuntu Forums ]

svn-tools: svn-feed update

January 4th, 2010

Few changes regarding the script for the creation of the rss feeds of the commits. Indeed, I decided to create a new one from scratch using python. With this you will be able both to update the feeds and create them from the origins of your repositories.

You can find the tool inside the hacks repository.

Deadmau5 – Slip (Original Mix)

January 3rd, 2010

Artificial Funk – Never Alone

December 30th, 2009

It took me more than a week finding its name.

Python: defaults arguments

December 29th, 2009

Here is a funny snippet of code:

Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class foo:
...   def __init__(self, x=[]):
...     self.y = x
...
>>> a = foo()
>>> a.y.append("123456")
>>> a.y
['123456']
>>> b = foo()
>>> b.y
['123456']
>>> a.y.append("987654")
>>> a.y
['123456', '987654']
>>> b.y
['123456', '987654']

You better define foo as following:

>>> def foo():
>>>  def __init__(self, x=None):
>>>    if x is None: x = []
>>>    self.y = x

Sebastien Leger – Bambou (Original Mix)

December 27th, 2009

Eclipse: update sites.

December 6th, 2009

Default

http://download.eclipse.org/releases/galileo

Pydev (Python)

http://pydev.org/updates

JGit (Git)

http://www.jgit.org/updates/

Subclipse (Subversion)

http://subclipse.tigris.org/update_1.6.x

Vrapper (Vim)

http://vrapper.sourceforge.net/update-site/stable

AnyEdit (Editor features)

http://andrei.gmxhome.de/eclipse/

Python: Generate fake B.S.O.D.

November 27th, 2009


I’ve just created a script which simulate a bsod by creating a fullscreen window and placing the right text in the right position.

In order to make it closer to reality, it’s better for you to download and install this font.

And now the script: bsod