Skip to content

Instantly share code, notes, and snippets.

View piotrkilczuk's full-sized avatar
🐈
I may be slow to respond.

Piotr Kilczuk piotrkilczuk

🐈
I may be slow to respond.
  • Rzeszów, PL
  • 00:48 (UTC -12:00)
View GitHub Profile
@piotrkilczuk
piotrkilczuk / gist:1108119
Created July 26, 2011 21:33
Find top 10 dirs on linux
du -a / | sort -n -r | head -n 10
@piotrkilczuk
piotrkilczuk / gist:1111409
Created July 28, 2011 11:27
README.rst template for Github projects

project-name

project-name aims at... (goals, comparison with others on the market)

Features:

  • 1
  • 2
from django.db import models
import uuid
class UUIDField(models.CharField):
"""
A field which stores a UUID value in hex format. This may also have
the Boolean attribute 'auto' which will set the value on initial save to a
new UUID value (calculated using the UUID1 method). Note that while all
UUIDs are expected to be unique we enforce this with a DB constraint.
@piotrkilczuk
piotrkilczuk / gist:1116854
Created July 31, 2011 14:56
Connect to openvpn network from console
#!/usr/bin/env sh
if [ -z $1 ]
then
echo "Input name, one of:"
ls /etc/openvpn/*.conf | sed 's/\/etc\/openvpn\///' | sed 's/.conf//'
exit 1
fi
sudo openvpn --config /etc/openvpn/$1.conf
@piotrkilczuk
piotrkilczuk / copy_mysqldb.sh
Created July 31, 2011 15:00
Copy MySQL database over SSH / SCP
#!/bin/bash
echo "copy_mysqldb.sh -- p.kilczuk@neumea.pl"
echo "version 0.1.0"
echo ""
REMOTE_DBNAME=""
REMOTE_USER=""
REMOTE_HOST=""
REMOTE_PORT="3306"
@piotrkilczuk
piotrkilczuk / gist:1120278
Created August 2, 2011 14:18
Recusively delete pyc / pyo
find . -name "*.pyc" -exec rm '{}' ';'
find . -name "*.pyo" -exec rm '{}' ';'
@piotrkilczuk
piotrkilczuk / runserver.py
Created August 9, 2011 12:15
Run multiple instances of Django development server using subprocesses
#!/usr/bin/env python
import glob
import os.path
import socket
import subprocess
import sys
# manage.py must be made executable in order for this to work
@piotrkilczuk
piotrkilczuk / gist:1149295
Created August 16, 2011 14:59
Recursively delete .svn
rm -rf `find . -type d -name .svn`
@piotrkilczuk
piotrkilczuk / gist:1154173
Created August 18, 2011 14:33
Rsync incremental media download script
#!/bin/bash
# Usage:
# rsync.sh re/mo/te/dir lo/cal/dir
# re/mo/te/dir will be appended to this
BASEDIR='user@host:/data/stor/www/...'
rsync --checksum --compress --exclude '.svn' --links --perms --progress --recursive --update --verbose $BASEDIR$1 $2
@piotrkilczuk
piotrkilczuk / storage.py
Created September 13, 2011 09:11
Store Django filenames as ASCII - ASCIIFileSystemStorage
from django.core.files.storage import FileSystemStorage
import unidecode
class ASCIIFileSystemStorage(FileSystemStorage):
"""
Convert unicode characters in name to ASCII characters.
"""
def get_valid_name(self, name):
name = unidecode.unidecode(name)