Navigation Menu

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 / LocalTimezoneDatabase.mkd
Last active June 8, 2020 12:08
This is a pretty rough explanation, with some examples, of how to setup a PostgreSQL database with PostGIS, and build your timezone table that you can query, given a latitude and longitude.

Installing and Setting a Timezone database

We're using Rails 4, PostgreSQL 9.3.4, and PostGIS 2.1.2.

Creating a Postgis enabled Postgresql template

createdb -E UTF8 template_postgis
createlang -d template_postgis plpgsq
psql -d template_postgis -c "CREATE EXTENSION postgis WITH SCHEMA public;"
@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
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOI+IZDMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM8=+++++++I7DMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM+++++++++++777$MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM++++++++++++?7777MMMMMMMMMMMMMMMMMMMMMMMMMMMM
$(document).watermark(
// "position" : "bottom-right",
// "opacity" : 30,
// "className" : "watermark",
"path": "/assets/watermark.png"
);
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
module AppSettings
class Railtie < Rails::Railtie
config.settings = ::ActiveSupport::OrderedOptions.new
end
end
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}")
@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:
root(appname) do
mkdir "config"
mkdir "log"
mkdir "test"
touch "Readme.mkd"
template "config.ru", file_or_string
template "config/application.rb", file_or_string
cp "test/test_helper.rb", file_or_string
template "bin/script", file_or_string