Skip to content

Instantly share code, notes, and snippets.

@JakeWharton
JakeWharton / seven_seg.py
Created April 14, 2009 18:43
Python function to generate seven-segment number strings. Derived from Knio.
def seven_seg(x):
'''
_ _ _ _ _ _ _ _
|_||_| ||_ |_ |_| _| _| || |
_||_| ||_| _| | _||_ ||_|
1111101101 = 1005
1101110001 = 881
1101111100 = 892
@JakeWharton
JakeWharton / gist:154713
Created July 25, 2009 06:08
Rudimentary implementation of pyy_tag/html_tag in C#
using System;
using System.Text;
using System.Reflection;
namespace pyysharp
{
public abstract class HtmlTag
{
private static string TAB = " ";
@JakeWharton
JakeWharton / Impersonator.cs
Created November 5, 2009 15:26
Allows you to execute code under another user's privileges.
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
namespace JakeWharton
{
public class Impersonator : IDisposable
{
private WindowsImpersonationContext ImpersonatedUser = null;
private IntPtr UserHandle;
@JakeWharton
JakeWharton / hookpuller.py
Created November 7, 2009 00:57
Takes a GitHub service hook POST and automatically updates the associated repo.
#!/usr/bin/env python
'''
Takes a GitHub service hook POST and automatically updates the associated repo.
'''
__license__ = '''
Copyright 2009 Jake Wharton
hookpuller is free software: you can redistribute it and/or modify
@JakeWharton
JakeWharton / ExpressionEvaluator.java
Created November 18, 2009 01:13
Java class to parse, evaluate, and convert between infix, prefix, and postfix expressions.
import java.util.ArrayList;
/***
* @name Expression Evaluator
* @author Jake Wharton
* @date 2005-11-07
*/
public class ExpressionEvaluator
{
public static enum EXPRESSIONTYPE
from rcdict import *
class User: pass
class Group(Model):
name = StringField()
admin = ForeignKey(User)
#users = ReverseForeignKey(User) generated automatically
class User(Model):
@JakeWharton
JakeWharton / post-receive
Created April 9, 2010 13:57
git post-receive hook for updating Trac 0.12
#!/usr/bin/python
import sys
import subprocess
GIT_PATH = '/usr/bin/git'
TRAC_ADMIN_PATH = '/usr/local/bin/trac-admin'
VALID_BRANCHES = ['master']
TRAC_ENV = '/path/to/trac'
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Basename;
use Getopt::Long;
#########################################################
# Flac to Mp3 Perl Converter - Terminal Edition
# Created by: Somnorific
# Based on: Scripts by Falkano and Nick Sklaventitis
@JakeWharton
JakeWharton / gist:506573
Created August 3, 2010 15:41
Disable any lazy loading of table properties by magical reflection voodoo
namespace JakeWharton.Utilities
{
public static class DataContextExtensions
{
/// <summary>
/// Disable any lazy loading of table properties by magical reflection voodoo.
///
/// See: http://stackoverflow.com/questions/3388276/disable-all-lazy-loading-or-force-eager-loading-for-a-linq-context
/// And: http://stackoverflow.com/questions/3396426/iterating-tables-in-a-context-and-the-properties-of-those-tables
/// And: http://stackoverflow.com/questions/3397843/how-to-determine-lazy-loaded-properties-at-runtime-on-a-linq-table
@JakeWharton
JakeWharton / IconCheckBoxPreference.java
Created August 9, 2010 16:37
IconCheckBoxPreference: An Android CheckBox preference with an optional Icon
package com.jakewharton.utilities;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import com.jakewharton.wakkawallpaper.R;