Skip to content

Instantly share code, notes, and snippets.

Dean Radcliffe deanius

View GitHub Profile
View ensure_column
# Alternative to add_column that will do nothing if a column by that name exists already
# Ensures a column of the name will exist - either creating it or leaving the existing one be
# Looks up the table_name in AR::Base's descendants to query them whether this column exists (by name) yet
# Currently does not ensure that the options for the column are the same, nor ensure all models are loaded
def self.ensure_column tn, cn, *opts
klass = begin
@@tables_to_classes ||=
ActiveRecord::Base.class_eval{ subclasses }.inject({}) do |map, this_class|
map[this_class.table_name] = this_class
View server.rb
# MY FIRST (NON-WORKING) ATTEMPT - borrowing from rails/lib/console_sanbox..
# I think it works only for console where a single connection can be counted on
# Allow for server to run in a mode where xactions are rolled back on exit,
# like script/console's --sandbox option. eg: > SANDBOX=1 script/server -p 3001
if ENV['SANDBOX']=="1"
conf = YAML::load( + '/config/database.yml'))[RAILS_ENV]
$stderr.puts conf.inspect
View gist:790002
memoizer = {};
function memosin(arg){
if( memoizer[arg] ){
return memoizer[arg]
memoizer[arg] = mysin(arg)
return memoizer[arg]
deanius / gist:1020227
Created Jun 11, 2011
On my Mac, lein is broken fresh off a bootstrapper install
View gist:1020227
hihat:clojure_1 $> lein repl
Exception in thread "main" java.lang.ClassNotFoundException: clojure.main
at Method)
at sun.misc.Launcher$ExtClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.Class.forName0(Native Method)
View gist:3166514
find . -mtime 1 # sort by modified time
deanius / ChessJS
Created Sep 6, 2013
BDD version of an incremental version of player-to-player chess
View ChessJS
<!DOCTYPE html>
<title>Jasmine Test Suite for Player-to-Player Chess</title>
<script type="text/javascript" src="//"></script>
<!-- script type="text/javascript" src="/js/jasmine-all-min.js"></script -->
<script type="text/javascript">
describe("Positions Vectors and Sides, oh my", function(){
deanius / Creative Problem Solving
Last active Dec 26, 2015
My versions of Eno Cards for Programmers
View Creative Problem Solving
  • Involve a different sense - draw it, or hand-wave it
  • Ask your question of a duck
  • Type your question out in a forum or chatroom
  • Validate your assumptions - what have you mis-taken for granted ?
  • Break it to learn: "If I break it this way, I expect it to do X"
  • Step away from it, activate your other senses
  • Resort to a cheat, clearly labeling it as HACK, and return right after the next problem
  • Look at the order in which you do things

Node 2 hour course


  • 0:00 - 0:05 Course Outline
  • 0:05 - 0:30 Discussion - What Is Node, Really ?
  • 0:30 - 0:55 Micro-challenges and review
  • 0:55 - 1:00 Break
  • 1:00 - 1:50 Labs - Learnyounode
  • 1:50 - 2:00 Review
View gist:7522293
deanius / Kangax JS Quiz #7.js
Created Jan 25, 2014
JS.Chi Explanation of Kangax Javascript Quiz problem #7 about the binding rules for 'this'
View Kangax JS Quiz #7.js
// JS.Chi Explanation of Kangax Javascript Quiz problem #7 about the binding rules for 'this'
// Dean Radcliffe, Deanius Solutions, Inc.
// Presenter Setup: Split-screen browser/sublime, using JsRun to execute in chunks
/************** SEEING IT *****************/
You can’t perform that action at this time.