Skip to content

Instantly share code, notes, and snippets.

View revans's full-sized avatar
🤠
Building Businesses

Robert Evans revans

🤠
Building Businesses
View GitHub Profile
@revans
revans / gist:1406
Created July 23, 2008 00:23
Merb Show Routes Task
desc "Show merb routes"
task :merb_routes => :merb_env do
require 'merb-core/rack/adapter/irb'
Merb::Rack::Console.new.show_routes
end
@revans
revans / git-merge-since.sh
Created February 12, 2014 20:25
Search the git log from a specific point in time for merge commits from one specific branch into another.
#!/bin/bash
#
# by: Robert Evans
#
# Git Merge Since Search
#
# I needed to be able to search git history looking for all merge commits from
# a specific repo, into another specific repo, starting at a given point in time.
#
# Example:
module TestMethodAlternatives
def testing(description, &block)
formatted_desc = description.gsub(/\s+/, '_').gsub(/\W+/, '')
define_method("test_#{formatted_desc}") do
if block_given?
instance_eval(&block)
else
instance_eval do
skip("test_#{formatted_desc}")
module AppSettings
class Railtie < Rails::Railtie
config.settings = ::ActiveSupport::OrderedOptions.new
end
end
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
$(document).watermark(
// "position" : "bottom-right",
// "opacity" : 30,
// "className" : "watermark",
"path": "/assets/watermark.png"
);
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOI+IZDMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM8=+++++++I7DMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM+++++++++++777$MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM++++++++++++?7777MMMMMMMMMMMMMMMMMMMMMMMMMMMM
@revans
revans / geo.rb
Last active August 29, 2015 14:00
class Geo
def self.get(coords)
sql = <<-EOF
SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":#{coords}}'))
EOF
ActiveRecord::Base.connection.execute(sql)
end
end
@revans
revans / demo.rb
Last active August 29, 2015 14:04
How to get the Next/Previous Record from an object. I'm using Rails 4.1.4, PostgreSQL 9.3.4 for the examples.
# Demo Database Object Schema:
#
# * name, string
# * status, integer
# * created_at, datetime
# * updated_at, datetime
#
class Demo < ActiveRecord::Base
include BaseScopes