Skip to content

Instantly share code, notes, and snippets.

@outoftime
outoftime / CQL3 Allowed Type Transitions
Created February 1, 2014 19:38
List of type transitions that are allowed by a CQL3 ALTER TABLE statement
FROM TO ALLOWED?
===================================
ascii -> blob true
ascii -> boolean false
ascii -> decimal false
ascii -> double false
ascii -> inet false
ascii -> int false
ascii -> float false
ascii -> bigint false
class Object
def clip
string = to_s
IO.popen('pbcopy', 'w') { |io| io << string }
string
end
end
#
# Monkeypatching gem dependencies is a fact of life. But it's dangerous, because *any* update
# to a library might change internals that your patch depends on. This little snippet allows you
# to leave "reminders" in your code that you're relying on a particular version of a gem, and blows
# up if the gem loaded at runtime doesn't fit the requirement.
#
# Example:
#
# monkeypatch('awesome_lib', '1.2.2') do
# module AwesomeLib
@outoftime
outoftime / trie.rb
Created September 24, 2014 19:01
Ruby Trie
class Trie
include Enumerable
def initialize
@leaf, @children = false, {}
end
def <<(value)
add_enum(value_to_enum(value))
end
@outoftime
outoftime / start_passenger
Created September 25, 2014 19:22
Passenger standalone with debugger and pry
#!/usr/bin/env ruby
require 'bundler'
Bundler.setup(:default, :development)
require 'rack-debug/debugger'
require 'pry-remote'
system('rm', '-fv', 'tmp/rack-debug.*')
fork { exec 'bundle', 'exec', 'passenger', 'start' }
@outoftime
outoftime / dotmatrix_cheat_sheet.md
Last active August 29, 2015 14:07
Dotmatrix cheat sheet

Command line

General-purpose

hcd DIR Go to DIR in your $HASHROCKET_DIR
ll List contents of directory in long format
@outoftime
outoftime / hackbone.js
Last active August 29, 2015 14:08
Hackbone sketch
window.Hackbone = (function () {
var hackbone, setupEvents;
hackbone = {
extend: function (prototype) {
var view = Backbone.View.extend(prototype),
selector = view.prototype.el;
if (typeof selector !== 'undefined') {
class Post
include Cequel::Record
belongs_to :blog
key :id, :timeuuid, auto: true
column :author_id, :timeuuid
# other column definitions
def author
@author ||= User.find(author_id)
require 'active_support/all'
class FakeRegexp
def initialize(pattern)
@pattern = pattern
end
def matches?(str)
case
when pattern.empty?