Skip to content

Instantly share code, notes, and snippets.

View mattgorecki's full-sized avatar

Matt Gorecki mattgorecki

View GitHub Profile
@mattgorecki
mattgorecki / gist:974920
Created May 16, 2011 17:32
web2py mobile browser detection
# Detect mobile device. Set to mobile view if available
from mobile.sniffer.detect import detect_mobile_browser
if detect_mobile_browser(request.env.http_user_agent):
mobile_view = '%s.mobile.%s' % (request.function, request.extension)
if os.path.exists(os.path.join(request.folder, 'views',request.controller, mobile_view)):
response.view = '%s/%s' % (request.controller, mobile_view)
@mattgorecki
mattgorecki / facedetect.py
Created July 21, 2011 02:14
Detecting faces with SimpleCV
#!/usr/bin/python
import SimpleCV
import time
import simplejson as json
import sys
if __name__ == "__main__":
captureDir = '/opt/display/applications/tldisplayclient/static'
ofilename = '%s/webcam-original.png' % captureDir
dfilename = '%s/webcam-detected.png' % captureDir
@mattgorecki
mattgorecki / socketio.py
Created November 18, 2011 03:23
Sending an event to a node.js socket.io server from Python.
import websocket
import thread
import time
import sys
from urllib import *
class SocketIO:
def __init__(self):
self.PORT = 5000
self.HOSTNAME = '127.0.0.1'
@mattgorecki
mattgorecki / gen_pass.py
Created April 16, 2012 03:39
Random, readable password generator for building initial passwords during signup
import string
import itertools
import random
def gen_pass():
initial_consonants = (set(string.ascii_lowercase) - set('aeiou')
# remove those easily confused with others
- set('qxc')
# add some crunchy clusters
| set(['bl', 'br', 'cl', 'cr', 'dr', 'fl',
@mattgorecki
mattgorecki / trapd.rb
Created June 7, 2012 15:59
Simple SNMP Trap receiver that dumps to a RabbitMQ queue
require 'rubygems'
require 'snmp'
require 'carrot'
require 'json'
q = Carrot.queue('traps', :durable => true)
m = SNMP::TrapListener.new(:Port => 162, :Community => 'snmpcommunity') do |manager|
puts "trapd.rb started..."
manager.on_trap_default do |trap|
@mattgorecki
mattgorecki / RaspberryPi-RFID
Created July 26, 2013 01:34
Python script to read RFID card from serial RFID reader attached to a Raspberry Pi. Also has a Exit button. The card swipe releases the maglock on the door.
#!/usr/bin/python2
import serial
import re, sys, signal, os, time, datetime
import RPi.GPIO as GPIO
BITRATE = 9600
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
@mattgorecki
mattgorecki / keybase.md
Created October 26, 2017 22:08
keybase.md

Keybase proof

I hereby claim:

  • I am mattgorecki on github.
  • I am abledanger (https://keybase.io/abledanger) on keybase.
  • I have a public key ASBQpN5WxiNBYmdRY-TEBfCy860Q-tp8tirCNsl8sdBejAo

To claim this, I am signing this object: