Skip to content

Instantly share code, notes, and snippets.


Damon Jablons blackrobot

Block or report user

Report or block blackrobot

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
blackrobot /
Created Jan 23, 2018
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
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)
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(
raise ValidationError({
api_settings.NON_FIELD_ERRORS_KEY: [message]
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):
(0, 1, 2, 3)
blackrobot /
Created Dec 20, 2017
Elasticsearch python dsl search query load all outline
class SearchQuery(...):
# special search methods, like `def for_name(...)`
def load_db_objects(self):
""" Immediately loads all of the database objects in a single
query, and caches them on each result's `object` property.
result_pks = [ for x in self] # maybe self.execute?
object_query_map = self.model.objects.in_bulk(result_pks)
blackrobot /
Created Dec 13, 2017
Google Chrome Flags
View findbar.css
@namespace url("");
@keyframes scale-in {
0% {
transform: scaleY(0);
100% {
transform: scaleY(1);
blackrobot /
Created Dec 7, 2017 — forked from koop/
Ensures a certificate is in the macOS system keychain.
# Usage
# $ ./ "/path/to/cert"
# First, grab the SHA-1 from the provided SSL cert.
CERT_SHA1=$(openssl x509 -in "$CERT_PATH" -sha1 -noout -fingerprint | cut -d "=" -f2 | sed "s/://g")
# Next, grab the SHA-1s of any certs in the keychain.
# Don't return an error code if nothing is found.
View wasavi.exrc
" exrc for wasavi
" Wasavi:
" Github:
" Themes:
" - blight
View md-here.highlight.css
Railscasts-like style (c) Visoft, Inc. (Damien White)
.hljs {
display: block;
overflow-x: auto;
/* padding: 0.5em; */
You can’t perform that action at this time.