Skip to content

Instantly share code, notes, and snippets.

@uhnomoli
uhnomoli / attr_list.py
Created August 20, 2013 22:13
Enables attribute list support for lists in Python Markdown.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
from markdown.extensions import Extension
from markdown.extensions.attr_list import AttrListTreeprocessor as _AttrListTreeprocessor, isheader
from markdown.util import isBlockLevel
<?php
error_reporting(E_ALL);
define('NUM_FEATURES', 3);
// My dataset describes cities around the world where I might consider living.
// Each sample (city) consists of 3 features:
// * Feature 1: average low winter temperature in the city
// * Feature 2: city population, in millions
@gpakosz
gpakosz / gist:2947616
Created June 18, 2012 09:18
vim - toggle between relative / absolute / no line numbering
if exists("+relativenumber")
set relativenumber " show relative line numbers
set numberwidth=3 " narrow number column
" cycles between relative / absolute / no numbering
function! RelativeNumberToggle()
if (&relativenumber == 1)
set number number?
elseif (&number == 1)
set nonumber number?
else
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@JoshuaEstes
JoshuaEstes / 000-Cheat-Sheets.md
Last active May 1, 2024 04:03
Developer Cheat Sheets for bash, git, gpg, irssi, mutt, tmux, and vim. See my dotfiles repository for extra info.
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@beberlei
beberlei / Document.php
Created May 18, 2011 10:46
My Symfony2 File Upload workflow
<?php
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @Entity
*/
class Document
{
@amundo
amundo / gist:288282
Created January 27, 2010 23:40
Super short intro to using cosine similarity in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# see http://www.fileslip.net/news/2010/02/04/language-id-project-the-basic-algorithm/
from math import sqrt
you = {'pennies': 1, 'nickels': 2, 'dimes': 3, 'quarters': 4 }
me = {'pennies': 0, 'nickels': 3, 'dimes': 1, 'quarters': 1 }
abby = {'pennies': 2, 'nickels': 1, 'dimes': 0, 'quarters': 3 }