Skip to content

Instantly share code, notes, and snippets.

View TimoSolo's full-sized avatar

Timothy Solomon TimoSolo

View GitHub Profile
@johanmeiring
johanmeiring / gist:3952290
Created October 25, 2012 12:23
Backup file rotation
#!/bin/bash
DEST=/root/BACKUPS
# Code to actually create backup files goes here...
# Check if we need to rotate the backup files.
FC=`ls ${DEST}/*.tar | wc -l`
if [[ $FC -gt 6 ]]; then
echo "Too many backup files. Deleting oldest one..."
DELETE_FILE=`ls -tr ${DEST}/*.tar | head -1`
@TimoSolo
TimoSolo / IDvalidation.py
Created June 26, 2012 11:29
South African ID number Validation for openERP
# info from http://geekswithblogs.net/willemf/archive/2005/10/30/58561.aspx
def _id_check(self, cr, uid, ids, context=None):
obj = self.browse(cr, uid, ids[0], context=context)
if obj and obj.idnumber:
idnum = str(obj.idnumber)
if len(idnum) != 13:
return False
checksum1 = 0
checksum2 = ""
@leenasn
leenasn / offset_id_fields_mysql.sql
Created March 18, 2011 09:03
An SQL script to offset the id fields across all tables in a DB.
/*
This script is for updating the auto_increment field by an offset. The logic applied is
max(AUTO_INCREMENT) + current value in the table.
*/
SET @db:='id_new';
select @max_id:=max(AUTO_INCREMENT) from information_schema.tables;
select concat('update ',table_name,' set ', column_name,' = ',column_name,'+',@max_id,' ; ') from information_schema.columns where table_schema=@db and column_name like '%id' into outfile 'update_ids.sql';