Skip to content

Instantly share code, notes, and snippets.

View mpickering's full-sized avatar

Matthew Pickering mpickering

  • Well Typed LLP
  • Sheffield, UK
View GitHub Profile
def parseInput(a,flag)
def handleOne(x)
if x.length == 1 or x =~ /^\+[a-z]$/
1
elsif x =~ /^-[a-z]$/
-1
else
x.chop.to_i
end
end
# -*- coding: utf-8 -*-
'''Takes plug.dj user playlists and uploads them to youtube, the playlists are uploaded with the same name as the playlist on plug
Require libraries
Youtube Data API from http://code.google.com/p/gdata-python-client/
USAGE:
@mpickering
mpickering / gist:2625015
Created May 6, 2012 23:39
pi approximation
len([1 for x,y in [[random.random() for t in range(2)] for i in range(1000000)] if math.sqrt(x**2+y**2)<=1])/250000.0
for (i in ids){
setTimeout(function(){
$.post('track',{id:ids[i]}, function(data){
done = done+1
setProgress(done,total)
console.log(data)
})}, i*1000)
@mpickering
mpickering / gist:3627034
Created September 4, 2012 21:49
fountain
#fountin
import random, math, itertools
def randomN(n):
while True:
yield random.randint(1,0.5*n*(n+1))
def stream(w):
rand = randomN(len(w))
all:
pandoc --filter pandoc-citeproc --variable="linestretch=2" --template=afterbody.tex -o minimal.pdf minimal.md
import Text.Pandoc.JSON
import Text.Parsec
import Control.Applicative
import Data.Monoid
main :: IO ()
main = toJSONFilter index
index :: Maybe Format -> Inline -> [Inline]
index (Just (Format f)) c@(Code _ s) =
@mpickering
mpickering / extrafile.md
Created August 19, 2014 10:00
Transclusion

This is the extra file.

Sat Dec 6 21:21 2014 Time and Allocation Profiling Report (Final)
pandoc +RTS -K16m -p -K4000M -RTS -f html -t plain -o plain.txt 76d21fc1321880f48eb6/bad.html
total time = 71.03 secs (71031 ticks @ 1000 us, 1 processor)
total alloc = 148,899,219,400 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
realLength Text.Pandoc.Pretty 30.3 27.6
@mpickering
mpickering / gist:f1718fcdc4c56273ed52
Created December 7, 2014 00:53
LaTeX Argument Parser
{-# LANGUAGE ViewPatterns #-}
module InTex where
import Text.Pandoc.JSON
import Text.Pandoc
import Data.List
main :: IO ()
main = toJSONFilter readFootnotes