Skip to content

Instantly share code, notes, and snippets.

@t0mmyt
t0mmyt / bzip.py
Last active December 26, 2015 12:59
Populate dict from bzipped log file
def populate(file, result):
'''
Read bzipped syslog and match re below, append to dict referred to
by result.
Requires re and bz2
'''
f = BZ2File(file, 'r')
re_aide = re.compile('^\w+ \d+ \d\d:\d\d:\d\d ([\w\-\.]+) aide: (.*)$')
@t0mmyt
t0mmyt / gist:8518114
Created January 20, 2014 10:43
Difference in slave mysql log position
echo 'SHOW SLAVE STATUS\G' | mysql -u root -p$pw mysql | grep 'Master_Log_Pos' \
| awk '/Read/{a=$NF} /Exec/{b=$NF} END{print a-b}'
@t0mmyt
t0mmyt / replicate_GPT_part.sh
Created August 8, 2014 10:45
Replicate GPT partitions
# Replicate
sgdisk -R /dev/sda /dev/sdb
# Reandomise GUIDs
sgdisk -G /dev/sdb
@t0mmyt
t0mmyt / ks.cfg
Last active August 29, 2015 14:05
Kickstart for CentOS 6 with RAID
install
lang en_GB.UTF-8
keyboard us-acentos
network --device eth0 --bootproto dhcp
rootpw --iscrypted $6$n4QrpXe8$RkhuWPAuEIcng90FFRZrrXPi.Dd/W6tdy71TZ6gqMEXPyX4k9EdlZGlt7tiJVyF.ENPILHOroOOPD6F0wof1C1
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc UTC
bootloader --location=mbr --driveorder=hda
@t0mmyt
t0mmyt / gist:0c30003401942169580a
Last active August 29, 2015 14:14
Find the wavs that didn't get converted to mp3
find . -name \*.wav | while read line ; do bn=$(basename "$line") ; mp3=${bn%.*}.mp3 ; if [[ ! -f mp3/$mp3 ]] ; then echo $line ; fi ; done
@t0mmyt
t0mmyt / supa.sh
Created January 29, 2015 16:43
scala update-alternative
sudo update-alternatives --install /usr/bin/scala scala "/opt/scala/latest/bin/scala" 1
sudo update-alternatives --install /usr/bin/scalac scalac "/opt/scala/latest/bin/scalac" 1
sudo update-alternatives --install /usr/bin/fsc fsc "/opt/scala/latest/bin/fsc" 1
sudo update-alternatives --install /usr/bin/sbaz sbaz "/opt/scala/latest/bin/sbaz" 1
sudo update-alternatives --install /usr/bin/sbaz-setup sbaz-setup "/opt/scala/latest/bin/sbaz-setup" 1
sudo update-alternatives --install /usr/bin/scalap scalap "/opt/scala/latest/bin/scalap" 1
sudo update-alternatives --install /usr/bin/scaladoc scaladoc "/opt/scala/latest/bin/scaladoc" 1
@t0mmyt
t0mmyt / init.sh
Created February 21, 2015 22:40
Skeleton rpmbuild environment
#!/bin/sh
cd || exit 1 # Go home!
cat <<EOS >.rpmmacros
%_topdir %(echo $HOME)/rpmbuild
EOS
mkdir -p rpmbuild/{BUILD{,ROOT},{,S}RPMS,SOURCES,SPECS}
@t0mmyt
t0mmyt / nsd.spec
Created May 20, 2015 14:31
Spec file for NSD 4
Summary: Fast and lean authoritative DNS Name Server
Name: nsd
Version: 4.1.1
Release: 1
License: BSD
Url: http://www.nlnetlabs.nl/%{name}/
Source: http://www.nlnetlabs.nl/downloads/%{name}/%{name}-%{version}.tar.gz
Source1: nsd.init
Source2: nsd.cron
Source3: nsd.sysconfig
@t0mmyt
t0mmyt / vimrc
Last active August 29, 2015 14:23
vimrc
set ai sw=4 ts=4 sts=4 et bg=dark nu ml
set pastetoggle=<F2>
" Tabs!!
map <F8> :tabn<CR>
map <F7> :tabp<CR>
map <F6> :tabe
" Open the file you are cursor is currently over
@t0mmyt
t0mmyt / update-repo.sh
Last active August 29, 2015 14:23
Script to make (or update) a yum repo
#!/bin/bash
# Script to make (or update) a yum repo
workers=4
REPOS=()
# To add a repo, REPOS+=("name or description|directory")
REPOS+=("Centos 7 x86_64 - live|/var/repo/repo/live/7/x86_64/")
REPOS+=("Centos 6 x86_64 - live|/var/repo/repo/live/6/x86_64/")
#REPOS+=("Centos 5 x86_64 - live|/var/repo/repo/live/5/x86_64/")