Skip to content

Instantly share code, notes, and snippets.

View blackrobot's full-sized avatar
🖖
coffee

Damon Jablons blackrobot

🖖
coffee
View GitHub Profile
@blackrobot
blackrobot / primary-styling.css
Created March 8, 2019 17:09
Markdown Here Settings
/*
* NOTE:
* - The use of browser-specific styles (-moz-, -webkit-) should be avoided.
* If used, they may not render correctly for people reading the email in
* a different browser than the one from which the email was sent.
* - The use of state-dependent styles (like a:hover) don't work because they
* don't match at the time the styles are made explicit. (In email, styles
* must be explicitly applied to all elements -- stylesheets get stripped.)
*/
@blackrobot
blackrobot / vscode-vim.cheatsheet.md
Last active October 7, 2018 21:44
A cheatsheet of plugin commands built into the VS Code Vim extension
@blackrobot
blackrobot / iina-input.conf
Last active August 30, 2018 21:37
Custom keybinding config for IINA
# ###
# damon.conf - IINA keybindings
# ###
# Copied from the default input config for IINA
#
# Documentation can be found here:
# * https://github.com/lhc70000/iina/wiki/Manage-Key-Bindings
# * https://mpv.io/manual/stable/#command-interface
#@iina Shift+Meta+v video-panel
import contextlib
@contextlib.contextmanager
def managed_records(shelve_db_names, file_names):
try:
shelve_dbs = []
for name in shelve_db_names:
db = shelve.open(name, protocol=pickle.HIGHEST_PROTOCOL)
shelve_dbs.append(db)
@blackrobot
blackrobot / github-refined.css
Last active July 12, 2018 22:01
Github Refined Extra CSS
.blob-code-inner,
.blob-num,
.highlight pre,
.files > tbody > tr > td.content a {
font-family: "Operator Mono" !important;
}
.files > tbody > tr > td.content a {
font-size: 13.3px;
}
.pl-c, .pl-e {
@blackrobot
blackrobot / how-to-set-up-stress-free-ssl-on-os-x.md
Created January 31, 2018 01:03 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@blackrobot
blackrobot / csv_utils.py
Created January 23, 2018 21:40
Mixins for working with CSV files in Python
from __future__ import absolute_import, print_function, unicode_literals
from collections import namedtuple
import io
import re
# python 3 backport of the stdlib csv module
# https://github.com/ryanhiebert/backports.csv
from backports import csv
def validate_data(self, data):
ret = OrderedDict()
errors = OrderedDict()
fields = self._writable_fields
for field in fields:
validate_method = getattr(
self, 'validate_' + field.field_name, None)
primitive_value = field.get_value(data)
try:
def to_internal_value(self, data):
"""
Dict of native values <- Dict of primitive datatypes.
"""
if not isinstance(data, Mapping):
message = self.error_messages['invalid'].format(
datatype=type(data).__name__
)
raise ValidationError({
api_settings.NON_FIELD_ERRORS_KEY: [message]
@blackrobot
blackrobot / batch.py
Last active December 29, 2017 22:46
from __future__ import print_function, unicode_literals
from six import itertools
def batch(iterable, size):
""" Generates slices of items in groups of `size` length.
>>> for group in batch(range(10), size=4):
print(group)
(0, 1, 2, 3)