Skip to content

Instantly share code, notes, and snippets.

@tgs
tgs / poor_mans_hist3.matlab
Created March 23, 2011 20:49
Make a 2d or 3d histogram to visualize data density
% Code from http://goo.gl/lhXpN (Doug Hull's mathworks blog)
% With changes suggested by Andrea and Thomas in the comment thread
%
% See also "cloudplot":
% http://www.mathworks.com/matlabcentral/fileexchange/23238-cloudplot
% put your input data as vertical arrays in x and y
x = randn(100000,1);
y = randn(100000,1) * 20;
@tgs
tgs / MissingBundleComplainer.java
Created December 6, 2011 20:51
Complain about ".tests" bundles that aren't activated
package org.cishell.testcollector;
import java.io.File;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.tap4j.model.Plan;
@tgs
tgs / MANIFEST.MF
Created February 10, 2012 14:49
Demo of a bug in Tycho staged 0.14.0, version checking is stricter than auto version updating
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: manifest-version-bug
Bundle-SymbolicName: manifest-version-bug
Bundle-Version: 1
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
@tgs
tgs / coursebuilder-bytecodecache-1.4.1.patch
Created August 5, 2013 21:44
Patch to Google Course Builder v1.4.1, adding caching of the bytecode of Jinja2 templates. Change to the root dir of your course builder installation and use patch -p2 < (this file)
diff --git a/coursebuilder/common/jinja_filters.py b/coursebuilder/common/jinja_filters.py
index 2bb6d17..a8a6261 100644
--- a/coursebuilder/common/jinja_filters.py
+++ b/coursebuilder/common/jinja_filters.py
@@ -17,8 +17,10 @@
__author__ = 'John Orr (jorr@google.com)'
import jinja2
+from jinja2.bccache import BytecodeCache
import safe_dom
@tgs
tgs / coursebuilder-bytecodecache-1.5.0.patch
Created August 5, 2013 21:56
Patch to Google Course Builder v1.5.0, adding caching of the bytecode of Jinja2 templates. Change to the root dir of your course builder installation and use patch -p2 < (this file). Version 1.5.1 will probably include this patch.
diff --git a/coursebuilder/common/jinja_utils.py b/coursebuilder/common/jinja_utils.py
index 9854a44..a5501e0 100644
--- a/coursebuilder/common/jinja_utils.py
+++ b/coursebuilder/common/jinja_utils.py
@@ -18,8 +18,10 @@ __author__ = 'John Orr (jorr@google.com)'
import jinja2
from webapp2_extras import i18n
+from models.models import MemcacheManager
import safe_dom
@tgs
tgs / appengine_bytecode_cache.py
Last active May 13, 2016 07:13
A version of Jinja2's MemcachedBytecodeCache with two extra features: support for namespaces, as used in Google App Engine's memcache module; and the ability to clear the cache.
from jinja2.bccache import BytecodeCache
__author__ = "Thomas Grenfell Smith (thomathom@gmail.com)"
class ClearableMemcachedBytecodeCache(BytecodeCache):
"""Requires a fancy memcache client, like Google App Engine's,
that supports namespaces. Requires get, set, add, and incr.
When you call .clear(), the entries previously stored through
this object become inaccessible through it, although they
@tgs
tgs / ckbleach.py
Created November 22, 2013 18:47
Convert the specification of allowed tags, attributes, etc. for Python's Bleach module, into a list that CKEditor understands. This is useful because, if you don't tell CKEditor what tags it can use, it will likely use ones you don't want to allow through.
import StringIO
def allowed_content(tags, attributes={}, styles=()):
"""
Given a list of allowed tags, dict of allowed attributes, and list of
allowed styles, generates a CKEditor 'allowedcontent' string. The default
lists used by the bleach module are: bleach.ALLOWED_TAGS,
bleach.ALLOWED_ATTRIBUTES, and bleach.ALLOWED_STYLES (which is empty by
default). This function's defaults are all empty lists/dicts.
@tgs
tgs / psalm-104-parker.txt
Created February 7, 2014 16:38
Matthew Parker's English translation of Psalm 104, published 1650.
Psalm 104
Translated by
Matthew Parker (1504-1575), Archbishop of Canterbury
The Argument. Psalme. CIIII.
This Psalme setth out: for prouidence,
Almighty Gods: magnificence:
His wisdome, power: his goodnes eke,
Of night, of day: of yere, of weeke,
His excellence: all thyng doth kepe.
@tgs
tgs / README.md
Last active August 29, 2015 14:00
Fun twiddly lines

Click it to make it go again.

A d3.js version of the "egyptian" effect used in Tron. A few really fun pages over here by GMUNK were the inspiration.

@tgs
tgs / README.md
Last active August 29, 2015 14:01
Star thingy

Zing, pow

Click it to make it go some more