Skip to content

Instantly share code, notes, and snippets.

View walterg2's full-sized avatar

George T Walters II walterg2

View GitHub Profile
@zumbojo
zumbojo / bijective.rb
Created July 9, 2011 22:09
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@walterg2
walterg2 / Character.js
Created June 13, 2012 11:51
Issue when attempting to initialize a Backbone model with invalid data
/*jslint nomen: true, regexp: true */
/*globals window, document, Backbone, _ */
var Character = Backbone.Model.extend({
alignments: {
"Evil": "Evil",
"Neutral": "Neutral",
"Good": "Good"
},
validate: function (attrs) {