This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
A script for parsing a flake8 error log and generating useful stats about the | |
errors in the code. | |
Author: Ben Lopatin (I think I wrote it, at least, no guarantee) | |
License: BSD | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeTestMixin: | |
def assertCloseEnough(self, first, second, diff=0.0001): | |
""" | |
Asserts that the percentage difference between the two values | |
is smaller than given diff value. | |
Results may depend on the order of the values. A more robust | |
version might test the difference against both values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List the domains you want to block, one per line, in your ~/.blocked_sites file, | |
# then ensure this script is included or sourced in your terminal configuration. | |
function worktime { | |
while read -r line; do | |
echo "127.0.0.1 ${line} # WORKTIME" | |
echo "fe80::1%lo0 ${line} # WORKTIME" | |
echo "127.0.0.1 www.${line} # WORKTIME" | |
echo "fe80::1%lo0 www.${line} # WORKTIME" | |
done < $HOME/.blocked_sites | sudo tee -a /etc/hosts > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on https://gist.github.com/blueyed/4fb0a807104551f103e6 | |
from django.db import connection | |
from django.db.migrations.executor import MigrationExecutor | |
import pytest | |
@pytest.fixture() | |
def migration(transactional_db): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Clean all but specified packages of old homebrewed installed packages | |
declare -a exclude=(python python3 python34 python35 python36 python27 pypy ruby node) | |
for PACKAGE in $(brew ls) | |
do | |
SENTINEL=false | |
for EXCLUDE in "${exclude[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# A little Ruby script to download your Drip broadcast messages to Jekyll-ready | |
# Markdown files. These could be used as posts or, better yet, as a collection. | |
# Inspired by Jonathan Stark's Drain https://github.com/jonathanstark/drain/ | |
# | |
# Copyright Ben Lopatin, 2018 | |
# Shared with an MIT license: https://opensource.org/licenses/MIT | |
# Since this is a standalone script, installing the dependencies is your responsibility |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def annotated(attr_name): | |
""" | |
Decorator for returning pre-calculated, annotated values | |
This should be used with model instance methods that fetch some | |
kind of related or calculated data. If the method is called on | |
a single instance in isolation, we should expect the method to | |
execute and return its value. However if the method is called | |
on a member of a queryset where the `attr_name` was added as an |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
LATEST_DB="$HOME/Downloads/$(ls -t ~/Downloads | head -1)" | |
BACKUP_PATH=${2-$LATEST_DB} | |
DB=$1 | |
echo "Creating database name $DB from $BACKUP_PATH" | |
psql -c "CREATE DATABASE $DB;" |