Skip to content

Instantly share code, notes, and snippets.

View zeha's full-sized avatar
:shipit:
Shipping it

Chris Hofstaedtler zeha

:shipit:
Shipping it
View GitHub Profile
@zeha
zeha / post-receive-jenkins.rb
Created January 10, 2013 23:41
git post-receive hook for triggering Jenkins builds. Jenkins must be set up to poll the SCM, but the schedule can be empty.
#!/usr/bin/env ruby
#
# git config --add hooks.jenkins.giturl <git url you've configured in jenkins>
# git config --add hooks.jenkins.jenkinsurl https://your.jenkins.host/
require 'rubygems'
require "net/http"
require "uri"
repopath = File.expand_path(__FILE__ + '/../../').split('/')
@zeha
zeha / parseheader.py
Created January 30, 2013 13:45
parser for a tiny subset of the C preprocessor lang
def parseheader(headerstream, defined_constants):
depth = 0
ignoring = False
for line in headerstream:
line = line.strip()
if not line.startswith('#'):
continue
@zeha
zeha / ftdi_serial.py
Created February 5, 2013 13:55
partially pyserial compatible FTDI D2XX binding hard-coded to use 0403/0601 devices.
import ctypes
__all__ = ['FtdiSerial', 'FtdiException', 'FtdiTimeoutException']
libftdi = ctypes.CDLL('libftd2xx.so')
FT_OK = 0
class FtdiException(Exception):
@zeha
zeha / console.py
Created February 15, 2013 21:56
minimal interactive python interpreter. useless because you could just call code.InteractiveConsole().interact() instead.
from __future__ import print_function
import traceback
import sys
def run():
print("minirepl on Python", sys.version)
continued = False
line = None
while True:
try:
@zeha
zeha / dsl.py
Created February 16, 2013 02:04
Quick DSL example for Python
from __future__ import print_function
from contextlib import contextmanager
class DslRunner(object):
"""Runs Python code in the context of a class.
Public methods will be exposed to the DSL code.
"""
import ctypes
__all__ = ['FtdiSerial', 'FtdiException', 'FtdiTimeoutException']
libftdi = ctypes.CDLL('libftd2xx.so')
FT_OK = 0
class FtdiException(Exception):
@zeha
zeha / gist:5233288
Last active December 15, 2015 08:49
quick howto netns
assumption: your machine has eth0 bridged to br0 already
(everything as root)
create a new netns:
-------------------
ip netns add foo
ip netns exec foo bash
@zeha
zeha / bt-proximity.sh
Created May 2, 2013 10:38
bt-proximity: Check if your phone (or any other bluetooth device) is in range.
#!/bin/bash
# sudoers:
# username ALL = NOPASSWD: /usr/bin/hcitool, /bin/mount
# crontab:
# @reboot ~/Source/dotfiles/tools/bt-proximity
# one-time pairing:
# bt-device -c F0:XX:XX:XX:XX:XX
mkdir -p ~/.local/bt-proximity
@zeha
zeha / gist:5999375
Created July 15, 2013 11:49
gitignore for MPLAB X projects
*.d
*.pre
*.p1
*.lst
*.sym
*.obj
*.o
*.sdb
*.obj.dmp
html/
import codecs
import sys
from xml.dom.minidom import parse, parseString
def minimize(el):
attrs = []
for i in range(0, el.attributes.length):
attrs.append(el.attributes.item(i).name)
for attr in attrs:
if el.getAttribute(attr) == "" or el.getAttribute(attr) == "0":