Skip to content

Instantly share code, notes, and snippets.

View pathouse's full-sized avatar
🐶

Pat McGee pathouse

🐶
View GitHub Profile
@pathouse
pathouse / greed-score.rb
Last active December 17, 2015 16:39
Working through the Greed scoring problem in Ruby Koans, the first two lines of my solution made me smile. Thanks Ruby. For context, 'dice' is an array of 5 numbers representing 5 die rolls.
def score(dice)
dice_hash = {"1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0, "6" => 0}
count = dice.each {|x| dice_hash[x.to_s] += 1}
end
@pathouse
pathouse / imdb_pro_production_companies_by_location.rb
Last active April 11, 2023 20:09
IMDb pro has a database of more than 22,000 production companies. Unfortunately, their searching and sorting tools are pretty poor. This is a very simple first draft of a script for scraping those pages for info and writing the results to a csv file. This is 4401 pages of data (50 companies per page) so it takes a while. An IMDb pro subscription…
require 'mechanize'
require 'csv'
PAGES = (1..4401)
LOGIN_PAGE = "https://secure.imdb.com/signup/v4/login"
BASE_URL = 'http://pro.imdb.com/companies/type-production'
def page_url(page)
module ActiveRecord
module ConnectionAdapters
module DatabaseStatements
#
# Run the normal transaction method; when it's done, check to see if there
# is exactly one open transaction. If so, that's the transactional
# fixtures transaction; from the model's standpoint, the completed
# transaction is the real deal. Send commit callbacks to models.
#
# If the transaction block raises a Rollback, we need to know, so we don't
@pathouse
pathouse / README.md
Last active January 3, 2016 17:29
Subject Tag Bubble Chart - Working

Artwork Subject Tags

Simple D3.js bubble chart of some Artsicle product tags based on this example

@pathouse
pathouse / README.md
Last active January 3, 2016 17:39
Artwork Medium Tags - working

Medium Tags Bubble Chart

Another bubble chart in D3.js once again thanks to this example

@pathouse
pathouse / README.md
Last active January 3, 2016 17:59
Surface Properties Products

###Surface Properties Bubble Chart

3rd in this series of data discovery charts.

@pathouse
pathouse / README.md
Last active January 3, 2016 17:59
medium properties products

###Medium Properties Bubble Chart

4th and last in this series of data discovery charts.

@pathouse
pathouse / README.md
Created July 13, 2014 17:53
Server Logging in Go

Server Event Logging in Go

Inspo

Many thanks to https://github.com/jadekler/git-go-websiteskeleton who got me started in this direction. Jadekler was in turn inspired by https://gist.github.com/cespare/3985516. Ultimately, this implementation has a lot more in common with cespare's. There are a few minor differences. I mainly wrote this one to teach myself exactly what was going on (hence all the comments) and to demonstrate the inclusion of the gorilla/mux framework without using Jadekler's technique of two separate http muxes.

Delivery Schedule Ingredient Preferred Sourcing Unit Standard Unit NE Standard MW Standard WC Standard FL Standard Notes Owner Yield Loss Calc
1618 Acadian Redfish pound pound 7.9 7.9 7.9 7.9
1618 Almonds Slivered pound pound 9.5 9.5 9.5 9.5
1625 Aluminum Tin 4-oz/~3" each each 0.08 0.08 0.08 0.08
1611 Aluminum Tin Square 7" each each 0.07 0.07 0.07 0.07
1612 Arborio Rice pound pound 2.02 2.02 2.02 2.02
1613 Arugula Baby pound pound 5 5 5 5 x
1623 Asparagus (28/1-LB) pound pound 3.5 3.5 3.5 3.5
1624 Avocado (48-Ct) each each 1.15 1.15 1.15 1.15 x
1625 Baby Spinach (Organic Girl, 5-oz clam) each each 2.51 2.51 2.51 2.51