Skip to content

Instantly share code, notes, and snippets.

View sleepingkingstudios's full-sized avatar
💭
🚀

Rob Smith sleepingkingstudios

💭
🚀
View GitHub Profile
@sleepingkingstudios
sleepingkingstudios / gist:955676
Created May 4, 2011 18:05
Adding a :redcarpet Haml Filter to Rails
# Thanks to:
# http://stackoverflow.com/questions/1921777/how-to-write-a-haml-custom-filter
# config/initializers/haml_filters.rb
require 'haml/filters/redcarpet'
# lib/haml/filters/redcarpet.rb
require 'redcarpet'
module Haml::Filters::Redcarpet
@sleepingkingstudios
sleepingkingstudios / gist:972856
Created May 15, 2011 03:11
ArticlesController (original implementation)
# config/routes
match 'articles/*path' => "articles#static"
match '*path' => "articles#static"
# app/controllers/ArticlesController
class ArticlesController < ApplicationController
# GET /articles/:path
def static
module AttributeFiltering
# [ :flying, :not => :psychic]
def is(arg)
return true if arg.class == TrueClass
return false if arg.class == FalseClass || arg.class == NilClass
if arg.class == Array
put "It's an array! #{arg.inspect}}"
# lib/explore/models/location.rb
require 'controllers/action_delegate'
require 'util/argument_validator'
require 'util/text_processor'
require 'explore/models/edge'
require 'explore/parsers/location_parser'
module Explore::Models
@sleepingkingstudios
sleepingkingstudios / .zshrc
Last active August 21, 2020 20:37
Developing For Ruby and Rails
export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"
export PGDATA="/usr/local/var/postgres"
eval "$(rbenv init - zsh)"
alias ci="bundle exec rspec && bundle exec rubocop"
alias be="bundle exec"
alias bea="bundle exec appraisal"
alias loki="bundle exec thor"
alias osd="OVERMIND_PROCFILE=Procfile.dev overmind start"
@sleepingkingstudios
sleepingkingstudios / mixin.rb
Created August 17, 2014 23:38
Class-method inheritance.
# Implements module-based inheritance of both class- and instance-level
# methods.
module Mixin
def mixins
@mixins ||= []
end # accessor mixins
def mixins=(ary)
@mixins = ary
class Comparator
def initialize(actual, expected)
@actual = actual
@expected = expected
@errors = Hash.new { |hsh, key| hsh[key] = [] }
end # constructor
attr_accessor :actual, :expected, :errors
def eql?
alias git-list-branches="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'"
@sleepingkingstudios
sleepingkingstudios / mock_example_group.rb
Created June 20, 2017 19:11
Mock Implementations of RSpec components.
module Spec::Support
class ExampleGroup
class << self
attr_reader :description
def describe description
example_group = Class.new(self)
example_group.description = description