Skip to content
View geo.rb
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
View gist:9961560
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOI+IZDMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM8=+++++++I7DMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM+++++++++++777$MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM++++++++++++?7777MMMMMMMMMMMMMMMMMMMMMMMMMMMM
View sample.js
$(document).watermark(
// "position" : "bottom-right",
// "opacity" : 30,
// "className" : "watermark",
"path": "/assets/watermark.png"
);
View reshaping_the_command_approach.rb
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
View app_settings.rb
module AppSettings
class Railtie < Rails::Railtie
config.settings = ::ActiveSupport::OrderedOptions.new
end
end
View extend_minitest_with_def_alternative.rb
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}")
View git-merge-since.sh
#!/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:
View project_template.rb
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
View user_script.sh
#!/usr/bin/env bash
#
# Author: Robert R Evans
#
# Description: AWS Ubuntu 13 Ruby Setup Script
#
# This script will setup a ubuntu box for Ruby, Rails, Sinatra, and/or Rack
# development/staging/production usage. It also installs Nodejs, Nginx, Git,
# Rbenv, and PostgreSQL adapters for using RDMS PostgreSQL. It assumes that
# git-deploy will be used, in place of the traditional capistrano deployments.
View object_diagnostics.rb
module ObjectDiagnostics
extend self
#This is handy when you want to determine what types of objects are contributing to memory bloat
#returns the change in object counts since the last time this method was called
def change_in_object_counts
#this will start all counts at 0 for the initial run
@previous_counts ||= Hash.new(0)
Something went wrong with that request. Please try again.