Skip to content

Instantly share code, notes, and snippets.

@philikon
philikon / wtf8.py
Created February 8, 2011 08:22
WTF-8 codec for Python
# wtf8.py
import codecs
def encode(input, errors='strict'):
return input.encode('utf-8', errors).decode('latin-1', errors).encode('utf-8', errors), len(input)
def decode(input, errors='strict'):
return input.decode('utf-8', errors).encode('latin-1', errors).decode('utf-8', errors), len(input)
class StreamWriter(codecs.StreamWriter):
@benjchristensen
benjchristensen / index.html
Created August 16, 2011 03:21
Animated Line Graphs / Sparklines using SVG Path and d3.js
<html>
<head>
<title>Animated Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
@ryangray
ryangray / buttondown.css
Created February 22, 2012 06:45
A clean, minimal CSS stylesheet for Markdown, Pandoc and MultiMarkdown HTML output.
/*
Buttondown
A Markdown/MultiMarkdown/Pandoc HTML output CSS stylesheet
Author: Ryan Gray
Date: 15 Feb 2011
Revised: 21 Feb 2012
General style is clean, with minimal re-definition of the defaults or
overrides of user font settings. The body text and header styles are
left alone except title, author and date classes are centered. A Pandoc TOC
@davidbgk
davidbgk / postsql.sql
Created May 17, 2012 23:53 — forked from tobyhede/postsql.sql
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- JSON Types need to be mapped into corresponding PG types
--
-- Number => INT or DOUBLE PRECISION
-- String => TEXT
@ThomasChiroux
ThomasChiroux / httpserve.py
Created September 26, 2012 09:11
python2 and python3 compliant simple http server
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""launch small http server
"""
import sys
try:
from SimpleHTTPServer import SimpleHTTPRequestHandler
except ImportError:
@markjaquith
markjaquith / gist:4500280
Last active April 17, 2024 21:06
Bash command to fix a quirk with Sublime Text 2's "subl" command. Sometimes, when using it, under hard-to-pinpoint circumstances, it will open up Sublime Text 2 completely blank (i.e. the file you asked it to open will not be open). This snippet fixes that by essentially kicking subl under the table to wake it up and then passing on the command …
function subl() {
if [[ ! -p /dev/stdin ]]; then
command subl > /dev/null 2>&1
fi
command subl "$@"
}
@n1k0
n1k0 / 404checker.js
Created January 11, 2013 10:55
A CasperJS script to check for 404 & 500 internal links on a given website
/**
* This casper scipt checks for 404 internal links for a given root url.
*
* Usage:
*
* $ casperjs 404checker.js http://mysite.tld/
* $ casperjs 404checker.js http://mysite.tld/ --max-depth=42
*/
/*global URI*/
@metamatik
metamatik / gist:5270253
Created March 29, 2013 11:15
magopian t'apprend l'encodage
<magopian> m'en fou je suis en passe de finir le portage de IMAPClient vers python3
<magopian> c'est kiffant l'open source quand même
<mrjmad> :)
<mrjmad> putain je sais pas quand je vais commencer a m'y mettre a py3 bordel
<Linovia> d'ailleurs, qui a commencé à vraiment utiliser python3 ?
<mrjmad> tu tentes aussi le django en py3 magopian ?
<mrjmad> Linovia, moi j'ai mis dans ma todo list 'comprendre comment faire du py3 ' :)
<Linovia> mrjmad: oO
<mrjmad> (par la je veux dire, comprendre toutes les modifs entre les 2 versions, etre capable de savoir exactement les points d'achoppement dans une migration 2.7 -> 3, etre capable de 'penser' en 3.X , etc .. )
<mrjmad> ( je suis encore très light sur pas mal de sujet, genre le utf8 tout ca , pour me dire avec sérénité que je peux faire des migrations 2.7 -> 3.X )
@gnarf
gnarf / ..git-pr.md
Last active April 12, 2024 22:00
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@nfroidure
nfroidure / gist:5696893
Last active December 18, 2015 00:29 — forked from brunobord/gist:5695039
// -------- Database section
// current version
var __versions__ = ['1.0.1','1.0.2','1.0.3'];
var __version__ = localStorage.getItem('db:version')
||__versions__[__versions__.length-1];
function migrate_1_0_1() {
console.log('going into migrate_1_0_1');
}
function migrate_1_0_2() {