Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# my title
echo -e '\x1b]0;my title\x07'
#!/bin/bash
echo $LINES
echo $COLUMNS
# or
tput lines
tput cols
#!/usr/bin/env python
# encoding=utf-8
# get terminal size
import curses
if __name__ == '__main__':
curses.setupterm()
print curses.tigetnum('lines')
@ratazzi
ratazzi / portabledb.py
Created December 24, 2011 06:24
portable db
#!/usr/bin/env python
# encoding=utf-8
import os, sys
import sqlite3
class PortableDB(object):
def __init__(self, db_path):
self.conn = sqlite3.connect(db_path)
self.cursor = self.conn.cursor()
git config filter.rcs-keyword.clean 'perl -pe "s/\\\$Revision[^\\\$]*\\\$/\\\$Revision\\\$/"'
git config filter.rcs-keyword.smudge 'perl -pe "s/\\\$Revision[^\\\$]*\\\$/\\\$Revision: `env -i git svn info | grep Revision | awk '\''{print $2}'\''`\\\$/"'
# example usage:
# echo 'test.py filter=rcs-keyword' >> .gitattributes
# git add test.py .gitattributes
# need manual checkout file
# rm test.py
# git checkout test.py
Options ExecCGI FollowSymLinks Includes MultiViews
RewriteEngine On
#RewriteCond %{HTTP_HOST} ^[^.]+\.ratazzi\.org$
#RewriteRule ^(.*) %{HTTP_HOST}$1 [C]
#RewriteRule ^([^.]+)\.ratazzi\.org(.*) /static/$1$2 [L]
RewriteCond %{HTTP_HOST} ^static.ratazzi.org$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# gevent on OS X Lion
sudo python setup.py install -I /opt/local/include/ -L /opt/local/lib
@ratazzi
ratazzi / eventlet_example.py
Created October 12, 2011 14:44
eventlet_example.py
#!/usr/bin/env python
# encoding=utf-8
import eventlet
eventlet.monkey_patch()
import sys, os
import xmlrpclib
import subprocess
def download():
@ratazzi
ratazzi / gist:1273519
Created October 9, 2011 10:08
aria2c
aria2c \
--continue=true \
--log=/home/ratazzi/aria.log \
--log-level=warn \
--seed-time=0 \
--file-allocation=none \
--human-readable=false \
--allow-overwrite=true \
--always-resume=true \
--bt-hash-check-seed=false \
" 2html.vim
colorscheme ratazzi
exec "TOhtml"
exec "xa"
# run in terminal
gvim log.txt -e -c "source 2html.vim"