Skip to content

Instantly share code, notes, and snippets.

@preshing
preshing / math.rb
Created October 27, 2013 15:04
MathJax tags for Octopress
#--------------------------------------------------------------
# MathJax tags for Octopress
#
# Put this in the plugins folder.
# Use a single "inlinemath" tag for inline math.
# Use a pair of "math/endmath" tags for math as a standalone paragraph.
# The "math" tag takes an optional size argument.
# You also need to include MathJax in the page header, for example by adding
# <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
# to source/_includes/custom/head.html
@preshing
preshing / list_modifications.py
Last active January 21, 2016 04:44
List the contents of folders recursively, sorted by modification time.
#! /usr/bin/env python
# License: http://creativecommons.org/publicdomain/zero/1.0/
# See http://preshing.com/20130115/view-your-filesystem-history-using-python
import optparse
import os
import fnmatch
import time
# Parse options
parser = optparse.OptionParser(usage='Usage: %prog [options] path [path2 ...]')
@preshing
preshing / gist:6663087
Created September 22, 2013 19:43
The example from http://preshing.com/20130922/acquire-and-release-fences, rewritten using Mintomic.
#include <mintomic/mintomic.h>
#include <time.h>
struct Message
{
clock_t tick;
const char* str;
void* param;
};
@preshing
preshing / validate.py
Created November 5, 2012 02:54
Python script to help validate 1MB Sorter
from subprocess import *
import time
def validate(sequence):
start = time.clock()
sorter = Popen('sort1mb.exe', stdin=PIPE, stdout=PIPE, stderr=PIPE)
for value in sequence:
sorter.stdin.write('%08d\n' % value)
sorter.stdin.close()
result = [int(line) for line in sorter.stdout]