This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DEBOUNCE_DELAY 100 | |
class Button | |
{ | |
public: | |
Button(int p_Pin) /*Constructor*/ | |
{ | |
l_Pin = p_Pin; | |
pinMode(l_Pin,INPUT); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def floor_to_minute(time, minutes): | |
time = time - datetime.timedelta( | |
minutes=time.minute % minutes, | |
seconds=time.second, | |
microseconds=time.microsecond) | |
return time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# lsusb.py | |
# Displays your USB devices in reasonable form. | |
# (c) Kurt Garloff <[email protected]>, 2/2009, GPL v2 or v3. | |
# (c) Kurt Garloff <[email protected]>, 9/2013, GPL v2 or v3. | |
# Usage: See usage() | |
from __future__ import print_function | |
import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(" ") |