Skip to content

Instantly share code, notes, and snippets.

@EnigmaCurry
EnigmaCurry / textile_filter.py
Created April 20, 2011 18:35
A hacked blogofile textile filter to get around syntax_highlight filter issues.
def run(content):
content = content.replace("<pre>","<textile-pre>").replace("</pre>","</textile-pre>")
content = textile.textile(content)
content = content.replace("<textile-pre>","<pre>").replace("</textile-pre>","</pre>")
return content
@EnigmaCurry
EnigmaCurry / test_pypy_cache.py
Created May 1, 2011 18:08
PyPy 1.5 bug where call to __getitem__ differs from CPython 2.7.1
# This is a test case to describe a bug I'm seeing in PyPy 1.5. I have
# a Cache object that is a dictionary that supports lookup via regular
# attribute access. For instance:
#
# >>> c = Cache()
# >>> c["asdf"] = "asdf"
# >>> c.asdf == c["asdf"]
# True
#
# When looking up keys via attribute, PyPy 1.5 calls __getitem__
app.register_blueprint(view.contact, url_prefix="/contact")
@EnigmaCurry
EnigmaCurry / proofreadnow.user.js
Created September 28, 2012 00:54
A notification script for a work site.
// ==UserScript==
// @name ProofreadNOW alert
// @namespace enigmacurry.com
// @description Alert when a new job comes in
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js
// @include https://secure.proofreadnow.com/index2.html?*
// @version 1
// @grant none
// ==/UserScript==
@EnigmaCurry
EnigmaCurry / grep.py
Created January 9, 2013 22:03
python grep
def grep(pattern, file_obj, include_line_nums=False):
grepper = re.compile(pattern)
for line_num, line in enumerate(file_obj):
if grepper.search(line):
if include_line_nums:
yield (line_num, line)
else:
yield line
@EnigmaCurry
EnigmaCurry / bitaddress.py
Created March 16, 2013 18:26
Eliptic Curve / Bitcoin test.
# Just a test to see how Eliptic Curve DSA works in Bitcoin.
# This isn't production code, this was an exploratory process simply
# for me to learn about it.
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)
@EnigmaCurry
EnigmaCurry / .bashrc
Created August 28, 2013 17:27
Cassandra remote jconsole through SSH
function jc {
host=$1
proxy_host="$1 -p 22"
# Find just the hostname (if specified as user@host):
host=`echo $host | sed 's/.*@//'`
jmxport=7199
proxy_port=${2:-8123}
@EnigmaCurry
EnigmaCurry / LXC_HOWTO.markdown
Last active November 24, 2024 21:24
Linux Containers mini-HOWTO on Ubuntu

This is a mini-HOWTO for setting up Linux Containers (LXC) on Ubuntu. This guide focuses on the creation of a web server with good process isolation and firewalling.

Dependencies

apt-get install lxc

Create a container

@EnigmaCurry
EnigmaCurry / murmur3_hash.py
Last active August 29, 2015 13:57
Example of murmur3 hashing in Jython
from org.apache.cassandra.dht import Murmur3Partitioner
from org.apache.cassandra.utils import ByteBufferUtil
from java.lang import Integer
p = Murmur3Partitioner()
int_token = p.getToken(ByteBufferUtil.bytes(Integer(10)))
string_token = p.getToken(ByteBufferUtil.bytes("asdf"))
Verifying that +enigmacurry is my Bitcoin username. You can send me #bitcoin here: https://onename.io/enigmacurry