Skip to content

Instantly share code, notes, and snippets.

@hcgatewood
hcgatewood / how-to-be-miserable.md
Created February 6, 2018 06:28
Checklist of strategies from Randy Paterson's How to Be Miserable: 40 Strategies You Already Use

Adopting a miserable lifestyle

  • 1. Avoid all exercise
  • 2. Eat what you're told
  • 3. Don't waste your life in bed
  • 4. Live better through chemistry
  • 5. Maximize your screen time
  • 6. If you want it, buy it
  • 7. Can't afford it? Get it anyway!
  • 8. Give 100 percent to your work
const isoFetch = require('isomorphic-fetch');
const Dropbox = require('dropbox').Dropbox;
const util = require('util');
exports.handler = function(context, event, callback) {
log(context);
log(event);
const whitelisted_numbers = [
context.HCG_NUM_1,
@hcgatewood
hcgatewood / jargonScraper.js
Last active December 23, 2019 08:24
Pull a random word and definition from the Jargon File
// NOTE:
// Must have xray installed.
// Use `npm init -y && npm install -S x-ray` in an empty directory.
// Here's the link for npm: https://docs.npmjs.com/getting-started/installing-node
// NOTE:
// Here's the url of the Jargon File: http://www.catb.org/jargon/html/
'use strict';
@hcgatewood
hcgatewood / hash_table.rb
Last active December 23, 2019 08:23
An associative array in Ruby
#!/usr/bin/env ruby
# A simple hash table implementation in Ruby using Ruby's built-in
# prehashing methods, chaining, and variable load factors.
#
# Author:: Hunter Gatewood
# A linked-list node with key, value, and next node attributes.
class Node
attr_accessor(:key, :val, :next_node)
@hcgatewood
hcgatewood / emojis.md
Created April 1, 2019 23:57
GitHub emoji support as of 04/01/2019
  • 👍 :+1:
  • 👎 :-1:
  • 💯 :100:
  • 🔢 :1234:
  • 🥇 :1st_place_medal:
  • 🥈 :2nd_place_medal:
  • 🥉 :3rd_place_medal:
  • 🎱 :8ball:
  • 🅰️ :a:
  • 🆎 :ab:
from random import choice
RUNS = 1_000_000
first_3 = []
def mean(lst):
return sum(lst) / len(lst)
for i in range(RUNS):
@hcgatewood
hcgatewood / fruits.csv
Last active October 26, 2017 16:40
CSV + processing example
1 apple:lemon:lime
2 banana:lemon:grape
3 apple
4 pear:apple:banana
5 strawberry
6 orange
1 banana
2 pear
3 strawberry
4 kiwi:pear:orange:strawberry
"""
Read in notes from the passed notes.json file and send to our Twitch channel.
Usage: `python3 play_notes.py <your notes.json file>`
Notes:
- Careful about getting rate limited! The limits per 30 seconds
are 30 messages for non-mods and 100 messages for mods. Pass that
limit and your IP gets banned for 8 hours. See
https://help.twitch.tv/customer/portal/articles/1302780-twitch-irc.
- Expects fields in notes.json to be filled out (pass, nick, notes).
# Comb through plausible shoutkey.com URLs looking for redirections.
#
# Prints out URLs with valid redirects. Will also write them to a file
# if KNOWN_WORDS_LOC is not None.
#
# NOTES
# - Words list: https://github.com/first20hours/google-10000-english/blob/master/google-10000-english-usa.txt
# - Kill the process with Ctrl+Z since the requests module improperly
# catches exceptions
@hcgatewood
hcgatewood / order_movies.py
Last active July 29, 2016 07:10
Sort a list of movies based on a viewed/not-viewed indicator
"""order_movies.py
Sorts a list of movies stored in 'Movies to watch.txt'.
@author Hunter Gatewood
"""
FILE_NAME = 'Movies to watch.txt'
def sort_key(entry):
"""Form a sort key for ordering the movies.