Skip to content

Instantly share code, notes, and snippets.

View dyspop's full-sized avatar
🇹🇭
SaaSy

Dan Black dyspop

🇹🇭
SaaSy
View GitHub Profile
@dyspop
dyspop / zeros.liquid
Last active February 3, 2016 16:00
Liquid zero start of string fill-ins.
{% assign user_code_str = event.user.user_code | downcase %}
{% capture user_code_length %}{{user_code_str | size}}{% endcapture %}
{% capture zeros_missing %}{{'9' | minus: user_code_length}}{% endcapture %}
{% capture nine_digit_user_code %}{% for zero in zeros_missing %}0{% endfor %}{{event.user.user_code}}{% endcapture %}
records = {('wendy', 'sanchez'): ['wunderkind','extraordinaire'], ('dan', 'black'): ['hacker','wannabe'], ('tim', 'black'): ['mad', 'genius', 'dontchaknow'], ('dan', 'garfield'): ['porg', 'rammer', 'snake charmer']}
sorted_last = ['black', 'black', 'garfield', 'sanchez']
itered_records = []
for last_name in sorted_last:
for key in records:
if key[1] == last_name:
if str([key + ('', records[key])]) not in itered_records:
itered_records.append(str([key + ('', records[key])]))
print key, records[key]`
@dyspop
dyspop / .bash_profile
Created September 15, 2016 20:57
my bash_profile
#aliases
alias rmdirectory='rm -rf'
alias ll='ls -artlhG'
alias get='curl -OL'
alias g='grep -i'
alias sublime='subl'
alias gl='git log'
alias gh='git log'
alias rmdir='rm -rf'
@dyspop
dyspop / .bash_profile
Created October 1, 2016 14:57 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@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 = {}
@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 / 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 / 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 / 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 / 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 {} +