Skip to content

Instantly share code, notes, and snippets.

@dvmonroe
dvmonroe / time_zone_state_helper.rb
Created August 4, 2017 03:34
ActiveSupport::TimeZone mapping by state
module TimeZoneStateHelper
STATE_TIME_ZONES = {
AK: "Alaska",
AL: "Central Time (US & Canada)",
AR: "Central Time (US & Canada)",
AZ: "Pacific Time (US & Canada)", # use the furthest time
CA: "Pacific Time (US & Canada)",
CO: "Mountain Time (US & Canada)",
CT: "Eastern Time (US & Canada)",
DC: "Eastern Time (US & Canada)",
@dvmonroe
dvmonroe / bash
Last active February 12, 2020 16:57
Automated git based release notes
#!/bin/bash
# RELEASE NOTE FILE
LOG_FILE=CHANGELOG.md
TMP_LOG_FILE=CHANGELOG.tmp.md
# SEEKING LABELS ON COMMIT SUBJECTS
BUGS=";B"
FEATURES=";F"
MISC=";M"
@dvmonroe
dvmonroe / string-sorting.js
Created November 5, 2015 23:39
js string sorting
var testString = "Partner World Dog Cat Xyelephone New. shorts apple summer a tiny"
function sortDescending(a, b){
if (a > b) return -1
if (a < b) return 1
else return 0
}
function sortArrayAndStringify(array, sortComparator){
@dvmonroe
dvmonroe / choose-chicago-crawler.rb
Created October 26, 2015 04:47
Chicago Upcoming Events web crawler
require 'simple-rss'
require 'open-uri'
require 'pry'
require 'mechanize'
require 'elasticsearch'
client = Elasticsearch::Client.new log: true
mechanize = Mechanize.new
rss = SimpleRSS.parse open('http://www.choosechicago.com/includes/cfcs/syndication/RSS/rssManager.cfc?method=showFeed&feedType=events&e_catID=0&regionid=0&e_sdate=10-20-2015&e_edate=10-26-2015')
@dvmonroe
dvmonroe / insta_tags.rb
Created June 6, 2015 23:48
Grabbing tags from Instagram /locations api
require "openssl"
require "rest-client"
INSTA_PATH = 'https://api.instagram.com/v1/locations/'
LOCATION = "#{location id}"
CLIENT_ID = "#{your client id}"
def parse_response(params)
results = JSON.parse(params)
binding.pry
@dvmonroe
dvmonroe / dmv.rb
Last active August 29, 2015 14:18
CA DMV new vehicle registration form
require 'rubygems'
require 'mechanize'
require 'pry'
require 'nokogiri'
require 'json'
class FeeCheckWorker < Workers
def setup_page
agent = Mechanize.new