Skip to content

Instantly share code, notes, and snippets.

@simonswine
simonswine / gist:5728575
Created June 7, 2013 11:10
Upgrade deploy key Gitlab 5.1 -> 5.2
#!/usr/bin/env python
import MySQLdb
import MySQLdb.cursors
sql = MySQLdb.connect(host="xyz", user="abc",passwd="def",db="f03_gitlab_production",cursorclass=MySQLdb.cursors.DictCursor)
@simonswine
simonswine / jenkins-latex.sh
Created August 6, 2013 05:59
Build script for building latex docs via jenkins in a cow chroot. (Pretty sure this isn't very secure, as anyone who has access to the git/svn/vcs can break out of chroot as root)
#!/bin/bash
# Clean up
rm -f *.pdf
cd source
# Entferne altes nicht gitiges
git clean -fx
cd $WORKSPACE
# Latex Base Builder erstellen
@simonswine
simonswine / gist:6429538
Created September 3, 2013 21:02
Remove all config files of uninstalled packages
$ sudo dpkg --purge $(dpkg -l | grep ^rc | awk '{print $2}' | tr "\n" " ")
@simonswine
simonswine / id_former03_vagrant.pub
Created March 27, 2014 13:32
id_former03_vagrant.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3Oz43/FDedO6lXNZttRV/cD0y8taDTnGTGjCF+71NHofdwgJugk17pxSqiE3prPt2T5VfkoO5ol+r8fsSP2qAe8Fz02AdcULb+Z8PrPeMnkp35dkNeQwnnwFknROh/3gQsmFFgZQNDInkI1IYgZAJuD+vqiRtNzT6MGjExT2kaaj/XxadaC4vm+AAh4KT/9m4AXpednGaOaMuu++7BRuNdFFO75ouI41KSl7cATvOzsKjUoHZncS23EAT9Ad7i51TFZ3EB/nBdaNwiNaKxJGU/kMPWtjKT1SnPR8gzz0/DMLhhQE5I2wjamA9IUXLfcyPDaozDVxm6JoxIL5FjlV6K9ML4hBwvSdOYwxXGYdGO1l+3Uou4X1ZNYxGVMHaBroqxKIoXi9LJGLjbsfJKbS5SqAmknCxhpev8cAw1hZz32dh8hnhktA2eaYUWIZA20/vt6ERmWejRruJ3URrQHzgI1v/ZqDzx26XBJ+Fbtn89RYcfDhDuYgYAF5tfDjLHBMowV7dlICLMi8VfLV2NAsnW4TCBI3z8rL63yOGQ/4J2kIrvreUczDYro9RocOHlABhKI0UesrbT3JOf59/aIwRGY+88H2jbD5RGbjYRESXmAoIHmh9519AR5QAo8n+TqitDbzUycz99+nKsN14QwkAQZStf2HEtBq6blo1TxFHqw== christian@pc-christian
@simonswine
simonswine / submodule2subtree.py
Created April 13, 2014 09:07
Integrate existing submodules as subtree
#!/usr/bin/env python
from __future__ import print_function
from git import Repo
import sys
import os
import shutil
def convert_submodule_to_subtree(r, sm, squash=True):
@simonswine
simonswine / show_gmail_ipv6_pain.sh
Last active August 29, 2015 14:01
Mail.log Debian Postfix Analyzer for Gmail v6 trouble
cat /var/log/mail.info | grep relay=gmail | ruby -ne 'm=/^(\S+\s+\S+\s+\S+).*(relay=[^, ]+).*status=(\S+)(.*)$/.match($_); printf "%s %-8s %-60s %s\n", m[1], m[3], m[2], m[4]'
@simonswine
simonswine / sync_keywords.rb
Last active August 29, 2015 14:06
Sync Keywords from Maildir to IMAP Server by comparing timstamps
require 'date'
require 'net/imap'
dictionary = {
'a' => 'Junk',
'b' => 'NonJunk',
'c' => '$label5',
'd' => '$label2',
'e' => '$label3',
'f' => '$label1',
@simonswine
simonswine / drop all tables
Created November 8, 2014 12:02
Shell oneliner drop all tables from xx
mysql -e "SELECT concat('DROP TABLE IF EXISTS ', table_name, ';') FROM information_schema.tables WHERE table_schema = 'xx';" | tail -n +2 | mysql xx
@simonswine
simonswine / stringcalc.rb
Last active August 26, 2015 19:57
StringCalc in ruby
class StringCalc
def self.calc(str)
# default regex to split
re_split = %r{[\n,]}
# regex for custom delimiter
m = str.match(%r{^//(.)})
re_split = %r{#{m[1]}} if m
# sum initial val
@simonswine
simonswine / main.go
Last active September 21, 2015 21:56
Go concurrency long and short task
package main
import (
log "github.com/Sirupsen/logrus"
"sync"
"time"
)
// work short is done right away
func workShort(id string) {