Skip to content

Instantly share code, notes, and snippets.

View Alir3z4's full-sized avatar
💭
Rock'nRolla

Alireza Savand Alir3z4

💭
Rock'nRolla
View GitHub Profile
def utf8ify(value):
if not value: return
# remove some characters altogether
value = re.sub(r'[?.,;/:"\'\|!@#~`+=$%^&\\*()\[\]{}<>]','',value, re.UNICODE)
return value
def utf8ify_slugify(value):
value = utf8ify(value)
value = value.replace(" ", "-")
@Alir3z4
Alir3z4 / forms.py
Created November 30, 2012 00:03
Override the init to pass the current user to the model form.
class Formio(ModelForm):
def __init__(self, user=None, *args, **kwrags):
"""
Override the init to pass the current user
to the model form.
Then the current user will be passed to the form at
initializing time in views or any other situation where
``request`` is available.
"""
# server {
# listen 80;
# server_name exampl.io www.exampl.io;
# access_log /srv/http/exampl.io/orgia/logs/access.log;
# error_log /srv/http/exampl.io/orgia/logs/error.log;
#
# #ssl on;
# #ssl_session_timeout 5m;
# #ssl_certificate /etc/ssl/certs/www.exampl.io.crt;
# #ssl_certificate_key /etc/ssl/private/www.exampl.io.key;
@Alir3z4
Alir3z4 / backup-archi,sh
Created November 7, 2012 12:36
dummy bk file
#!/bin/bash
# Author Alireza Savand
# CopyRight 2012 Alireza Savand
# Back up
echo "==========================================="
echo "Start to get /home/vmail dir backup"
echo "==========================================="
echo ""
echo "Compressing format gzip2"
# Note
# mounting vmail
mount.s3ql --allow-other s3://archi-vmail /home/vmail/
# Chown to vmail:vmail
chown -R vmail:vmail /home/vmail/
# bring the ubuntu up ;)
passwd
adduser alireza
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
print 'Upgrading %s' % dist.project_name
call("pip2 install --upgrade " + dist.project_name, shell=True)
sudo ip link set wlan0 down
sudo iwconfig wlan0 channel auto
sudo ip link set wlan0 up
sudo rm /var/run/wpa_supplicant/wlan0
sudo rm -rf /run/dhcpcd-wlan0.pid
sudo wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
#sleep 20
sudo dhcpcd wlan0
*filter
# Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -i lo -d 127.0.0.0/8 -j REJECT
# Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow all outbound traffic - you can modify this to only allow certain traffic
for f in *.*; do echo "video file $f is under fucking processing"; ffmpeg -i $f $f.mkv"; done
" -[ General behaviour ]-
" general
set nocompatible
set nowrap
syntax on
filetype plugin indent on
" search
set nohls
set incsearch