February 7th, 2010
Given a structure of a project ..
gstream/
bin/
gstream
gstreamlib/
__init__.py
gui.py
player.py
playlist.py
.. you can create a simple setup.py script containing:
#!/usr/bin/env python
from distutils.core import setup
setup(name='gstream',
version='0.5',
author='Matteo Landi',
author_email='landimatte@gmail.com',
scripts=['bin/gstream'],
package_dir={'gstreamlib': 'gstreamlib'},
packages=['gstreamlib'],
)
Tags: install , package , python Posted in programming , tips & triks | No Comments »
February 4th, 2010
#!/usr/bin/env bash
cat << EOF
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
EOF
Copy it into a file, and make it executable! Enjoy!
Tags: ipsum , lorem , script Posted in hacks | No Comments »
February 2nd, 2010
This video was embedded using the YouTuber plugin by Roy Tanck . Adobe Flash Player is required to view the video.
Tags: downtempo , house , music Posted in music | No Comments »
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.
Tags: relocate , svn Posted in hacks , programming | No Comments »
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 ]
Tags: database , dump , mysql , restore Posted in tips & triks | No Comments »
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 ]
Tags: backup , linux , restore Posted in tips & triks | No Comments »
January 3rd, 2010
This video was embedded using the YouTuber plugin by Roy Tanck . Adobe Flash Player is required to view the video.
Tags: house , music Posted in music | No Comments »
December 30th, 2009
It took me more than a week finding its name.
This video was embedded using the YouTuber plugin by Roy Tanck . Adobe Flash Player is required to view the video.
Tags: chillout , langue Posted in music | No Comments »
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
Tags: arguments , default , python Posted in programming , tips & triks | No Comments »