Skip to content

Instantly share code, notes, and snippets.

View blackwatertepes's full-sized avatar
Relaxing

Tyler J. Kuhn blackwatertepes

Relaxing
View GitHub Profile
=begin
INCOMPLETE: I realized last night (as I tried to not think about coding), how to fix at least the issue with the previous iteration. This one works partially, it just doesn't account for capitalization, punctuation, and
common words (the, of, etc.)
=end
def words_in_a_file (source_text, number)
file_as_a_string = File.open(source_text).read
word_count = Hash.new(0)
array_of_text = file_as_a_string.split
array_of_text.each do |word|
@blackwatertepes
blackwatertepes / jeopardy.txt
Created March 15, 2013 19:32
A super long list of jeopardy questions
This file has been truncated, but you can view the full file.
3288-45 20002 IF THEY WERE SUPERHEROES (Alex: All of the correct responses will end in the letters "M-A-N"; example: Superman.) This 1940s Chicago Bears quarterback would have won games with incredible good fortune (Sid) Luckman 1600 $600
3264-50 20003 THE MEDIA ON TV This title character was the crusty and tough city editor of the Los Angeles Tribune Lou Grant 1800 $800
3032-28 20004 CYBER LIFE Mojo Nixon and the Rev. Horton Heat provided music for this CD-ROM game set in an Arkansas trailer park Redneck Rampage 500 $500
3329-2 20005 THERE GOES THE EMPIRE This nation colonized part of Somalia in the 19th century and invaded Ethiopia in the 20th Italy 100 $100
3279-3 20006 300 YEARS AGO In 1698, this comet discoverer took a ship called the Paramour Pink on the first purely scientific sea voyage Edmund Halley 100 $100
3109-31 20007 FILM BIOGRAPHIES In a 1992 film Jack Nicholson portrayed this labor leader Jimmy Hoffa 1200 $200
4973-40 20008 BEASTLY LIT 1930:Bird is the word for Dashiell Hammett in
@blackwatertepes
blackwatertepes / shortest_distance.rb
Created May 2, 2013 16:02
Shortest Driver Distance (Lyft)
require 'rspec'
module Trip
def distance(a, b)
lat_dist = (a[:lat] - b[:lat]).abs
long_dist = (a[:long] - b[:long]).abs
Math.sqrt(lat_dist**2 + long_dist**2)
end
def route_distance(*points)
@blackwatertepes
blackwatertepes / gist:8186711
Created December 30, 2013 19:23
Git Strangeness
[preproduction][~] git log
commit 61cec4a71dbea09af2b4c8072216adfa2d8bcc4c
Author: Tyler J. Kuhn <tyler@wargoats.com>
Date: Fri Dec 6 11:51:09 2013 -0800
if notes have no body, they get deleted
[preproduction][~] git status
# On branch preproduction
nothing to commit, working directory clean
[preproduction][~] git pull --rebase origin preproduction
@blackwatertepes
blackwatertepes / gist:8328340
Created January 9, 2014 02:18
Massive Query
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT(sv.value) FROM signal_processor_signal_values AS sv WHERE sv.item_id = si' at line 1: SELECT `signal_processor_items`.`id` AS t0_r0, `signal_processor_items`.`processor_id` AS t0_r1, `signal_processor_items`.`created_at` AS t0_r2, `signal_processor_items`.`updated_at` AS t0_r3, `signal_processor_items`.`default` AS t0_r4, `signal_processor_items`.`paused` AS t0_r5, `signal_processor_signal_values`.`id` AS t1_r0, `signal_processor_signal_values`.`signal_id` AS t1_r1, `signal_processor_signal_values`.`value` AS t1_r2, `signal_processor_signal_values`.`created_at` AS t1_r3, `signal_processor_signal_values`.`updated_at` AS t1_r4, `signal_processor_signal_values`.`lat` AS t1_r5, `signal_processor_signal_values`.`lng` AS t1_r6, `signal_processor_signal_values`.`begin_at` AS t1_r7, `signal_processor_signal_values`.`end_at` AS t1_r8, `signal_processor_signal_valu
#This converts a csv file to a slightly different csv.
#usage: ruby csv_to_csv.rb <csv input filename> <csv output filename>
# leaving out the output filename will result in a csv file with the same name as the input, and will have 'converted' in front of it.
require 'rubygems'
require 'csv'
require 'json'