Skip to content

Instantly share code, notes, and snippets.

View simon-engledew's full-sized avatar
🙈

Simon Engledew simon-engledew

🙈
View GitHub Profile
@simon-engledew
simon-engledew / i18n_reverse.rb
Created April 17, 2014 11:46
Rails 3 i18n Progress Visualizer
# see how well you are doing localizing your site by flipping all localized text upside-down!
# anything being loaded from your en.yml will now be quite obvious!
if ENV['REVERSE']
module I18n::Backend::Base
def flip(c)
case c
when "a" then return "\u0250"
when "b" then return "q"
when "c" then return "\u0254"
@simon-engledew
simon-engledew / cards.html
Created February 25, 2014 20:41
HTML5 Line Cards
<!DOCTYPE html>
<html>
<head>
<script src="http://zeptojs.com/zepto.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.2/bacon.js" type="text/javascript"></script>
<style>
html, body {
height: 100%;
width: 100%;
@simon-engledew
simon-engledew / process_lock.rb
Last active August 29, 2015 13:56
Set of useful methods for creating a singleton process
class ProcessLock
def initialize(filename)
FileUtils.touch(@filename = filename)
end
def acquire!
File.open(@filename, 'r+') do |f|
lock(f, false) do
f.truncate(f.write(Process.pid))
@simon-engledew
simon-engledew / format.js
Last active December 26, 2015 08:59
String.format
String.format = function format()
{
var replacements = arguments;
return arguments[0].replace(/\{(\d+)\}/gm, function replace(string, match) {
return replacements[parseInt(match) + 1];
});
};
@simon-engledew
simon-engledew / post-receive
Created January 28, 2013 14:07
cow-say for git post-receive and campfire
#!/usr/bin/env python
import json
import requests
import json
import commands
import pipes
import sys
import glob
import os
@simon-engledew
simon-engledew / foreach.py
Created September 20, 2012 12:48
Python ForEach Naughtiness
import __builtin__
import operator
def merge(a, b):
a = a.copy()
a.update(b)
return a
class curry(object):
def __init__(self, fn, *args, **kwargs):
@simon-engledew
simon-engledew / xmlbuilder.py
Created September 8, 2011 14:09
Python magic to concisely generate XML
import xml.dom.minidom as xml
class Document(object):
"""
XML Document Builder
@author Simon Engledew
example:
dom = Document.catalog(version="1.0")
@simon-engledew
simon-engledew / BubbleBabble.cs
Created September 2, 2011 09:01
C-Sharp implemention of the Bubble Babble algorithm
public static class BubbleBabble
{
private static readonly string vowels = "aeiouy";
private static readonly string consonants = "bcdfghklmnprstvzx";
public static string Convert(byte[] bytes)
{
int seed = 1;
int rounds = 1 + bytes.Length / 2;
StringBuilder result = new StringBuilder();
@simon-engledew
simon-engledew / Dispatch.cs
Created August 25, 2011 14:57
Dispatch by Generic type
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Diagnostics;
using System.Threading;
namespace Ladybear
{
/// <summary>
/// Dispatches to an Action based on the first generic type parameter.
# config/environment.rb => require 'xmlrpc/client'
#XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, true)
XMLRPC::Config.const_set(:ENABLE_NIL_PARSER, true) unless XMLRPC::Config.const_defined?(:ENABLE_NIL_PARSER)
module XmlRpc
class Api
class << self
def method_missing(method, *args)