Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'digest/md5'
require 'fastercsv'
require 'json'
require 'curb'
require 'pp'
data = []
@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(
@zeuxisoo
zeuxisoo / MAMP with Python-MySQLdb.txt
Created April 13, 2011 08:56
MAMP + Python-MySQLdb
1. Goto http://dev.mysql.com/downloads/mysql/
2. Select Platform: "Mac OS X"
3. Download mysql-5.5.11-osx10.6-x86.tar.gz
(Mac OS X ver. 10.6 (x86, 32-bit), Compressed TAR Archive)
4. Unzip it
5. Copy include folder into /Applications/MAMP/Library
6. Copy lib/* files into /Applications/MAMP/Library/lib
----
1. Goto http://sourceforge.net/projects/mysql-python/
@oponder
oponder / gist:1043432
Created June 23, 2011 19:36
Show git branch and time since last commit in a bash prompt
# Super messy and hacked together from what I saw at http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt, but then with time since last commit smooshed in
export PS1="\[\033[38m\]\u\[\033[01;34m\]:\W \[\033[31m\]\`ruby -e \"git_status = (%x{git status 2> /dev/null}); last_commit = (%x{git log --pretty=format:'%at' -1 2> /dev/null}).gsub(/^\* (.+)$/, '(\1) '); seconds = Time.now.to_f - last_commit.to_f; minutes = seconds.to_f / 60; ((seconds > 60*60*2) ? (time_since_commit = ('+2h')) : (time_since_commit = minutes.to_i.to_s + 'm') if (git_status != ''));print (%x{git branch 2> /dev/null}.split(%r{\n}).grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(' + time_since_commit.to_s + '|\1) ')\"\`\[\033[37m\]$\[\033[00m\] "
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@kohlmeier
kohlmeier / ka_bnet_numpy.py
Created March 26, 2012 21:59
Bayes net example in Python with Khan Academy data
#!/usr/bin/env python
from numpy import asmatrix, asarray, ones, zeros, mean, sum, arange, prod, dot, loadtxt
from numpy.random import random, randint
import pickle
MISSING_VALUE = -1 # a constant I will use to denote missing integer values
def impute_hidden_node(E, I, theta, sample_hidden):
@zmaril
zmaril / index.html
Created June 16, 2012 14:08 — forked from ilyabo/index.html
D3 tooltip using Bootstrap
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src=https://raw.github.com/gist/2941416/24172d26b3c802f5be54b3411863822cad6b8538/tooltip.custom.js"></script>
<script type="text/javascript" src="https://raw.github.com/gist/2941416/39fbe358eb3256e62401e2403735907fbe3f7a75/popover.js"></script>
</head>
<body>
<div id="chart"></div>
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 13, 2024 05:29
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@zmaril
zmaril / index.html
Created June 24, 2012 03:16 — forked from mbostock/.block
d3 bootstrap tooltips
<!doctype html>
<head>
<style>
body {
font: 10px sans-serif;
}
#main {
left: 25%;
position: absolute;
}
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active June 13, 2024 02:39
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx