Educate Yourself

Dec 29
2009

http://educate-yourself.org

socket.error: (99, ‘Cannot assign requested address’)

Dec 27
2009

Enable the localhost interface:
/sbin/ifconfig lo up

Git Cheat Sheet (Debian based)

Dec 17
2009

apt-get remove --purge gitk gitosis git-gui git-core
apt-get install mercurial

`mkdir` and `cd` at once

Dec 16
2009

I am sick of mkdir dir_name; cd dir_name;
The solution (put this function in “.bashrc” or whatever shell config file you use):

_mkcd () {
       mkdir -p $1
       cd $1
}
# usage: _mkcd /tmp/dir_1/dir_2
# pwd will show: /tmp/dir_1/dir_2

Projects’ Hosting

Dec 16
2009

Why Assembla free plan:

  • Subversion Hosting with Integrated Tickets
  • Trac and Subversion Hosting
  • Team Collaboration
  • Subversion Repository
  • Git with Integrated Tickets

P.S. If you are like me - spitting on GIT on a daily basis - Mercurial is included in the other plans.

Christmas names

Dec 15
2009
>>>from nltk.corpus import wordnet as wn
 
>>>wn.synsets('Christmas')[0].lemma_names
 
['Christmas', 'Christmastide', 'Christmastime', 'Yule', 'Yuletide', 'Noel']

unarchive files

Dec 14
2009

a sample BASH function (usually resides in $HOMES/.bashrc)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
extract () {
        if [ -f $1 ] ; then
                case $1 in
                        *.tar.bz2) tar xjf $1;;
                        *.tar.gz) tar xzf $1;;
                        *.bz2) bunzip2 $1;;
                        *.rar) rar x $1;;
                        *.gz) gunzip $1;;
                        *.tar) tar xf $1;;
                        *.tbz2) tar xjf $1;;
                        *.tgz) tar xzf $1;;
                        *.zip) unzip $1;;
                        *.Z) uncompress $1;;
                        *) echo "'$1' cannot be extracted via extract()";;
                esac
        else
                echo "'$1' is not a valid file"
        fi
}

the actual meaning of “Merry Christmas”

Dec 14
2009
import re
 
greeting = "Merry Christmas"
 
greeting_list = map(chr, [ord(i) - len(greeting) - 1 for i in greeting])
greeting_list = set(filter(lambda x: re.match('[a-z]|[A-Z]', x), greeting_list))
 
# greeting_list is set(['c', 'b', 'd', 'i', 'Q', 'U', 'Y', 'X'])
# the 1st 3 elements are not clear to me: c,b,d
# 'i' means 'I', 'Q' means 'question', 'U' means 'you', 'Y' means 'why', 'X' means 'Christmas'
# which makes the compound: 'I question you - why Christmas?'

Right?

Upgrade Trac seamlessly

Nov 28
2009

Find your Trac path:

python -c’import trac;print trac’

Edit env.py on line 598:

1
2
3
4
5
6
if needs_upgrade:
    try:
        os.system("/usr/bin/trac-admin %s upgrade" % env_path)
    except TracError:
        raise TracError(_('The Trac Environment needs to be upgraded.\n\n'
                              'Run "trac-admin %(path)s upgrade"', path=env_path))

Restart Trac daemon ot whatever http server is serving it.

The Alphabet

Oct 20
2009

Python

import re
 
_char = re.compile(r'\w')
 
''.join([chr(i) for i in xrange(65,122) if _char.match(chr(i))])
 
# or just:
import string
 
string.ascii_letters
string.ascii_lowercase
string.ascii_uppercase

Ruby

(65..122).to_a.map{ |e| e.chr =~ /\w/ && e.chr }.compact.to_s

Perl

$chars .= chr() =~ /\w/ ? chr() : q{} for 65..122;

I don’t like the mess of Ruby, and Perl.

Calendar

July 2010
M T W T F S S
« Apr    
 1234
567891011
12131415161718
19202122232425
262728293031  

Tags