Skip to content

Instantly share code, notes, and snippets.

@tatic0
tatic0 / thread-subprocess.py
Created December 29, 2016 16:02
Python thread + subprocess example
# it will calculate the md5sum of
# all files in the arborescence
from threading import Thread
import subprocess
import os
def slowthing(i):
cmd = ["md5sum", i]
print(cmd)
@dryan
dryan / settings.py
Last active September 7, 2023 11:04
Handling EC2 ELB health checks and Django's ALLOWED_HOSTS setting.
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
'yourdomain.tld',
'.compute-1.amazonaws.com', # allows viewing of instances directly
]
import requests
EC2_PRIVATE_IP = None
try:
@tatic0
tatic0 / gist:4160731
Created November 28, 2012 12:02 — forked from yyuu/gist:1569253
df in python on Linux
#!/usr/bin/env python
# df.py
# inispirational code taken from:
# https://gist.github.com/1569253
from __future__ import with_statement
import contextlib
import os
import sys
@dcramer
dcramer / track_data.py
Created December 6, 2010 19:15
Tracking changes on properties in Django
from django.db.models.signals import post_init
def track_data(*fields):
"""
Tracks property changes on a model instance.
The changed list of properties is refreshed on model initialization
and save.
>>> @track_data('name')