Skip to content

Instantly share code, notes, and snippets.

View awhit012's full-sized avatar

Alex White awhit012

View GitHub Profile
{
"school": "General Assembly",
city: "San Francisco",
course: "Web Development Immersive",
course_id: "WDI22",
classrootm: "1",
students: [{
id: 0,
last_name: "Aramayo",
first_name: "Angelo",
@awhit012
awhit012 / camel.js
Created August 13, 2015 04:18
Console game for OO JavaScript practice
var prompt = require('prompt');
prompt.start();
WELCOME = [
"Welcome to Camel Run!" ,
"You have stolen a camel (you egg!) to make your way across the great Mobi desert." ,
"The townspeople want their camel back and are chasing you down! Survive your" ,
"desert trek and outrun the blockos." ,
"Only drink when necessary. Always use E. to display your status!" ,
"Do not let your thirst go above 6 and your camel's tiredness above 8."
@awhit012
awhit012 / gist:089a54b09a53ee389827
Created July 16, 2015 01:31
spirit_of_mckenna.py
import praw, time, csv, random, itertools, requests
BOT = 'spirit_of_mckenna'
PASSWORD = "" #not actual password
KEYWORD = "mckenna"
SLEEP_MESSAGE = "Sleeping for 12 hours..."
BY_LINE = " -Terence McKenna"
USER_AGENT = "When people reference McKenna, I provide a quote of his, /u/spirit_of_mckenna"
SUBREDDITS = [ 'test',
'psychonaut',
@awhit012
awhit012 / rps.rb
Created May 5, 2015 00:25
Rock Paper Scissors in Ruby
MESSAGES = [
"Choose your weapon",
"Computer has chosen ",
"TIE!",
"Computer Wins",
"You Win!"
]
def run
puts MESSAGES[0]
@awhit012
awhit012 / rovarspraket.rb
Created May 4, 2015 01:23
rovarspraket converter
def rovarspraket(string)
vowels = ['a','e','i','o','u' 'y', 'Å', 'Ä', 'Ö']
vowels.each{|vowel| vowel.downcase!}
answer = ""
string.each_char do |char|
if char =~ /[[:alpha:]]/
unless vowels.include?(char) || vowels.include?(char.downcase)
answer += char + 'o' + char.downcase
else
answer += char
# finished
PUZZLES = [
"105802000090076405200400819019007306762083090000061050007600030430020501600308900",
"005030081902850060600004050007402830349760005008300490150087002090000600026049503",
"105802000090076405200400819019007306762083090000061050007600030430020501600308900",
"005030081902850060600004050007402830349760005008300490150087002090000600026049503",
"005030081902850060600004050007402830349760005008300490150087002090000600026049503",
"290500007700000400004738012902003064800050070500067200309004005000080700087005109",
"080020000040500320020309046600090004000640501134050700360004002407230600000700450",
"608730000200000460000064820080005701900618004031000080860200039050000100100456200",
@awhit012
awhit012 / mckenna_quotes.csv
Created May 2, 2015 06:49
McKenna Quotes!
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 2 columns, instead of 4 in line 2.
“I think of going to the grave without having a psychedelic experience like going to the grave without ever having sex. It means that you never figured out what it is all about. The mystery is in the body and the way the body works itself into nature.”,
“Stop consuming images and start producing them.”,
“You are a divine being. You matter, you count. You come from realms of unimaginable power and light, and you will return to those realms.”,
“You are an explorer, and you represent our species, and the greatest good you can do is to bring back a new idea, because our world is endangered by the absence of good ideas. Our world is in crisis because of the absence of consciousness.”,
“The male dominant agenda is so fragile that any competitor is felt as a deadly foe.”,
@awhit012
awhit012 / quote_bot.py
Last active February 12, 2018 21:56
BotMother: A Reddit QuoteBot template using Praw
# UPDATED 7/15
# Thanks to kootenpv for the code review!
# This makes it easy to create a reddit bot that
# A. Grabs comments from subreddits of your choice
# B. Searches for a keyword
# C. Replies to comments with that keyword from a list of responses on a CSV file
# Follow correct etiquette:
# https://www.reddit.com/r/Bottiquette
@awhit012
awhit012 / alex_knp.rb
Last active June 23, 2024 15:31
A ruby implementation of the Knuth-Morris-Pratt algorithm
class KMP
attr_reader :results
def initialize string, pattern
@string = string
@pattern = pattern
@string_length = string.length
@pattern_length = pattern.length
@table = kmp_table
@results = []
kmp
@awhit012
awhit012 / alex_horspool.rb
Last active July 15, 2016 16:46
Horspool string matching algorithm in Ruby
#Horspool algorithm implements the good suffix rule.
# If the char is not present, it still skips ahead by the length of the pattern.
# If the char is not a match, but it is present in the string, it jumps forward by the appropriate ammount.
# pattern_length if char not in pattern is found
# function accepts a string and a pattern and returns the index in the string where
# the pattern first occurs, or "not found"
def brute_search_2 string, pattern
pattern_length = pattern.length
bad_match_table = Hash.new