Skip to content

Instantly share code, notes, and snippets.

View Spaceghost's full-sized avatar
👻
Building distributed and decentralized systems that run in the browser

Johnneylee Jack Rollins Spaceghost

👻
Building distributed and decentralized systems that run in the browser
View GitHub Profile
@Spaceghost
Spaceghost / Role.rb
Created December 25, 2010 17:24 — forked from joshrendek/Role.rb
class Role < ActiveRecord::Base
serialize :permissions
has_many :users
end
@Spaceghost
Spaceghost / DecryptWindowsProductKey.py
Created March 19, 2011 01:06
A script to decrypt windows product keys written in python
import _winreg
def DecodeKey(rpk):
rpkOffset = 52
i = 28
szPossibleChars = "BCDFGHJKMPQRTVWXY2346789"
szProductKey = ""
while i >= 0:
dwAccumulator = 0
- owner_only do
= link_to "My Control Panel", edit_bracket_path(@bracket), :title => 'Admin'
def set_cache_buster
response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "#{10.year.ago}"
end
@Spaceghost
Spaceghost / gist:998534
Created May 30, 2011 07:03 — forked from jejacks0n/gist:990160
Adding sprockets to evergreen for rails 3.1 and coffeescript (via /config/evergreen.rb)
# For Rails 3.1 asset packaging / sprockets support
# 1. Create a /config/evergreen.rb file and put these contents in it
# 2. Adjust the paths below (the provided ones are generic)
require ::File.expand_path('../application', __FILE__)
module Evergreen
class << self
def application_with_additions(suite)
app = application_without_additions(suite)
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@Spaceghost
Spaceghost / Gemfile
Created June 1, 2011 16:21 — forked from gvarela/Gemfile
web sockets with eventmachine and redis pub/sub
# A sample Gemfile
source "http://rubygems.org"
gem "redis"
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git'
gem "em-hiredis"
# gem "em-synchrony"
gem "em-websocket"
# It's pretty easy to set a custom method as the basis of your friendly_id if
# you want to incorporate information from another model in the friendly_id.
class City < ActiveRecord::Base
belongs_to :state
has_friendly_id :city_and_state, :use_slugs => true
# This will return something like "San Francisco, California". It can be used
# as a display name in your views, and also as the basis of the friendly_id
# because it will be processed by the plugin to remove spaces, punctuation,
MasterCourse -> MasterSection -> MasterStep -> MasterQuiz -> MasterQuestion -> MasterChoice
|| || ||
Course Step Choice
@Spaceghost
Spaceghost / undefined_method_oddity_spec.rb
Created April 1, 2012 09:18
An RSpec "undefined method" oddity
ubuntu-desktop-x64 :: ~/Code » rspec 2274040/undefined_method_oddity_spec.rb
FF
Failures:
1) UndefinedMethodOddity correctly complaints 'expected: 1 time, received: 2 times'
Failure/Error: subject.should_receive(:bar)
(#<UndefinedMethodOddity:0x000000010b7c68>).bar(any args)
expected: 1 time
received: 0 times