Skip to content

Instantly share code, notes, and snippets.

@haxney
haxney / gist:1841437
Created February 16, 2012 03:18
setentry object
typedef struct {
long hash; /* cached hash code for the entry key */
PyObject *key;
} setentry;
@haxney
haxney / gist:1841760
Created February 16, 2012 03:45
tricking python's set
a == b #=> false
hash(a) == hash(b) #=> true
ab = {a, b}
ba = {b, a}
ab == ba #=> true
list(ab) == list(ba) #=> false
@haxney
haxney / gist:1841863
Created February 16, 2012 04:02
differently-ordered equal sets
{0, 8} # => {8, 0}
{8, 0} # => {0, 8}
{8, 0} == {0, 8} #=> True
list({0, 8}) == list({8, 0}) #=> False
@haxney
haxney / gist:1841869
Created February 16, 2012 04:03
Some set elements reversed
{0, 8} #=> {8, 0}
{1, 9} #=> {9, 1}
{2, 10} #=> {10, 2}
{3, 11} #=> {3, 11}
{4, 12} #=> {4, 12}
{5, 13} #=> {13, 5}
@haxney
haxney / compiz.sh
Created February 27, 2012 19:13
Making Ubuntu usable again
$ sudo apt-get install compiz compizconfig-settings-manager
@haxney
haxney / simple-recursive.el
Created April 22, 2012 22:19
Simple way to find files recursively and evaluate a body there
(defmacro go-files (base-dir &rest body)
"Recursively open files, visiting each one and running BODY there."
`(recursive-files ,base-dir '(progn ,@body)))
(defun recursive-files (dir form)
(loop
for (file is-dir) in (directory-files-and-attributes
dir
t
;; Ignore "." and ".." directories, but is too aggressive
@haxney
haxney / denmark.csv
Created June 18, 2012 18:42
Eurostat import to Silk
GEO COUNTRY YEAR UNIT SECTOR Value
Denmark-2002 Denmark 2002 Millions of euro General government 100 829.0
Denmark-2003 Denmark 2003 Millions of euro General government 103 801.1
Denmark-2004 Denmark 2004 Millions of euro General government 107 505.9
Denmark-2005 Denmark 2005 Millions of euro General government 109 465.9
Denmark-2006 Denmark 2006 Millions of euro General government 112 841.5
Denmark-2007 Denmark 2007 Millions of euro General government 115 600.0
Denmark-2008 Denmark 2008 Millions of euro General government 121 145.8
Denmark-2009 Denmark 2009 Millions of euro General government 129 816.8
Denmark-2010 Denmark 2010 Millions of euro General government 136 225.5
@haxney
haxney / httpd.conf
Created June 19, 2012 21:04
Service FileMaker web publishing with Apache
LoadModule jk_module "c:/Program Files/FileMaker/FileMaker Server/Web Publishing/publishing-engine/web-server-support/apache-2.2/mod_jk.so"
JkWorkersFile "c:/Program Files/FileMaker/FileMaker Server/Admin/admin-helper/WEB-INF/conf/workers.properties"
JkMountFile "c:/Program Files/FileMaker/FileMaker Server/Admin/admin-helper/WEB-INF/conf/uriworkermap.properties"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkRequestLogFormat "%w %V %T"
@haxney
haxney / gist:3055728
Last active February 19, 2023 18:45
List monospace fonts in Emacs
;; Display all the monospace fonts available to Emacs in a dedicated buffer
(defun font-is-mono-p (font-family)
;; with-selected-window
(let ((wind (selected-window))
m-width l-width)
(with-temp-buffer
(set-window-buffer (selected-window) (current-buffer))
(text-scale-set 4)
(insert (propertize "l l l l l" 'face `((:family ,font-family))))
@haxney
haxney / ChromatoGen.R
Created July 20, 2012 14:24
Testing speed improvement in R
#!/usr/bin/env Rscript
##' Generate a Selected Ion Chromatogram (SIC) from a run in a database.
##'
##' Retrieves spectra from a MySQL database and generates an SIC using the
##' specified parameters. Database connection information *must* be passed in
##' using the following environment variables:
##'
##' - MZDB_HOST: Computer on which the database is running.
##' - MZDB_USER: Username for authentication.