Skip to content

Instantly share code, notes, and snippets.

View dyspop's full-sized avatar
🇹🇭
SaaSy

Dan Black dyspop

🇹🇭
SaaSy
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dyspop on github.
  • I am danblack (https://keybase.io/danblack) on keybase.
  • I have a public key ASCJnHihWA0wrXdnJQ0MwSBUWIgHkpAY0HAErhpgl6VE1Ao

To claim this, I am signing this object:

""" Tic tac toe code exercise with dataclasses.
Usage:
import tictactoe as ttt
game = ttt.Game()
game.make_move(x, y)
"""
@dyspop
dyspop / fix_shutterstock_editorial_onboarding_t2_best.txt
Last active June 10, 2019 20:43
Fix the DCM modules and display for this first round of DCM in production
shutterstock_header_core_center
hero_copy
text_paragraph_center-1
feature_right-1
feature_left-1
<#if SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY='US' || SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY = 'GB' || SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY = 'DE' >text_paragraph_center-2</#if>
<#if SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY='US' || SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY = 'GB'>feature_right-2</#if>
<#if SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY='US' || SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY = 'GB' || SHUTTERSTOCK_IMG_MUSIC_FOOTAGE_EDITORAL_PET.COUNTRY = 'DE' >feature_left-2</#if>
text_paragraph_center-3
shutterstock_marketing_footer_inverse
@dyspop
dyspop / pull_set_info.py
Created May 12, 2019 02:50
Download mtg set data
import json
import requests
# Ask the user for the set abbreviation.
setabbrv = input("What's the abbreviation of the set?\n")
# Define the URL to look it up from
lookupobject = "https://api.scryfall.com/cards/search?order=name&q=set:" + setabbrv
# Make a get request and convert the json response to a dictionary
resp = json.loads(requests.get(lookupobject).text)
@dyspop
dyspop / fix-homebrew-owner-perms.sh
Created September 30, 2018 22:39 — forked from stefanschmidt/fix-homebrew-owner-perms.sh
Fix ownership and permissions of a multi-user Homebrew installation
# fix owner of files and folders recursively
sudo chown -vR $(whoami) /usr/local /opt/homebrew-cask /Library/Caches/Homebrew
# fix read/write permission of files and folders recursively
chmod -vR ug+rw /usr/local /opt/homebrew-cask /Library/Caches/Homebrew
# fix execute permission of folders recursively
find /usr/local /opt/homebrew-cask /Library/Caches/Homebrew -type d -exec chmod -v ug+x {} +
@dyspop
dyspop / set_get_generator.py
Last active February 13, 2018 16:07
Generate Python class property setters and getters
class_properties = ['foo', 'bar', 'baz']
for prop in class_properties:
print(f'''
@property
def {prop}(self):
"""Get {prop}."""
return self.__{prop}
@{prop}.setter
@dyspop
dyspop / gist:041e5c76da9b677a0e31f1ad3315371f
Last active December 13, 2017 18:13
pytest style in question
"""Tests for each individual function in the Client."""
import responsysrest as r
def dict_contains_key(d, k):
"""Test if the key is in the dictionary."""
return k in d
def test_get_context():
@dyspop
dyspop / gist:b29945eb5ece2e058a51e4e9ed8585f2
Created December 6, 2017 17:55 — forked from mattkenefick/gist:7e565607c9656ad81d4d
Bash CRUD (Get,Post,Put,Delete) Commands
# Polymer Mallard - Bash CRUD
#
# Put the following into your ~/.bash_rc or ~/.bash_profile
# Requires Python, cURL
function pmCrudRequest {
printf " \n \e[1;33m$method\e[0m from \e[1;33m$url\e[0m \n \n"
printf " \n \e[0;32m"
echo "$response" | python -m json.tool
printf "\e[0m"
@dyspop
dyspop / .bash_profile
Last active February 13, 2018 03:11
Fun and useful terminal prompt with autoenv
#!/bin/bash
alias ll='ls -hartlG'
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="🤖 \h\n👤 \u\n📁 \w\n🌳 \$(parse_git_branch)\n🤘 "
@dyspop
dyspop / average_image_color.py
Created March 27, 2017 02:50
assign averages of image channel histograms to a dictionary
from PIL import Image
filename = 'pastries.jpg'
image = Image.open(filename)
# get average color
# inspiration from https://gist.github.com/olooney/1246268
def average_image_color(imagedata):
channel_histograms = {}
color_averages = {}