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 / chat.rb
Created May 1, 2013 21:41 — forked from rkh/chat.rb
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
#######################################################################
# Setup Paths
function prepend_to_path -d "Prepend the given dir to the PATH if it exists and is not already
included within the PATH"
if test -d $argv[1]
if not contains $argv[1] $PATH
set -gx PATH "$argv[1]" $PATH
end
end
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
#!/usr/bin/env ruby
=begin
= Geographic Searches With Postgres's Earthdistance and Cube Extensions
This program shows how to easily create a Postgres database that uses the Cube
and Earthdistance extensions to perform fast queries on geographic data.
Briefly, the problem this code solves is "show me all places within 50
kilometers of New York City."
# see https://github.com/thomasjbradley/signature-pad for more details
instructions = JSON.load(data).map { |h| "line #{h['mx']},#{h['my']} #{h['lx']},#{h['ly']}" } * ' '
system "convert -size 198x55 xc:transparent -stroke blue -draw '#{instructions}' signature.png"
@revans
revans / instructions.md
Last active December 12, 2015 07:18
Setting up a new Machine in the most common way

Setting up a new Machine in the most common way

Install XCode

These days, go to Apple's app store and get Xcode.

Install XCode Command Tools

Open Xcode

http://production.cf.rubygems.org/gems/<name>-<version>-<platform>.gem
http://docs.rubygems.org/read/chapter/6#page20
@revans
revans / validate_original_gem.rb
Last active December 12, 2015 00:29
If you have a copy of the original .gem file that you pushed to rubygems.org, you can verify a checksum of both files.
#!/usr/bin/env ruby
#
# Usage:
# ruby validate_original_gem.rb /path/to/gem/gemname.rb
require 'openssl'
require 'digest/sha1'
require 'zlib'
module Verify
@revans
revans / validate_local_cache.sh
Created January 31, 2013 02:39
A script to validate your local gem cache against the public s3 repositories. If you find mismatches that contain both local and remote values, please post them in comments. For Rbenv
#!/usr/bin/env sh
set -e
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
require 'erb'
namespace :db do
namespace :generate do
desc "Generate a config/database.conf"
task :config do
db_example = Rails.root.join("config/database.yml.erb")
print "What is your password for your local database? (leave empty for no password): "
# get data