Skip to content

Instantly share code, notes, and snippets.

View fish2000's full-sized avatar
👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!

Alexander Böhn fish2000

👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!
  • Objects in Space and Time, LLC
  • Baltimore, MD
  • 23:11 (UTC -04:00)
  • X @fish2000
View GitHub Profile
@fish2000
fish2000 / sigbytes.py
Last active May 10, 2019 01:25
Python CLT to print out the first eight bytes – aka the “signature” – of one or more files
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# sigbytes.py
#
# Read and print the first 8 or so bytes of a file,
# For, like, tests and stuff
# (c) 2015 Alexander Bohn, All Rights Reserved
#
u"""
@fish2000
fish2000 / django-string-signing.js
Last active April 24, 2019 21:02
Django string signing in JavaScript (using String object prototypes)
/// Makes use of “hashes.js” -- q.v. https://git.io/fjsmQ
(function (hashes, undefined) {
var SIGNATURE_LENGTH = 27,
SIGNATURE_SALT = 'django.core.signing.Signer',
SIGNATURE_SECRET = 'YO DOGG',
SIGNATURE_SEPARATOR = ':',
SIGNATURE_DJANGO_SALT = 'signer';
@fish2000
fish2000 / display.py
Created April 24, 2019 20:35
Decorator to simplify setting display-related attributes in Django ModelAdmin subclasses
# encoding: utf-8
class display(object):
""" A decorator to make short work of using custom display/format methods
in Django ModelAdmin subclasses -- they'd have you do shit like this:
class DoggAdmin(ModelAdmin):
list_display = ['id', 'with_name']
def with_name(self, obj):
@fish2000
fish2000 / csvpadding.py
Last active August 15, 2019 16:36
CSV data padding
# encoding: utf-8
# Usage: `pad_csv(«uneven CSV data»)` -> «padded CSV data»
try:
from functools import reduce
except ImportError:
pass
segments = lambda line: len(line.split(','))
@fish2000
fish2000 / brew-receipt.sh
Last active June 3, 2022 02:55
Homebrew external-command script to show syntax-highlited install receipt JSON, using Pygments
#!/usr/bin/env bash
#: * `receipt` <formula> [<formula>...]:
#: Show the syntax-highlighted JSON install receipt for the specified formulae
function brew () {
"${HOMEBREW_PREFIX}/bin/brew" "$@"
}
irfilename="INSTALL_RECEIPT.json"
pygmentize="$(command -v pygmentize)"
@fish2000
fish2000 / keyvalue.py
Last active May 10, 2019 01:29
Generic Python REPL configuration NOW WITH ANSI-COLOR FIGLET BANNERS DOGG
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import plistlib
import zict
import os
import appdirs
from replutilities import attr, isstring, isbytes
@fish2000
fish2000 / .bash_prompt.sh
Last active January 30, 2019 07:40 — forked from miki725/.bash_prompt.sh
Custom bash prompt display: «virtualenv»:HOST-NAME:current_working_dir[git-branch •]$
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git/mercurial repository
# * the return value of the previous command
#
# USAGE:
@fish2000
fish2000 / cieXYZ.py
Created January 30, 2019 05:07
Coordinates for drawing the CIE1931 XYZ colorspace from above (née “Yxy”)
#!/usr/bin/env python
# encoding: utf-8
"""
cieXYZ.py
Party like it's 1931.
Created by FI$H 2000 on 2011-04-18.
Copyright (c) 2011 OST, LLC. All rights reserved.
@fish2000
fish2000 / # cpplocate - 2019-01-26_04-28-08.txt
Created January 26, 2019 09:35
cpplocate (cginternals/cginternals/cpplocate) on macOS 10.14.3 - Homebrew build logs
Homebrew build logs for cginternals/cginternals/cpplocate on macOS 10.14.3
Build date: 2019-01-26 04:28:08
@fish2000
fish2000 / # cppassist - 2019-01-26_04-26-36.txt
Created January 26, 2019 09:31
cppassist (cginternals/cginternals/cppassist) on macOS 10.14.3 - Homebrew build logs
Homebrew build logs for cginternals/cginternals/cppassist on macOS 10.14.3
Build date: 2019-01-26 04:26:36