Skip to content

Instantly share code, notes, and snippets.

View samuelclay's full-sized avatar

Samuel Clay samuelclay

View GitHub Profile
# server
require 'rubygems'
require 'sinatra'
get '/temp' do
content_type :json
temp = `./temper`
bits = temp.split(' ')
"{ \"time\" : #{bits[0]}, \"fahrenheit\" : #{bits[2].gsub(/F/,'')}, \"celcius\" : #{bits[3].gsub(/C/,'')} }"
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@sstephenson
sstephenson / let.tcl
Created March 17, 2011 14:04
Lexical scoping in Tcl
#!/usr/bin/env TEST=1 tclsh
# Lexical scoping in Tcl
proc let {block args} {
try {
set captured_vars [uplevel [list capture [block args]]]
set all_var_names [uplevel {info vars}]
foreach var [block args] value $args {
uplevel [list catch [list unset $var]]
@mtigas
mtigas / tap_detect.sh
Created January 26, 2011 19:50
Shell script to detect whether your network connection is being tapped by your IT department or ISP.
#!/bin/bash
# I take absolutely no responsibility for anything that happens when you run this.
while true; do
curl -s "http://www.google.com/?q=hardcore+porn" > /dev/null &\
curl -s "http://www.google.com/?q=kiddie+porn" > /dev/null &\
echo -n "."
sleep 5