alembic
is a great tool for managing migrations. However, sometimes you can get your branches divergent due to separate PRs. To resolve this, run the following commands:
# Find out where your branches fork
alembic branches
# abcdef
# ghijkl
# Determine which of the 2 branches is a commit in the new non-master branch
# Open that alembic revision in your editor
alembic
is great but lacks an out of the box way to set up running migrations against a specific database (e.g. development
, test
, production
). The following adjustments to its env.py
and alembic.ini
allow us to target a specific database:
Example:
alembic -x db=development upgrade head
env.py:
"use strict"; | |
(function() { | |
var supportsCSSText = getComputedStyle(document.body).cssText !== ""; | |
function copyCSS(elem, origElem, log) { | |
var computedStyle = getComputedStyle(origElem); |
Geometry.distanceSqToSegment = (function () { | |
// Define reusable variables to avoid memory thrashing | |
var ptV1 = [0.0, 0.0, 0.0]; | |
var v2V1 = [0.0, 0.0, 0.0]; | |
// Define and return our actual function | |
// DEV: We name our function inline as otherwise it's `<anonymous>` in stack traces | |
return function distanceSqToSegmentFn (pt, v1, v2) { | |
// Resolve the vectors between our vertices and our point | |
// DEV: This overwrites our reusable variable values |
// Load in glob and fs | |
var glob = require('glob'), | |
fs = require('fs'); | |
// Create a test directory | |
try { fs.mkdirSync('src'); } catch (e) {} | |
// Create a nested directory | |
try { fs.mkdirSync('src/nested'); } catch (e) {} |
In some cases for Python unit tests, we want to automatically perform setUp
methods in as declared in a base class. However, we still want setUp
to work as per normal in the subclass. The following code will proxy the new setUp
function to run it's base class' and the new one.
# Define a common test base for starting servers
class MyBaseTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""On inherited classes, run our `setUp` method"""
# Inspired via http://stackoverflow.com/questions/1323455/python-unit-test-with-base-and-sub-class/17696807#17696807
if cls is not MyBaseTestCase and cls.setUp is not MyBaseTestCase.setUp:
node_modules/ | |
I'm learning about SOPS and setting it up as my preferred mechanism for storing secrets. Here are my notes.
It’s security mechanism is that we (i.e. client) use a PUBLIC key from the receiver (i.e. server) and encode it with a random key (I’m saying nonce but it could be reused)
This varies from RSA and SSH because the server uses a PUBLIC key to identify the client.
Web of trust operates by still using PGP (i.e. encoding with recipient’s public key) but additionally, we can encrypt/sign the data as our own by signing it with the client’s private key.
This means the recipient will initially decrypt via our (i.e. client’s) public key (verifying the source) and then decrypting via their (i.e. server’s) private key to get the data.