Skip to content

Instantly share code, notes, and snippets.

@thomie
thomie / 3d-project-all.ijm
Last active August 29, 2015 13:56
ImageJ Macro to 3D project all images in directory
// ImageJ Macro to 3D project all images in directory
//
// Created by Thomas Miedema
// February 15th 2014
//
// Tested with: ImageJ = 1.48q
// Probably works with: ImageJ >= 1.47o
// Doesn't work with: ImageJ = 1.46a
// rsb.info.nih.gov/ij/developer/macro/functions.html
@thomie
thomie / ghc-tickets.py
Last active August 29, 2015 14:02
Script for generating overview of open GHC tickets by component
#!/usr/bin/env python
# Script for generating
# https://ghc.haskell.org/trac/ghc/wiki/Status/Tickets
columns = (
('!', 'open tickets'),
('bug', 'bugs'),
('feature request', 'feature requests'),
('task', 'tasks'),
@thomie
thomie / binary-blobs-solution.sh
Last active August 29, 2015 14:07
GHC: test binary blobs solution with libff-tarballs
set -e
# ghc-tarballs contains big binary blobs. Windows developers really
# only need the latest version of it. One solution is to not use git,
# but just wget the files from some server.
# This is a git solution, which has the advantage that the full
# history of ghc-tarballs is tracked, while still only downloading
# the latest version initial.
rm -rf testrepo*
=====> T9586(normal) 4434 of 4635 [0, 3, 0]
Compile failed (status 256) errors were:
[1 of 1] Compiling Main ( T9532.hs, T9532.o )
ghc.exe: getMBlocks: VirtualAlloc MEM_COMMIT failed: The paging file is too small for this operation to complete.
*** unexpected failure for T9532(normal)
=====> T9681(normal) 4435 of 4635 [0, 4, 0]
timeout.exe: failed to create OS thread: The paging file is too small for this operation to complete.
264 [main] python2 5016 fhandler_dev_zero::fixup_mmap_after_fork: requested 0x6FFFD8A0000 != 0x0 mem alloc base 0x0, state 0x10000, size 132997997330432, Win32 error 1455
513 [main] python2 5016 C:\msys64\usr\bin\python2.exe: *** fatal error in forked process - recreate_mmaps_after_fork_failed
@thomie
thomie / rename-greens-functions.sh
Created August 18, 2010 09:13
Rename Green's functions
#!/bin/sh
FILES='
Makefile.am
*.hpp
*.cpp
*.py
test/Makefile.am
test/*.cpp
test/*.py
@thomie
thomie / self-replication.py
Created June 2, 2011 17:03
Self replicating code
x = 'print "x = " + chr(39) + x + chr(39) + "; exec(x)"'; exec(x)
@thomie
thomie / unique_permutations.pl
Created June 4, 2011 15:37
Unique permutations
# Generate all unique permutations of an array
# with possibly duplicate elements (multiset).
# unique_permutations(('A', 'B', 'B')) -> ABB BAB BBA
sub unique_permutations
{
my @results;
my (@list) = @_;
if ($#list == -1) {
return [()];
@thomie
thomie / double-dispatch.cpp
Created July 25, 2012 11:28
Double dispatch in C++
#include <stdio.h>
/* Forward declarations. */
class Structure;
class Plane;
class Cylinder;
void print2(Cylinder*, Plane*);
void print2(Plane*, Cylinder*);
void print2(Cylinder*, Cylinder*);
void print2(Plane*, Plane*);
@thomie
thomie / gist:5247145
Last active December 15, 2015 10:39 — forked from dxlbnl/gist:5245302
## Prelude.
from functools import partial
from itertools import chain, ifilter, islice, izip_longest
def compose(*funcs):
"""Return a function such that compose(a,b,c)(arg1, arg2, arg3)
is equivalent to a(b(c(arg1, arg2, arg3)))."""
# See http://bugs.python.org/issue1660179
def _composefunc(*args, **kw):
@thomie
thomie / coroutines.py
Last active December 15, 2015 20:49
Coroutines in Python
# Simple Generators
# http://www.python.org/dev/peps/pep-0255/
def producer():
a, b = 0, 1
while True:
a, b = b, a + b
yield a
def pull():
p = producer()