Skip to content

Instantly share code, notes, and snippets.

View ekarulf's full-sized avatar

Erik Karulf ekarulf

View GitHub Profile
@ekarulf
ekarulf / qr_service.py
Last active December 14, 2015 14:38
Iterating on a QR service Source: http://zacharyvoase.com/2013/03/06/qr-codify/ Install into ~/Library/Services using Automator
import sys
import subprocess
import tempfile
import urllib
with tempfile.NamedTemporaryFile(mode='w', suffix='.png') as f:
try:
subprocess.check_call('qrencode -V'.split())
except OSError:
print "Rendering QR Code using Google Charts API"
@ekarulf
ekarulf / mysqli-prepared.php
Created February 7, 2011 10:27
MySQLi Prepared Statement Helper
<?php
//
// mysqli-prepared.php
// Use PreparedQuery to ease use of prepared query calls
// Example:
// PreparedQuery($conn, "SELECT id, username FROM users WHERE email = ?", array("s", $_POST["email"])
//
function PreparedQuery($connection, $query, $params=array())
@ekarulf
ekarulf / code128.py
Created November 16, 2010 04:25
Code128 Python Generator (Uses PIL)
#!/usr/bin/env python
# Copyright (c) 2010 Erik Karulf ([email protected])
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@ekarulf
ekarulf / etree_import.py
Created November 10, 2010 09:39
Import ElementTree with preference to faster libraries
def etree(packages=('lxml.etree', 'xml.etree.cElementTree',
'cElementTree', 'elementtree.ElementTree')):
for pkg_name in packages:
try:
pkg = __import__(pkg_name)
except ImportError:
continue
else:
for subpkg_name in pkg_name.split('.')[1:]: # skip the base package
pkg = getattr(pkg, subpkg_name)
#!/bin/sh
#
# PROVIDE: minecraft
# REQUIRE: DAEMON
#
# Add the following lines to /etc/rc.conf to run minecraft:
#
# minecraft_enable (bool): Set it to "YES" to enable minecraft.
# Default is "NO".
# minecraft_java_flags (flags): Set flags here. More options in java(1)
@ekarulf
ekarulf / barcode_type.py
Created August 21, 2010 06:01
Common barcode formats
#!/usr/bin/env python
# -*- coding: ascii -*-
##############################################################################
# Copyright (c) 2010, Erik Karulf ([email protected])
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
/*
* NumericRangeCalculator.java
*
* Created on Sep 13, 2007, 12:14:01 PM
*
*/
package edu.wustl.asl.gs.common;
import edu.wustl.asl.utils.NumericRange;