Skip to content

Instantly share code, notes, and snippets.

View alertor's full-sized avatar

Stefan Taranu alertor

  • Bucharest, Romania
View GitHub Profile
@alertor
alertor / zodiac.py
Created August 28, 2014 12:03
get zodiacal sign by DD-MM
# from http://stackoverflow.com/questions/3274597/how-would-i-determine-zodiac-astrological-star-sign-from-a-birthday-in-python
from bisect import bisect
signs = [(1,20,"Cap"), (2,18,"Aqu"), (3,20,"Pis"), (4,20,"Ari"),
(5,21,"Tau"), (6,21,"Gem"), (7,22,"Can"), (8,23,"Leo"),
(9,23,"Vir"), (10,23,"Lib"), (11,22,"Sco"), (12,22,"Sag"),
(12,31,"Cap")]
def zodiac_sign(m,d):
return signs[bisect(signs,(m,d))][2]
assert zodiac_sign(3,9) == "Pis"
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.contrib import files
USAGE = """
================================================================
NOTE:
using this fabfile expects that you have the python utility
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
fabfile for Django
------------------
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too
#!/bin/bash
EXITCODE="0"
SERVICES=(
"memcached &"
"mongod &"
"redis-server &"
"neo4j start"
"elasticsearch"
@alertor
alertor / opencv-install.txt
Last active August 29, 2015 14:03
Installing OpenCV on Ubuntu 14.04
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
cd ~/<my_working _directory>
git clone https://github.com/Itseez/opencv.git
mkdir build
cd build
@alertor
alertor / mongodb
Created April 11, 2013 08:51 — forked from srpouyet/mongodb
# Put this in /etc/logrotate.d/mongodb
# http://stackoverflow.com/questions/5004626/mongodb-log-file-growth
/var/log/mongo/*.log {
daily
rotate 30
compress
dateext
missingok
notifempty
@alertor
alertor / varnishadm.py
Created April 5, 2013 09:45
check varnishadm backend health status
#!/usr/bin/python
# save as /usr/lib/nagios/plugins/check_varnish_backends.py
from optparse import OptionParser
import subprocess
def getOptions():
arguments = OptionParser()
arguments.add_option("--host", dest="host", help="Host varnishadm is running on", type="string", default="localhost")
arguments.add_option("--port", dest="port", help="varnishadm port", type="string", default="6082")
from fabric.api import env, run, sudo, local, put
def production():
"""Defines production environment"""
env.user = "deploy"
env.hosts = ['example.com',]
env.base_dir = "/var/www"
env.app_name = "app"
env.domain_name = "app.example.com"
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name }
@alertor
alertor / diacritics.py
Created February 27, 2013 19:44
"convert" romanian diacritics
#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
# get hex code from : http://webdesign.about.com/od/localization/l/blhtmlcodes-ro.htm
import fileinput
table = {
0x103: u'a',
0x15f: u's',
}
@alertor
alertor / mongod-install
Created February 27, 2013 10:38
install mongodb - CentOS 6.3
# /etc/yum.repos.d/10gen.repo
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1
# ---
yum install mongo-10gen mongo-10gen-server