Skip to content

Instantly share code, notes, and snippets.

View vindolin's full-sized avatar
:octocat:
Available for hire 😎

Thomas Schüßler vindolin

:octocat:
Available for hire 😎
View GitHub Profile
import subprocess
for line in subprocess.check_output('dd if=/dev/urandom of=output.dat bs=1M count=10', shell=True, stderr=subprocess.STDOUT):
print line.split(" ")
import fcntl
import termios
import sys
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
new = termios.tcgetattr(fd)
new[3] = new[3] & ~termios.ECHO # disable echo
termios.tcsetattr(fd, termios.TCSANOW, new)
#include <SoftwareSerial.h>
#include <DHT.h>
#define DHTTYPE DHT22
#define DHTPIN 12
#define LED_PIN 13
DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial dbgSerial(2, 3); // RX, TX
#!/usr/bin/env python
# lsusb.py
# Displays your USB devices in reasonable form.
# (c) Kurt Garloff <garloff@suse.de>, 2/2009, GPL v2 or v3.
# (c) Kurt Garloff <kurt@garloff.de>, 9/2013, GPL v2 or v3.
# Usage: See usage()
from __future__ import print_function
import os
@vindolin
vindolin / round_to_minutes.py
Last active August 29, 2015 14:06
round a datetime to minutes
import datetime
def floor_to_minute(time, minutes):
time = time - datetime.timedelta(
minutes=time.minute % minutes,
seconds=time.second,
microseconds=time.microsecond)
return time
@vindolin
vindolin / colortimeit.py
Last active August 29, 2015 14:06
Simple module for rought timing of python code
from __future__ import print_function
import time
print_func = print
def format_sec(milliseconds):
return '{:>8.3f} sec.'.format(milliseconds / 1000.0)
current_milli_time = lambda: int(round(time.time() * 1000))
#!/usr/bin/env python
from gi.repository import Clutter
import cairo
import math
color = lambda string: Clutter.color_from_string(string)[1] # shortcut
class CairoActor(Clutter.Actor):
'''a horizontal item inside a row'''
#define DEBOUNCE_DELAY 100
class Button
{
public:
Button(int p_Pin) /*Constructor*/
{
l_Pin = p_Pin;
pinMode(l_Pin,INPUT);
@vindolin
vindolin / gist:1f1247572659537b3915
Created August 15, 2014 06:03
Arduino Thumbstick
ThumbState_t thumbSt;
const bool DEBUG = false; // set to true to debug the raw values
int xPin = A2;
int yPin = A3;
int xZero, yZero;
int xValue, yValue;
int deadzone = 5; // smaller values will be set to 0
lass __WeakWrapper(object):
def __init__(self, sender, callback, *userdata):
self.weak_obj = weakref.ref(callback.im_self)
self.weak_fun = weakref.ref(callback.im_func)
self.userdata = userdata
self.sender = sender
self.handle = None
def __call__(self, source):
obj = self.weak_obj()