Skip to content

Instantly share code, notes, and snippets.

View trevvvy's full-sized avatar

Trevor Johnston trevvvy

View GitHub Profile
dictionary = File.read('dictionary.txt').split("\n")
five_letter_words = dictionary.select{|word| word.length == 5}
most_common_letters = five_letter_words.inject({}) do |result, word|
letters_array = word.chars
letters_counts = letters_array.tally
letters_counts.to_a.each_with_index do |(letter, count), index|
# next if letter == "s" && index == 4
@trevvvy
trevvvy / 0_reuse_code.js
Created October 18, 2015 20:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
select
start_at AT TIME ZONE 'UTC' AT TIME ZONE 'America/Vancouver'
from
appointments
where
date(start_at AT TIME ZONE 'UTC' AT TIME ZONE 'America/Vancouver') = '2014-07-24';
class MigrateTimeZones
attr_reader :old_zone, :new_zone
def initialize(old_zone = "Pacific Time (US & Canada)", new_zone = Company.current.time_zone)
@old_zone = ActiveSupport::TimeZone.new old_zone
@new_zone = ActiveSupport::TimeZone.new new_zone
end
def call
update_appointments
update_shifts
" Define the wildignore from gitignore. Primarily for CommandT
let gitignore = '.gitignore'
if filereadable(gitignore)
let igstring = ''
for oline in readfile(gitignore)
let line = substitute(oline, '\s|\n|\r', '', "g")
if line =~ '^#' | con | endif
if line == '' | con | endif
if line =~ '^!' | con | endif
if line =~ '/$' | let igstring .= "," . line . "*" | con | endif