Skip to content

Instantly share code, notes, and snippets.

View jathanism's full-sized avatar
🍕
See below.

Jathan McCollum jathanism

🍕
See below.
View GitHub Profile
@jathanism
jathanism / reactorless_example.py
Last active August 29, 2015 14:13
An example of fetching the time on any device where a specific user is found to be logged in. It's not the most useful example, but it's simple and gets the idea across on how to build workflows using ReactorlessCommando. It's also not super efficient, because it requires a new connection to each device for each subsequent step.
"""
user_example.py - Sample flow of using ReactorlessCommando.
This is an example of the following:
1. Run 'show users' on a list of devices.
2. Check if a certain user is found in the output for each device.
3. Execute 'show clock' on each device where user was found.
4. Display the results
"""
(import MockSSH)
(require mockssh.language)
(setv cmds
{"passwd" (command :name "passwd"
:type "prompt"
:output "Password: "
:required-input "1234"
:on-success ["prompt" "hostname#"]
import re
from django.conf import settings
from django.core import cache as django_cache
from mock import patch
from rest_framework.permissions import SAFE_METHODS
from rest_framework.response import Response
class CachedResourceMixin (object):
@property
@davewongillies
davewongillies / Serving Django apps behind SSL with Nginx.md
Last active April 24, 2025 21:36 — forked from aj-justo/gist:3228782
Serving Django apps behind SSL with Nginx

Configuring Nginx to serve SSL content is straight forward, once you have your certificate and key ready:

server { 
    listen 443 default ssl;
    root /path/to/source;
    server_name mydomain;

    ssl_certificate      /path/to/cert;
    ssl_certificate_key  /path/to/key;
@bruth
bruth / README.md
Created July 31, 2013 13:16
Django command that gives a set of subcommands a namespace. For example, a command named after an app can be defined with a set of subcommands, e.g. `python manage.py command subcommand`.

Subcommander

Managment commands are assumed to be unique across all apps in a Django project. This can lead to long or obscure command names in attempt to namespace those commands.

Subcommander acts as a proxy command giving the real commands a namespace. The subcommander module can be named after the app name or some derivation. The structure looks as follows:

myapp/
    management/
        commands/
@jpetazzo
jpetazzo / README.md
Last active August 21, 2019 17:55
Give network superpowers to docker

Unionize: network superpowers for your docker containers

Unionize lets you connect together docker containers in arbitrarily complex scenarios.

Note: I recommend to use https://github.com/jpetazzo/pipework instead.

  • pipework is a better name than unionize
  • it's hosted on a "real" github repo instead of a small gist :-)

Now if you want Unionize, it's still here. Just check those examples.

@jathanism
jathanism / commanduo.py
Created January 16, 2013 02:01
A ``ReactorlessCommando`` subclass that allows for running multiple Commando instances in the same program under the same reactor by preventing the instances from doing it themselves.
# commanduo.py - Running multiple Commando's in the same script
from trigger.cmds import Commando as CommandoBase
from twisted.internet import defer, task, reactor
from twisted.python import log
import sys
# Uncomment me for verbose logging.
#log.startLogging(sys.stdout, setStdout=False)
@admackin
admackin / .bashrc
Last active February 10, 2022 22:06
Sane SSH_AUTH_SOCK handling for Screen and Tmux, so that new SSH agents created by subsequent logons are still usable.
_ssh_auth_save() {
ln -sf "$SSH_AUTH_SOCK" "$HOME/.ssh/ssh-auth-sock.$HOSTNAME"
}
alias screen='_ssh_auth_save ; export HOSTNAME=$(hostname) ; screen'
alias tmux='_ssh_auth_save ; export HOSTNAME=$(hostname) ; tmux'
@jathanism
jathanism / dictobject.py
Last active December 9, 2015 20:28
A dictionary-like object to recursively (or not) represent its items as attributes, but still behaves like a dict in every way.
# -*- coding: utf-8 -*_
"""
A dictionary-like object to represent items as attributes, but still behaves
like a dict in every way.
"""
__author__ = 'Jathan McCollum'
__maintainer__ = 'Jathan McCollum'
__email__ = '[email protected]'
@jedda
jedda / gist:4103604
Created November 18, 2012 04:44
Configuring basic RADIUS on OS X 10.8 Server
# Configuring basic RADIUS on OS X 10.8 Server
# Jedda Wignall
# http://jedda.me
# Full writeup at: http://jedda.me/2012/11/configuring-basic-radius-os-108-server/
# create the SACL for access to RADIUS
dseditgroup -q -o create -u <admin user> -n . com.apple.access_radius
# configure radiusd to log both successful and failed authentications