Skip to content

Instantly share code, notes, and snippets.

var canvases = [];
var testIndex = 0;
function createCanvas( level )
{
var canvas = document.createElement('canvas');
var tests = document.getElementsByClassName( 'test' )
canvas.width = 300;
canvas.height = 150;
canvas.id = canvases.length;
# Batcan Style
class Project
# permission is enforced for all create/update/save calls. It is defined within the context of its own class and is only
# called when this particular permission is checked.
permission :save do |project, user|
next true if user.admin?
next true if project.owner == user
next true if project.collaborators.include?(user)
# at this point if we haven't returned true then we dont have permission. We are allowed to return a user readable
# string here (not sure if CanCan has this capability, I don't see it in the docs)
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
sudo dpkg -i elasticsearch-0.90.7.deb
@jhoffner
jhoffner / layout_options.rb
Last active December 10, 2015 16:08
A clean way to specify layout options for your rails options
class ApplicationController
helper_method :layout_options
def layout_options(options = nil)
@layout_options ||= Hashie::Mash.new(
title: "Default App Title",
menubar: true,
footer: true,
og_title: nil,
og_type: 'website',
@jhoffner
jhoffner / hash_make_dynamic.rb
Created September 7, 2012 15:54
Make any hash dynamic (so that you can access its hash values as properties)
class Hash
#
# Makes the hash dynamic, allowing its hash values to be accessed as if they were properties on the object.
#
def make_dynamic(cascade = false, allow_dynamic_new_properties = false)
self.extend(DynamicAttrs) unless is_a? DynamicAttrs
@allow_dynamic_new_properties = allow_dynamic_new_properties
if cascade