Skip to content

Instantly share code, notes, and snippets.

View zenweasel's full-sized avatar
🏠
Working from home

Brent Hoover zenweasel

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from flask import Flask, request, redirect, url_for, send_from_directory, render_template
import mimetypes
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])
UPLOAD_FOLDER = os.path.abspath(os.path.dirname(__name__))
@zenweasel
zenweasel / watcher.py
Created November 25, 2014 02:08
The Watcher that will not die
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import threading
import sys
import time
class Watcher(object):
@zenweasel
zenweasel / gist:f6143d7bad31608561fb
Created November 25, 2014 02:06
The Watcher that will not die
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import threading
import sys
import time
class Watcher(object):
@zenweasel
zenweasel / runplaybook.py
Created October 24, 2014 23:23
runplaybook
#!/usr/bin/env python
import os
from termcolor import colored, cprint
import ansible.playbook
import ansible.constants as C
import ansible.utils.template
from ansible import errors
from ansible import callbacks
@zenweasel
zenweasel / cron.py
Last active August 29, 2015 14:05
Base Cron Object
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from optparse import OptionParser
import logging
from cron.utils.nagios import nagios_success, nagios_failure, nagios_warning
from reservation.provider.base import BaseProvider
@zenweasel
zenweasel / daemon.py
Created August 15, 2014 20:13
Simple Daemon Worker
"""
***
Modified generic daemon class
***
Author: http://www.jejik.com/articles/2007/02/
a_simple_unix_linux_daemon_in_python/www.boxedice.com
License: http://creativecommons.org/licenses/by-sa/3.0/
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> REMOTE_MODULE setup
<127.0.0.1> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/brent/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=2222', '-o', 'IdentityFile="/home/brent/.vagrant.d/insecure_private_key"', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1407903495.03-60894458071659 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1407903495.03-60894458071659 && echo $HOME/.ansible/tmp/ansible-tmp-1407903495.03-60894458071659'"]
fatal: [default] => SSH encountered an unknown error. The output was:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/brent/.ssh/config
debug1: Reading configuration data
WITH btree_index_atts AS (
SELECT nspname, relname, reltuples, relpages, indrelid, relam,
regexp_split_to_table(indkey::text, ' ')::smallint AS attnum,
indexrelid as index_oid
FROM pg_index
JOIN pg_class ON pg_class.oid=pg_index.indexrelid
JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
JOIN pg_am ON pg_class.relam = pg_am.oid
WHERE pg_am.amname = 'btree'
),

Keybase proof

I hereby claim:

  • I am zenweasel on github.
  • I am zenweasel (https://keybase.io/zenweasel) on keybase.
  • I have a public key whose fingerprint is 1B8B 63B4 36BF 68E6 31A2 9C69 8ACF 830B B2E8 5C5B

To claim this, I am signing this object:

@zenweasel
zenweasel / memorymiddleware.py
Created February 27, 2014 19:10
A very rough and simple memory profiling middleware
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Based on a StackOverflow post by Graham Dumpleton
import os
import psutil
import logging