Skip to content

Instantly share code, notes, and snippets.

View benburrill's full-sized avatar

Ben Burrill benburrill

  • Looking for a job
View GitHub Profile
import json
import base64
import requests
import mimetypes
import urllib.parse
from pprint import pprint
from requests_oauthlib import OAuth1
CONSUMER_KEY = "INSERT KEY HERE"
CONSUMER_SECRET = "INSERT SECRET HERE"
@benburrill
benburrill / funcfmt.py
Created November 15, 2015 05:12
Function formatting in Python - see usage
# This is more of an idea than a actual module - although you can use it as such.
# A few things you could do:
# - split the fmt_spec into comma-separated arguments which can be passed into the function
# - make a format method part of the class itself instead of splatting the object into format
class FormatFuncs(dict):
def register(self, func):
self[func.__name__] = type(func.__name__, (), {
"__format__": lambda self, fmt_spec: func(fmt_spec)
})()
# Fill this out with your real username/password
USERNAME = "???"
PASSWORD = "???"
# Here we create a metaclass that effectively turns a class scope into a different programming environment where setting variables under one name saves them to another
# This level of madness requires Python 3 to run.
class CrazyDict(dict):
def __setitem__(self, item, value):
super().__setitem__("potato_" + str(item), value)
class CrazyMeta(type):
def __prepare__(*args, **kwargs):
return CrazyDict()
@benburrill
benburrill / test.rst
Last active January 25, 2019 21:14
rst test

Hello!

There should be syntax-highlighed python below this line, right?

print("hi")
@benburrill
benburrill / life_expectancy_3.ipynb
Created July 20, 2016 19:54
life_expectancy_3.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am benburrill on github.
  • I am benburrill (https://keybase.io/benburrill) on keybase.
  • I have a public key ASBfwFuMOM22ETCiolN6XZa1e2TlvHilKPjLQrvao8udWwo

To claim this, I am signing this object:

@benburrill
benburrill / itdiff.py
Created January 4, 2018 10:33
Iterator diffing for /u/Skaperen
"""
Iterator diffing: a response to
https://www.reddit.com/r/learnpython/comments/7o0swm/interleaving_iterators/
MIT License:
Copyright (c) 2017 Ben Burrill
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@benburrill
benburrill / 99-custom-touchpad.conf
Last active September 2, 2018 20:02
I hate touchpad middle click
Section "InputClass"
Identifier "libinput touchpad custom"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
# Map the first two buttons (normally left click and middle click) to both be left click
# so that 2/3 of the touchpad is devoted to left click and 1/3 to right click.
# I'm not sure, but probably on a 2 button touchpad this would eliminate right click, so
# be aware.
@benburrill
benburrill / run
Last active May 17, 2020 01:00
OpenXcom nightly auto-update script
#!/usr/bin/env bash
# Runs and auto-updates OpenXcom nightlies in a portable environment
# By default, this script will try to download and use the latest
# nightly. If it finds a newer version than you already have, it will
# prompt you (with a zenity popup) to ask if you actually want to
# download it.
#
# If you want to stick to a particular version and don't want the popup
# telling you to update, you can change the $here/versions/greatest
# symlink to point to a specific AppImage rather than the default