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 flatten(sequence): | |
""" | |
Flatten an arbitrary nested sequence. | |
Example usage: | |
>> my_list = list(flatten(nested_lists)) | |
:param sequence: A nested list or tuple. | |
:returns: A generator with all values in a flat structure. | |
""" | |
for i in sequence: | |
if isinstance(i, Sequence) and not isinstance(i, (str, bytes)): |
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 | |
EXITED=$(docker ps -q -f status=exited) | |
DANGLING=$(docker images -q -f "dangling=true") | |
if [ "$1" == "--dry-run" ] | |
then | |
echo "==> Would stop containers:" | |
echo $EXITED | |
echo "==> And images:" | |
echo $DANGLING |
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
" Global settings | |
set hidden | |
set nocompatible | |
filetype off | |
" Vundle settings | |
" See https://github.com/gmarik/Vundle.vim for info. | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'gmarik/Vundle.vim' " let Vundle manage Vundle |
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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.core.exceptions import ImproperlyConfigured | |
class SetRemoteAddrFromForwardedFor(object): | |
""" | |
Middleware that sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, if the | |
latter is set. This is useful if you're sitting behind a reverse proxy that |
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 | |
import os | |
import sys | |
from gevent import monkey | |
from psycogreen.gevent import patch_psycopg | |
# The threading module raises a KeyError if already loaded | |
# when monkey patching it. | |
if "threading" in sys.modules: |
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
# some default settings | |
startup_message off | |
vbell off | |
msgwait 1 | |
defutf8 on | |
compacthist on | |
# Monitor windows | |
defmonitor on | |
activity "" |
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
# -*- coding: utf-8 -*- | |
from django import template | |
from django.utils.encoding import smart_unicode | |
register = template.Library() | |
class PaginateNode(template.Node): |
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
# ~/.bashrc: executed by bash(1) for non-login shells | |
# if not running interactively, dont't do anything | |
[ -z "$PS1" ] && return | |
# timezone info | |
export TZ="Europe/Oslo" | |
# don't put duplicate lines in the history. See bash(1) for more options | |
# don't overwrite GNU Midnight Commander's setting of `ignorespace'. |
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 | |
# | |
# A simple script to kill all connections to | |
# a postgresql database. | |
# | |
function usage() { | |
cat << EOF | |
usage: $0 options |