Skip to content

Instantly share code, notes, and snippets.

Bill Burcham Bill

Block or report user

Report or block Bill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Bill
Bill / docker-compose.yml
Last active May 2, 2019
Run a local Hypothes.is annotation server (and the services it needs) via docker-compose
View docker-compose.yml
# This docker-compose.yml will run the Hypothes.is annotation server.
# (adapted from instructions here https://h.readthedocs.org/en/latest/INSTALL.html)
#
# Place this file in the working directory (clone of https://github.com/hypothesis/h)
# run with docker-compose up -d
#
# Now browse to Hypothes.is at http://192.168.59.103:8000/ and create an account
# You'll see the invitation email in Mailcatcher at http://192.168.59.103:1080/
# Click that invitation link and log in on your local Hypothes.is
# And you are ready to annotate!
View gist:33df1cc70abb30964397
(ns progress-light.core
(:require [clj-progress.core :as progress]
[clojure.core.async :as async :refer [>!! timeout chan alt!! thread]])
(:gen-class))
(def tick-ch
(chan))
(def done-ch
(chan))
View morse_fsa.rb
require 'singleton'
# This is a parser pattern based on regexp as lexer.
# Express your tokens as parenthesized regexps separated by
# alternation (|). Erroneous input causes immediate return.
module Parse
def parse( s, p, &block)
i = 0
while i < s.length do
View morse_regexp.rb
require 'singleton'
# This is a parser pattern based on regexp as lexer.
# Express your tokens as parenthesized regexps separated by
# alternation (|). Erroneous input causes immediate return.
module Parse
def parse( s, p, &block)
i = 0
while i < s.length do
# could pass i to match and use block form in newer lib
View application_controller.rb
before_filter :set_database_for_cluster_stuff
# SourceSpecific and subclasses (Content, Cluster) take up a lot of space so we want them in
# their own per-Domain databases. This hook injects the appropriate database connection based
# on the Domain gleaned from the request so subsequent access (during this request)
# will go to the appropriate database.
def set_database_for_cluster_stuff
config = ActiveRecord::Base.configurations[RAILS_ENV]
# Get the database name from the Domain
View gist:96776
# capture a yaml dump of an object like this:
# capture { y request }
module Kernel
def capture # pass a block to capture
old_stdout = $stdout
out = StringIO.new
$stdout = out
begin
yield
ensure
View gist:95507
# the approved way to add methods to example groups in rspec
# from David Chelimsky's comment here http://www.benmabey.com/2008/06/08/writing-macros-in-rspec/
Spec::Runner.configure do |config|
config.include(AssignMacro, :type => :controllers)
end
View gist:95498
module Spec
module Rails
class ControllerContext < Rails::Context
module ContextEvalInstanceMethods
def setup_extra
(class << @controller; self; end).class_eval do
include ControllerInstanceMethods
end
@controller.integrate_views! if @integrate_views
@controller.session = session
View Optimizing For Patches.rb
# BAD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42
# GOOD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42
View seed-fu.rb.diff
===================================================================
--- vendor/plugins/seed-fu/lib/seed-fu.rb (revision 3419)
+++ vendor/plugins/seed-fu/lib/seed-fu.rb (working copy)
@@ -20,7 +20,7 @@
raise "You must set at least one constraint." if constraints.empty?
@constraints = []
constraints.each do |constraint|
- raise "Your constraint `#{constraint}` is not a column in #{@model_class}. Valid columns are `#{@model_class.column_names.join("`, `")}`." unless @model_class.column_names.include?(constraint.to_s)
+ raise "Your constraint `#{constraint}` is not a column in #{@model_class}. Valid columns are `#{@model_class.column_names.join("`, `")}`." unless @model_class.column_names.include?(constraint.to_s) || association = @model_class.reflect_on_association(constraint)
@constraints << constraint.to_sym
You can’t perform that action at this time.