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
sudo adduser $USER | |
#sudo usermod -aG sudo $USER # Give user sudo? | |
su - $USER | |
mkdir ~/.ssh | |
chmod 0700 ~/.ssh | |
touch ~/.ssh/authorized_keys | |
chmod 0600 ~/.ssh/authorized_keys | |
vim ~/.ssh/authorized_keys | |
chown -R $USER:$USER ~/.ssh |
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
#!/bin/bash | |
# remove exited containers: | |
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v | |
# remove unused images: | |
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi | |
# remove unused volumes: | |
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <( |
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
from enum import Enum | |
from django.db import models | |
class Blips(Enum): | |
BLOOP = 1 | |
BLIP_CHOICES = ( | |
(SomeEnum.BLOOP, 'Bloop'), | |
) |
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
import copy | |
import datetime | |
import numpy as np | |
from optparse import OptionParser | |
import time | |
import cv2 | |
from matplotlib import pyplot as plt | |
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
import numpy as np | |
import cv2 | |
def np_rotate_array(arr, shift): | |
"""Shift a numpy array to the right so that it wraps around.""" | |
return np.concatenate([arr[shift:], arr[:shift]]) | |
def main(): |
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
// Globally available utility library. | |
(function (window, document) { | |
'use strict'; | |
// attach as a property of window | |
var util = window.util || (window.util = {}); | |
function uniqify(list) { | |
var uniqified = {}; |
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
import unittest | |
from django.utils.functional import wraps | |
def retry(tries=1, ignore_exception=None): | |
""" | |
Decorator to retry a test. | |
:param ignore_exception: Exception class to catch. | |
:param tries: number of times to try running the wrapped function. | |
Don't use if you need to do something with the return value. |
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
/* Quick new angular app | |
* Accompany in template with: | |
<html ng-app="AppName" | |
ng-controller="AppCtrl"> | |
*/ | |
var app = angular.module('AppName', []); | |
app.config(['$interpolateProvider', '$httpProvider', | |
function($interpolateProvider, $httpProvider) { | |
// Change angular templating syntax from {{var}} to {[var]} so as not to |
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
from django.db import models | |
from django.db.models.query import QuerySet | |
class QuerySetExplainMixin: | |
""" | |
Dump SQL EXPLAIN for a Queryset. | |
Usage: `queryset.explain()` | |
""" | |
def explain(self, analyze=False, verbose=False): |
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
from cStringIO import StringIO | |
output = StringIO() | |
class bcolors: | |
HEADER = '\033[95m' | |
BLUE = '\033[94m' | |
GREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' |