Skip to content

Instantly share code, notes, and snippets.

@hgdeoro
hgdeoro / custom_hasher.py
Created January 15, 2015 00:39
Custom hasher, hereda de PBKDF2PasswordHasher y utiliza valor de "iterations" de Django 1.7.2
class MyPBKDF2PasswordHasher(PBKDF2PasswordHasher):
iterations = 12000
#
# in the remote (client) machine
#
sudo ssh -o PermitLocalCommand=yes \
-o LocalCommand="sudo ifconfig tun1 192.168.123.2 pointopoint 192.168.123.1 netmask 255.255.255.0" \
-TC -w 1:1 root@ip-of-the-machine-with-the-virtual-servers \
'ifconfig tun1 192.168.123.1 pointopoint 192.168.123.2 netmask 255.255.255.0; echo tun ready'
#
@hgdeoro
hgdeoro / ntpd-samba
Created September 4, 2013 16:02
Init script for ntpd
#! /bin/sh
#
# ntpd-samba Control the NTP server
#
# chkconfig: - 90 10
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
@hgdeoro
hgdeoro / command_locked.py
Created June 29, 2013 02:11
Comando para Django que chequea lock
import logging
import fcntl
import os
from optparse import make_option
from django.core.management.base import BaseCommand
logger = logging.getLogger(__name__)
@hgdeoro
hgdeoro / check_smart_sas.sh
Created June 25, 2013 19:44
Check health of SAS drive using smartctl
#!/bin/bash
#STATE_OK=0
#STATE_WARNING=1
#STATE_CRITICAL=2
#STATE_UNKNOWN=3
#STATE_DEPENDENT=4
STATUS_OK="OK"
STATUS_WARNING="WARNING"
@hgdeoro
hgdeoro / check_ntp_by_hostname.sh
Created June 25, 2013 18:32
Wraps original `check_ntp` to check NTP server by hostname instead of IP
#!/bin/bash
TMP=$(mktemp)
for IP in $(dig +short 1.south-america.pool.ntp.org) ; do
rm -f $TMP > /dev/null 2> /dev/null
/usr/lib/nagios/plugins/check_ntp -H $IP > $TMP 2>&1
EXIT_STATUS=$?
if [ "$EXIT_STATUS" -eq 0 ] ; then
@hgdeoro
hgdeoro / gmic-perf.sh
Created March 15, 2013 01:39
Run gmic on various files and report performance
#!/bin/bash
#
# TODO: use time from `time` command, not from 'end-start'
#
if [ -z "$(which exiv2)" ] ; then
echo "ERROR: exiv2 required. On Ubuntu, install with 'sudo apt-get install exiv2'"
exit 1
fi
@hgdeoro
hgdeoro / django_o_l_example_2.py
Created March 10, 2013 15:57
Django Optimistic Locking: Use a Meta option
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
Meta:
optimistic_locking = True
@hgdeoro
hgdeoro / django_o_l_example_1.py
Created March 10, 2013 15:45
Django Optimistic Locking: Add a VersionField to models
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
version = models.VersionField()
@hgdeoro
hgdeoro / snorby
Created March 6, 2013 15:25
Init script for Unicorn+Snorby
#! /bin/sh
#
# Snorby Control the Unicorn+Snorby server
#
# chkconfig: - 90 10
# config: /home/snorby/snorby/unicorn.conf.rb
# pidfile: /var/run/snorby/unicorn.pid
# Source function library.
. /etc/rc.d/init.d/functions