This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
rescue_from Exception, :with => :handle_exceptions | |
private | |
def handle_exceptions(e) | |
case e | |
when CanCan::AccessDenied |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bases = require('bases'); | |
var crypto = require('crypto'); | |
// Returns a base-62 (alphanumeric only) string of the given length: | |
function randomStr(length) { | |
// We generate a random number in a space at least as big as 62^length, | |
// and if it's too big, we just retry. This is still statistically O(1) | |
// since repeated probabilities less than one converge to zero. Hat-tip to | |
// a Google interview for teaching me this technique! ;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |