Skip to content

Instantly share code, notes, and snippets.

@tdfischer
tdfischer / gist:4082680
Created November 16, 2012 00:16
generate imap message ranges from a list of ints
msgRanges = []
num = iter(sorted(numbers))
startNum = None
lastNum = None
try:
while True:
curNum = num.next()
if startNum is None:
startNum = curNum
lastNum = curNum
@tdfischer
tdfischer / gist:8214080
Created January 2, 2014 02:23
key cutter
#!/usr/bin/env python
import sys
keyPIN = str(int(sys.argv[1]))
print """
G94 ( use inches/min feed rate)
G20 ( use inches for coordinates )
G90 ( absolute coordinates )
G64 P0.00500 ( maximum deviation )
@tdfischer
tdfischer / makekey.py
Last active January 5, 2024 06:54
Schalge 5 Cylinder Key Generator https://noisebridge.net/wiki/Key_Milling
#!/usr/bin/env python
# makekey.py - A key making tool
# This program will accept a pin configuration for a Schalge 5 Pin lock and produce GCode to mill out the corresponding key.
#
# For example, this will produce a bump key:
# $ ./makekey.py 99999
#
# This could produce a key to something else:
# $ ./makekey.py 38457
#
#!/usr/bin/env python
from PyQt4 import QtCore, QtWebKit, QtGui
import sys
import random
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
layout = QtGui.QVBoxLayout(window)
// A pin has been written to and its value updated
void cb_write (BigEarSensorValue *sensor_value, GValue *value)
{
gchar *name;
gchar *contents;
g_object_get (sensor_value, "name", name);
contents = g_strdup_value_contents (value);
g_print ("Write to sensor's %s: %s\n", name, contents);
g_free (contents);
@tdfischer
tdfischer / main.c
Created April 18, 2014 10:51
entropy-control
#include <glib.h>
#include <entropy/client.h>
#include <entropy/resource.h>
#include <stdio.h>
GMainLoop *loop = NULL;
void
cb_download_file (EntropyClient *client, gchar **argv)
{
int main (int argc, char** argv)
{
EntropyCollection *collection;
GList *resources, cur;
collection = entropy_client_get_default_collection ();
resources = entropy_collection_sparql ("SELECT ?a { ?a a entropy:Resource . ?a dc:title \"Anamanaguchi\" . ?a a nfo:Audio .?a nmm:streamingBitrate ?b . FILTER (?b < 128.0 )}");
cur = resources;
while (cur) {
#include <graviton/client/cloud.h>
#include <stdlib.h>
static void
cb_browse (GravitonCloud *cloud, GravitonServiceEvent event, GravitonServiceInterface *iface, gpointer user_data)
{
GError *error = NULL;
switch (event) {
case GRAVITON_SERVICE_NEW:
g_print ("Found a door. I'm opening it!\n");
@tdfischer
tdfischer / browser.py
Created July 20, 2014 08:14
self browsing webbrowser
#!/usr/bin/env python
from PyQt4 import QtCore, QtWebKit, QtGui, QtDeclarative
import sys
import random
app = QtGui.QApplication(sys.argv)
view = QtDeclarative.QDeclarativeView(QtCore.QUrl("browser.qml"))
view.show()
@tdfischer
tdfischer / Graviton.cpp
Created November 8, 2014 06:04
Arduino Graviton
#include "Graviton.h"
GravitonFleck::GravitonFleck(const char* serviceName, const GravitonDriver* driver, const GravitonFleckMethod methods[]) :
m_service (serviceName),
m_driver (driver),
m_methods (methods)
{}