Skip to content

Instantly share code, notes, and snippets.

View barelyknown's full-sized avatar

Sean Devine barelyknown

View GitHub Profile
@barelyknown
barelyknown / gist:3989577
Created October 31, 2012 20:21
Eight Move Letterpress Win
Let's start the simulator
Player 1 will play: UROPYGIAL
Z A1 Z V W
V P Z U Y1
U1 D D I1 Q
G S C R1 O1
G1 W W L1 P1
Player 1: 9
Player 2: 0
---------------
@barelyknown
barelyknown / gist:4011968
Created November 4, 2012 13:40
Calculate All Moves For A Word in Letterpress Board
# requires a board_tiles method that returns an array of objects that respond to the letter method
def board_tiles_by_letter
by_letter = {}
('A'..'Z').each { |letter| by_letter[letter] = [] }
board_tiles.each { |board_tile| by_letter[board_tile.letter] << board_tile }
by_letter
end
def every_play(word)
@barelyknown
barelyknown / gist:4055906
Created November 11, 2012 19:09
Partage Software Developer Job Description

We're hiring 1-2 developers to help build the next generation of our software platform.

Technologies

Our development stack is typical Ruby on Rails - ruby, rails, HTML, CSS, JS/coffeescript, Bootstrap, Postgresql, heroku and github.

We <3 open source software. It's a big plus if you do too. Much of your work will be released as open source if you join the team.

When

@barelyknown
barelyknown / listify.rb
Created November 28, 2012 21:18
listify
def listify(words)
words.inject { |string, word| string + (word == words[-1] ? " and " : ", ") + word }
end
@barelyknown
barelyknown / gist:4228392
Created December 6, 2012 21:04
Problem with hash conditions on joined tables in AR models of namespaced Rails engines
# The namespaced table is not being determined in hash conditions. See below.
module Carrier
class Engine < ::Rails::Engine
isolate_namespace Carrier
end
end
module Carrier
class Profile < ActiveRecord::
@barelyknown
barelyknown / Partage API README.md
Last active December 10, 2015 01:38
Partage API Documentation

THE LATEST VERSION OF THIS DOCUMENTATION IS AVAILABLE AT gopartage.com/api.

Partage API

The Partage API provides a simple limited interface to the Partage brokerage system.

Authentication

For now, authentication is done with an API token that is connected to your company. We will add additional and more secure authentication options later in 2013 when we expose more services. For now, the services are "read only" and do not enable you to make any changes in our system, so we delayed our decision about additional security until we need to make it.

@barelyknown
barelyknown / partage_api_terms.txt
Last active December 10, 2015 01:38
Partage API Terms
The price provided in this rate quote response specifically reflects the origin and destination zip codes provided, the equipment type selected, as well as the number of pallet spots (defined as a standard 4' x 4' pallet, occupying space from the floor of the trailer to the ceiling of the trailer), and the weight of the shipment in the case of partial truckload shipments. Partial truckload shipments must be at least 4 pallets and 4,000 pounds and must be palletized. Product that is not palletized must move as a full truckload. This price is dependent on the exact pickup and delivery dates of the shipment. If no pickup date was entered as part of the quote process, or if the pickup and delivery date entered in the quote changes for any reason, the price of the shipment may change. This price reflects the special services that were selected in the quote. Special services not selected in the quote but required as part of the shipment's handling, will be charged according to Partage's standard accessorial rate sc
@barelyknown
barelyknown / http_request_through_proxy_in_ruby.rb
Created January 20, 2013 23:43
HTTP request through a proxy in ruby
http_class = Net::HTTP::Proxy(proxy_url, proxy_port, proxy_user, proxy_password)
http_class.start("example.com", 80) do |http|
request = Net::HTTP::Get.new "/hello_world.html"
request["Example-Header"] = "patriots_will_win_by_14"
http.request(request).body
end
@barelyknown
barelyknown / initialize_as_a_valid_instance_matcher.rb
Created August 24, 2013 19:03
Rspec matcher to test if a class initialize valid instances.
# test if ActiveRecord classes (or ActiveModel) initialize valid instances
# it { should initialize_as_a_valid_instance }
RSpec::Matchers.define :initialize_as_a_valid_instance do
match do |actual|
actual.valid?
end
description do
@barelyknown
barelyknown / to_csv_with_headers.rb
Created November 2, 2013 16:57
additional method for CSV::Rows to convert row to csv with headers. useful for serializing row for Sidekiq jobs.
class CSV::Row
def to_csv_with_headers
CSV.generate do |csv|
csv << headers
csv << fields
end.to_s
end
end