Skip to content

Instantly share code, notes, and snippets.

View ties's full-sized avatar

Ties de Kock ties

  • The Netherlands
View GitHub Profile
@ties
ties / vgcopy.py
Last active December 30, 2015 09:59
Small script that parses the output of [lvm2defrag](http://bisqwit.iki.fi/source/lvm2defrag.html) and uses it to build a script that copies all volumes from `source_vg` to `target_vg`
#
# Read the dump made by lvm2defrag and calculate the total size per lv
#
import glob, itertools, re
from collections import defaultdict
from optparse import OptionParser
"""
Read 'dump.txt' generated by lvm2defrag and gather all it's fragments
@ties
ties / channels.py
Last active December 31, 2015 10:18
Quick and dirty script to add all the channels from the VCK IPTV (vlc) playlist to tvheadend
#
# Parse all multicast URL's from the IPTV stream list
#
import json, os, collections, re, requests, urlparse
TVHEADEND_USER = ''
TVHEADEND_PASS = ''
assert TVHEADEND_USER and TVHEADEND_PASS
TVHEADEND_ROOT = 'http://server:9981/'
import bz2
BUFFER_SIZE = 4096
def stream_bz2(fn):
buf = bytearray(BUFFER_SIZE)
with bz2.BZ2File(fn) as b2f:
while True:
s_r = b2f.readinto(buf)
#!/usr/bin/env python
"""
One of my machines runs multiple KVM vm's.
When the host needs to reboot i suspend the vm's first using this quick and dirty script.
After the reboot there is some time skew in the vm's (they continue at the time of the
suspend). You either need to use one of these solutions;
* reboot the vm's. They will pickup the correct time...
* manually stop ntp (service stop ntp) and let ntpd fix the time with a large step (ntpd -gq)
* setup ntp to skew the clock faster
# SSL config snippet for apache
SSLProtocol -ALL +SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2
SSLCipherSuite EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4
SSLHonorCipherOrder on
#SSLCipherSuite HIGH:MEDIUM
# HSTS
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains"
listen [::]:443 ipv6only=on ssl default_server;
ssl_session_cache shared:SSL:10m;
ssl on;
ssl_certificate <unified certificate chain>;
ssl_certificate_key <private key>;
ssl_dhparam <dh param>;
ssl_session_timeout 5m;
@ties
ties / ossettings.pp
Created May 20, 2014 08:09
I moved all my defaults write commands from the readme into my boxen config. Pretty nice :)
class projects::ossettings {
# directory setup
$home = "/Users/${::boxen_user}/"
## java home
file_line { 'java_home':
path => "${home}/.profile",
line => 'export JAVA_HOME=`/usr/libexec/java_home`',
}
import os, shutil, os.path
"""
Crudely move all "dot"/hidden files from the current directory to a target dir.
... saved me 8GB of disk space and a lot of manual filtering after restoring some hidden files to Desktop.
Of course I could delete the Desktop dir. 20/20 hindsight...
"""
src_dir = "/Users/<user>/Desktop"
target_dir = "/Users/<user>/Desktop/<tgt>"
function encode(instr)
{
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var outstr = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
do {
chr1 = instr.charCodeAt(i++);
package com.haibison.android.lockpattern.widget;
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;