This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "json" | |
require "date" | |
require "rest-client" | |
require "axlsx" | |
BLS_REGISTRATION_KEY = "<get your own from https://data.bls.gov/registrationEngine/>" | |
# How many spreadsheet rows before the data actually starts | |
TABLE_OFFSET = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 3 | |
class CreateFoo < ActiveRecord::Migration | |
def up | |
create_table :foos | |
execute "alter table foos add column created_at timestamp with time zone" | |
execute "alter table foos add column updated_at timestamp with time zone" | |
end | |
def down | |
drop_table :foos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InfiniteArray < Array | |
def initialize(value) | |
super(1, value) | |
end | |
def [](index) | |
self.first | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VersionNumber | |
include Comparable | |
attr_reader :version_parts | |
def initialize version_string | |
@version_parts = version_string.split(/[a-zA-Z]/).first.split('.').map(&:to_i) | |
end | |
def <=> other | |
@version_parts.each_with_index do |version_part, i| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# output | |
> gh = Redcarpet::Render::GithubStyleTitles.new | |
> puts Redcarpet::Markdown.new(gh).render "test\n\n# test 1\n\n# test 2\n\n# test 1\n\n# test 1" | |
=> | |
<a name="test-1" class="anchor" href="#test-1"><span class="anchor-icon"></span></a><h1 id="test-1">test 1</h1> | |
<a name="test-2" class="anchor" href="#test-2"><span class="anchor-icon"></span></a><h1 id="test-2">test 2</h1> |