Skip to content

Instantly share code, notes, and snippets.

@lgrains
lgrains / Problems installing Postgres on 10.7.4
Created January 12, 2013 15:58
Files requested from here: https://github.com/mxcl/homebrew/wiki/troubleshooting when brew fails to install programs
HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install postgres
==> Downloading http://ftp.postgresql.org/pub/source/v9.2.2/postgresql-9.2.2.tar.bz2
Already downloaded: /Users/rainyglade/Library/Caches/Homebrew/postgresql-9.2.2.tar.bz2
/usr/bin/tar xf /Users/rainyglade/Library/Caches/Homebrew/postgresql-9.2.2.tar.bz2
==> Patching
/usr/bin/patch -f -p1 -i 000-homebrew.diff
patching file src/pl/plpython/Makefile
patching file contrib/uuid-ossp/uuid-ossp.c
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.2.2 --datadir=/usr/local/Cellar/postgresql/9.2.2/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.2.2/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl ARCHFLAGS='-arch x86_64'
./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.2.2 --datadir=/usr/local/Cellar/postgresql/9.2.2/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.2.2/share/doc/postgresql
module Seed
class CourseRequirement < OpenStruct
include Gardener
def self.destroyable?
true
end
def attributes
{ coming_soon: coming_soon }
@lgrains
lgrains / instrument.rb
Created November 7, 2013 21:39
Taking a vote. Which looks cleaner and more rubyesque?
require 'ostruct'
class Instrument < OpenStruct
def self.instruments_array
InstrumentsCSVReader.get_from_file
end
def self.all
@all ||= instruments_array.map { |n| new(n) }
class CitizenshipStatus
include Processor
def process_field(value)
AlienStatus.find_code( value )
end
end
module Euler
class Prob1
def self.sum(upper_limit, num1, num2)
::Prob1.new(upper_limit, num1, num2).sum
end
def initialize(upper_limit, num1, num2)
puts "#{upper_limit} | #{num1} #{num2}"
require 'spec_helper.rb'
require 'lib/sf_to_coll/convert.rb'
require 'rake'
describe SfToColl::Convert do
context "main file for single record should be 2186 chars long" do
Rake::Task["import_field_data"].invoke
let(:converter){ SfToColl::Convert.new("tmp/ctbrown.csv").process }
let(:out_file_name){ converter.out_file_name }
class Graph
attr_accessor :points, :edges
def initialize(array_of_points)
points = Marshal.load(Marshal.dump(array_of_points))
puts "in initialize where graph.points is #{points}"
edges=[]
construct_edges
end
@lgrains
lgrains / quadtree_pseudocode.rb
Last active July 26, 2021 12:14
Pseudo-code for Quadtree Implementation
class Point
attr_accessor :x, :y
end
class QuadtreeNode
attr_accessor :point, :name
def northwest(other)
self.point.x > other.point.x && self.point.y < other.point.y
end
@lgrains
lgrains / irb_session.rb
Created May 12, 2014 13:41
IRB session using the kdtree gem
>> require 'kdtree'
true
>> point_array = [ [3,5],[14,0],[0,3],[-5,6],[-2,-3],[-4,-7],[2,-5],[0,0] ]
[
[0] [
[0] 3,
[1] 5
],
[1] [
[0] 14,
@lgrains
lgrains / get_historical_name
Created May 14, 2014 00:57
This psql function returns the historical name of a course, given the term and item number.
--Function parameters: cart_item_id (ec_items)
product_name (ec_products)
--returns the title of the course at that point in time.
create or replace function public.get_historical_name ( integer, varchar )
returns varchar as '
declare
v_cart_item_id alias for $1;
v_product_name alias for $2;