Skip to content

Instantly share code, notes, and snippets.

View kennethreitz's full-sized avatar
🌙

Kenneth Reitz kennethreitz

🌙
View GitHub Profile
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@kennethreitz
kennethreitz / oh-god.py
Created November 24, 2009 16:32
My first python script from 4 years ago. Wow.
def main():
import os, time
menu_selection = 0
while menu_selection != 5:
clear_screen()
mainmenu()
if menu_selection == 1:
clear_screen()
print_instructions()
elif menu_selection == 2:
@kennethreitz
kennethreitz / robot.py
Created November 24, 2009 16:20
Pacman Simulation for iRoomba (years ago, don't worry)
from create import *
from time import *
import create
robot = create.Create(3)
def wait():
sleep(.5)
def die():
@mnot
mnot / link_header.py
Created October 15, 2009 00:41
link_header.py: HTTP Link header parsing
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
@schacon
schacon / example_gist_create.rb
Created August 6, 2008 20:29
gist example api post
require 'net/http'
require 'uri'
# /api/v1/:format/new
# /api/v1/:format/gists/:user
# /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })