Skip to content

Instantly share code, notes, and snippets.

View tef's full-sized avatar
💭
Please don't try to contact me over GitHub.

tef tef

💭
Please don't try to contact me over GitHub.
View GitHub Profile
@tef
tef / foo.md
Last active December 22, 2015 16:28
tef-taco
  1. make a bacon sandwich. why not put a bit of soy and cumin in the pan.
  2. use the bacon fat to fry some onions for like 40 minutes
  3. in the meantime, go and chop up some spring onions, cherry tomatoes and leaf salad. put in a bowl with a pinch of fresh coriander and a squirt of lime juice
  4. still in the meantime, go and chop up some garlic (like a bulb), some chilli
  5. take some beef mince, some diced chorizo and whip it up with some paprika, coriander, soy, tamari, gochujang, pepper, cayenne pepper, worchestershire sauce, maybe a hint of chipolte, and a whizz of lime juice. oh and i used ginger
  6. chuck chilli and garlic in the pan after the onions have gotten impatient (around 30-40-50 minutes)
  7. wait a little longer, about 10 minutes, and mash the meat into the pan and fry
  8. make some gnocchi.
  9. now everything smells tasty, and the meat is browned and cooked, chuck in some (whatever) beans from a tin.
  10. take the cooked gnocchi and chop it a little and stick it in the pan too. ooh
1. pandoc -D latex > pandoc.template.jp.tex
2. following instructions from https://groups.google.com/d/msg/pandoc-discuss/R8T4j7SrJXk/EXNLBcm28z0J
go into the .tex file and change the XeTeX part so it reads:
\ifxetex
\usepackage{fontspec,xltxtra,xunicode,xeCJK}
\setCJKmainfont{Kochi Mincho}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[utf8]{inputenc}
@tef
tef / sort.py
Last active December 25, 2015 11:19 — forked from ntlk/sort.py
from sys import stdin, stdout
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-r', action='store_const', const=True, required=False, default=False)
args = parser.parse_args()
stdout.writelines(sorted(stdin.readlines(), reverse = args.r))
@tef
tef / gist:7040514
Created October 18, 2013 11:56
quines are easy in php :-)
$ cat > quine.php
Hello, World!
$ php quine.php
Hello, World!
$
@tef
tef / jptest.tex
Created October 22, 2013 16:12
Test of CJK in XeLaTeX
% Install these fonts http://ipafont.ipa.go.jp/#en
\documentclass[12pt]{article}
\usepackage{fontspec, xunicode, xeCJK}
\setCJKmainfont{IPAexMincho}
\setCJKsansfont{IPAexGothic}
\setCJKmonofont{IPAexGothic}
\begin{document}
Hello World, or こんにちは 世界!
\end{document}
@tef
tef / sortstuff.py
Last active December 27, 2015 20:29
#!/usr/bin/env python3
import random
def msort(array, compare):
l = len(array)
if l > 2:
mid = l//2
left = msort(array[:mid], compare)
right = msort(array[mid:], compare)
return merge(left, right, compare)
class ShittyHashTable:
def __init__(self, buckets = 8):
self.buckets = []
for x in range(8):
self.buckets.append([])
def add(self, key, value):
n = shittyhash(key, len(self.buckets))
bucket = self.buckets[n]
for i, pair in enumerate(bucket):
possible assignments:
- add tests to check the behaviour is correct.
don't compare it to python's output, just check that each element is greater than the
next, with the compare function
- add profiling code, and run it with much, much larger lists ~5000 elements
which one is fast, slow?
- quick sort picks a random pivot, is this a good choice? what happens on larger lists
# based upon http://www.johndcook.com/standard%5Fdeviation.html
from collections import OrderedDict
class RunningStat(object):
def __init__(self):
self.n = 0
self.m = None
self.s = None
self.min = None
self.max = None