Skip to content

Instantly share code, notes, and snippets.

import basin
import string
from hashlib import sha1
## Fixed-length compact ids for compound keys. Given one or more strings, this will
## concat with delim (default '|'), sha1 hash the result, convert to the given base
## (default 62), truncate to the given length (default 12) and left-pad with zeros.
##
## *** WARNING MATH AHEAD ***
## Here's a handy way to approximate the birthday number for a given bitspace and a
@roundand
roundand / OpenWithSublimeText3.bat
Last active January 30, 2025 13:12 — forked from mrchief/LICENSE.md
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@martinnormark
martinnormark / BusinessLogicInstaller.cs
Created July 17, 2012 09:17
Castle Windsor IoC Container setup for ASP.NET MVC
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using MyApp.BusinessLogic.Facades;
namespace MyApp.Web.PresentationLogic.Container
{
public class BusinessLogicInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
@karmi
karmi / index.html
Created April 5, 2012 14:23
Animated bar chart
<!DOCTYPE html>
<html>
<head>
<title>Sliding Bar Charts</title>
<script src="http://mbostock.github.com/d3/d3.v2.min.js?2.8.1"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
body {
position: relative;
font-family: "Helvetica Neue";
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@rdingwall
rdingwall / DynamicJsonDeserializer.cs
Created February 22, 2012 12:22
RestSharp deserialize JSON to dynamic
// ReSharper disable CheckNamespace
namespace RestSharp.Deserializers
// ReSharper restore CheckNamespace
{
public class DynamicJsonDeserializer : IDeserializer
{
public string RootElement { get; set; }
public string Namespace { get; set; }
public string DateFormat { get; set; }
@rduplain
rduplain / client.py
Created October 5, 2011 19:29
Simple Python HTTP client for tests, maintains cookies.
import cookielib
import urllib
import urllib2
class Client(object):
def __init__(self):
self.cookie_jar = cookielib.CookieJar()
self.opener = urllib2.build_opener(
urllib2.HTTPCookieProcessor(self.cookie_jar))
@scottlittlewood
scottlittlewood / NewtonsoftJsonCodec.cs
Created December 9, 2010 10:57
OpenRasta Json Codec using the Newtonsoft.Json library
[MediaType("application/json;q=0.5", "json")]
public class NewtonsoftJsonCodec : IMediaTypeReader, IMediaTypeWriter
{
public object Configuration { get; set; }
public object ReadFrom(IHttpEntity request, IType destinationType, string destinationName)
{
using(var streamReader = new StreamReader(request.Stream))
{
var ser = new JsonSerializer();