Skip to content

Instantly share code, notes, and snippets.

@hcgatewood
hcgatewood / emojis.md
Created Apr 1, 2019
GitHub emoji support as of 04/01/2019
View emojis.md
  • 👍 :+1:
  • 👎 :-1:
  • 💯 :100:
  • 🔢 :1234:
  • 🥇 :1st_place_medal:
  • 🥈 :2nd_place_medal:
  • 🥉 :3rd_place_medal:
  • 🎱 :8ball:
  • 🅰️ :a:
  • 🆎 :ab:
View ps11.py
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 / how-to-be-miserable.md
Created Feb 6, 2018
Checklist of strategies from Randy Paterson's How to Be Miserable: 40 Strategies You Already Use
View how-to-be-miserable.md

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
@hcgatewood
hcgatewood / fruits.csv
Last active Oct 26, 2017
CSV + processing example
View fruits.csv
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
View play_notes.py
"""
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).
View shoutkey-comb.py
# 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 / jargonScraper.js
Last active Nov 6, 2017
Pull a random word and definition from the Jargon File
View jargonScraper.js
// 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 / order_movies.py
Last active Jul 29, 2016
Sort a list of movies based on a viewed/not-viewed indicator
View order_movies.py
"""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.
@hcgatewood
hcgatewood / random_note.py
Last active Jul 29, 2016
Print a random note at the passed interval, defaulting to every 4 seconds
View random_note.py
#!/usr/bin/env python3
'''
Prints a random note at the passed interval, defaulting to every
4 seconds.
@author Hunter Gatewood
'''
import itertools
import random
import time
@hcgatewood
hcgatewood / hash_table.rb
Last active Aug 29, 2015
An associative array in Ruby
View hash_table.rb
#!/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)
You can’t perform that action at this time.