Skip to content

Instantly share code, notes, and snippets.

Brad Beattie bradbeattie

Block or report user

Report or block bradbeattie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pgen.py
#!/usr/bin/env python3
from getpass import getpass
import argparse
import base64
import hashlib
import json
import logging
import os
import secrets
View dwarf-fortress-mockup
#dig start(34;40; ) - - DwarfMockup(95;89;4;1)
~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,#
~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,#
~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,#
~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,#
~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,#
~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,#
~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,#
~,~,~,~,~,~,~,~,~,~,~,~,
View prep-python-env.sh
#!/bin/bash
DIR=$(pwd)
# Download Python
PYTHON_VERSION="3.6.4"
PYTHON_VERSION_SHORT="3.6"
PYTHON_DOWNLOAD_URL="https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz"
PYTHON_DOWNLOAD_FILE="Python-$PYTHON_VERSION.tgz"
curl $PYTHON_DOWNLOAD_URL > $PYTHON_DOWNLOAD_FILE
PYTHON_MD5SUM_EXPECTED="9de6494314ea199e3633211696735f65"
@bradbeattie
bradbeattie / netflix.js
Last active Jan 25, 2018
Adds IMDB ratings to netflix
View netflix.js
var OMDB_APIKEY = "..."
var omdb_searched = new Set()
var omdb_netflix_id_regex = new RegExp("/watch/([0-9]+)")
function omdb_get_key(link) {
return "omdb" + omdb_netflix_id_regex.exec(link.prop("href"))[1]
}
function omdb_find_cards() {
jQuery(".meta > .year").each(function() {
@bradbeattie
bradbeattie / pycon-preference-displayer.js
Last active Apr 20, 2017
PyCon Preference Displayer
View pycon-preference-displayer.js
// To be used on https://us.pycon.org/2017/schedule/talks/
// after using https://gist.github.com/bradbeattie/8d346acda2d737ef23ccf9cc78fd80d7
// Display the recorded preference for each talk
// To be used in tandem with
$(".slot-talk .title a").each(function() {
var element = $(this)
var href = element.attr("href")
if (localStorage[href] !== undefined) {
element.parents(".slot-talk").css("background", "hsl(" + ((parseInt(localStorage[href]) + 5) * 10) + ", 50%, 50%)")
@bradbeattie
bradbeattie / pycon-preference-recorder.js
Last active Apr 20, 2017
PyCon Preference Recorder
View pycon-preference-recorder.js
// To be used on https://us.pycon.org/2017/schedule/talks/list/
// Hide who's giving the talk and when
$("h2 + p").remove()
// On left and right click, increase or decrease the recorded preference for the talk
function process(event, element, left) {
event.preventDefault()
event.stopPropagation()
var href = element.prev().find("a").attr("href")
@bradbeattie
bradbeattie / They Come Unseen.md
Last active Mar 8, 2017
Rules Confirmation Scenario for They Come Unseen
View They Come Unseen.md

They Come Unseen: Rules Confirmation Scenario

This is not meant to be a comprehensive list of rules, but instead to help players validate their understanding of the rules through a scenario. The turns below are not in order.

Note: This document has yet to be fully verified. Pending requests for clarifications have been added after the document at the bottom.

Scenario Setup

Location Battery Mines Damage
View Python regex tokenizer
import re
# Supported tokens and their operations
ORDER_OF_OPERATIONS = ["MULTIPLY", "DIVIDE", "ADD", "SUBTRACT"]
scanner = re.Scanner([
(r"([0-9]+)", lambda x, y: int(y)),
(r"\+", lambda x, y: "ADD"),
(r"-", lambda x, y: "SUBTRACT"),
(r"\*", lambda x, y: "MULTIPLY"),
(r"/", lambda x, y: "DIVIDE"),
@bradbeattie
bradbeattie / queryset_filters.py
Created Jul 19, 2016
Django queryset understanding confirmation
View queryset_filters.py
#$ cat myapp/models.py
#from django.db import models
#
#class Foo(models.Model):
# pass
#
#class Bar(models.Model):
# foos = models.ManyToManyField(Foo, related_name="bars")
# val_a = models.BooleanField()
# val_b = models.BooleanField()
@bradbeattie
bradbeattie / cache_result.py
Last active Jun 27, 2016
Caches function results a little more intelligently
View cache_result.py
from datetime import timedelta
from django.core.cache import cache
from hashlib import md5
from importlib import import_module
from random import randint
from redis import Redis
from rq import Queue
EXPIRY_VARIANCE = 0.2
You can’t perform that action at this time.