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
import ctypes
__all__ = ['FtdiSerial', 'FtdiException', 'FtdiTimeoutException']
libftdi = ctypes.CDLL('libftd2xx.so')
FT_OK = 0
class FtdiException(Exception):
@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.
"""
@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 / 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 / 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 / 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('/')