Skip to content

Instantly share code, notes, and snippets.

View kennethreitz's full-sized avatar
🐍

Kenneth Reitz kennethreitz

🐍
View GitHub Profile
@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' })
# 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.
@mnot
mnot / link_header.py
Created October 15, 2009 00:41
link_header.py: HTTP Link header parsing
@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():
@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:
# 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 / backup.php
Created April 5, 2010 07:27
mediatemple-to-s3.php
#!/usr/bin/env php
<?php
set_time_limit(0);
$nDays = 300; // How many days of backups to keep?
// MySQL variables
$bBackupMySQL = true; // Do you want to backup MySQL databases?
$mysql = '/usr/bin/mysql';
$mysqldump = '/usr/bin/mysqldump';
$mysql_server = 'xxxx.com';
$mysql_username = 'xxxx';
@kennethreitz
kennethreitz / gist:432002
Created June 9, 2010 19:08
Pushing the limits.
Hardware:
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro6,2
Processor Name: Intel Core i7
Processor Speed: 2.66 GHz
Number Of Processors: 1
Total Number Of Cores: 2
#!/usr/bin/env python
"""xml2json.py Convert XML to JSON
Relies on ElementTree for the XML parsing. This is based on
pesterfish.py but uses a different XML->JSON mapping.
The XML->JSON mapping is described at
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
merge.tool=chdiff
mergetool.chdiff.cmd=/usr/bin/env chdiff --wait $LOCAL $REMOTE
mergetool.chdiff.keepbackup=false
mergetool.chdiff.trustexitcode=false
diff.tool=Kaleidoscope
difftool.Kaleidoscope.cmd=ksdiff-wrapper git "$LOCAL" "$REMOTE"
difftool.prompt=false