This file contains hidden or 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 time | |
| class CachedDict(object): | |
| """A dictionary where the items timeout after self.timeout seconds | |
| We've implemented just enough of a real dictionary to work as a | |
| replacement for the dicts in django.template.loader.cached.Loader | |
| """ |
This file contains hidden or 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.template.loaders.cached import Loader as CachedLoader | |
| from django.conf import settings | |
| from .cacheddict import CachedDict | |
| class Loader(CachedLoader): | |
| """A cached template loader where the templates expire after self.timeout | |
| seconds. |
This file contains hidden or 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 urllib.request import urlopen | |
| from django.conf import settings | |
| from django.template import Origin, TemplateDoesNotExist | |
| from django.template.loaders.base import Loader as BaseLoader | |
| from django.utils.module_loading import import_string | |
| class Loader(BaseLoader): |
This file contains hidden or 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 | |
| # uses surekillpid: https://gist.github.com/tubaman/377458a11fedb49cc2132ea6e31ae8b2 | |
| pgrep $@ | grep -v $$ | xargs --no-run-if-empty surekillpid |
This file contains hidden or 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 | |
| # How to try to kill a process | |
| # http://porkmail.org/era/unix/award.html#uuk9letter | |
| # Be as nice as possible before shooting it in the head | |
| # uses waitpid: https://gist.github.com/tubaman/00b792221bd75fbbca61184da3d414ce | |
| options=$(getopt -o v --long verbose -- $@) | |
| [ $? -eq 0 ] || { | |
| exit 1 | |
| } |
This file contains hidden or 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 | |
| # Wait for a process(es) to finish by pid | |
| # https://stackoverflow.com/a/41613532 | |
| for pid in $@; do | |
| tail --sleep-interval=0.250 --pid=$pid -f /dev/null | |
| done |
This file contains hidden or 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
| """Python module to get password data from password-store.org(pass) | |
| ex: | |
| from pwstore import pwstore | |
| password, data = pwstore("example.org") | |
| username = data['Username'] | |
| """ | |
| import re |
This file contains hidden or 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 | |
| set -o noglob | |
| function addfiles { | |
| NAME="$1" | |
| find $EXCLUDE -name "$NAME" >> cscope.files | |
| } | |
| function autoignore { |
This file contains hidden or 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 | |
| # Connect from one linux desktop to another using SSH over VNC | |
| # | |
| # The script works best if you have ssh public key authentication setup with | |
| # an agent so you don't have to type your ssh password 1000 times. | |
| # | |
| # Usage: vncssh remote_servername | |
| # | |
| # What does this do? | |
| # 1. Calculate the right scale factor so the remote desktop resolution will |
This file contains hidden or 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 logging | |
| import sys | |
| import csv | |
| import pint | |
| ureg = pint.UnitRegistry() | |
| logger = logging.getLogger(__name__) | |
| logger.setLevel(logging.INFO) |