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 / diff.py
Created September 23, 2011 13:39 — forked from readevalprint/diff.py
Django instance Diff - Now it's the bestestest.
#!/usr/bin/env python
class Missing:
pass
def diff(instance1, instance2=None, missing_field=None):
'''
Compares two instances and returns a dictionary of
the different fields and a tuple of the corrisponding values.
@jathanism
jathanism / wl_snmpd.sh
Created October 7, 2011 16:16 — forked from anonymous/wl_snmpd.sh
simple script to run a triggered snmp command get to wifi client info
#!/bin/sh
place=".1.3.6.1.4.1.2021.255"
refresh() {
id=1
lastid=0
noise_reference=$(wl -i `nvram get wl0_ifname` noise | cut -d" " -f3)
@jathanism
jathanism / .vimrc
Created April 19, 2012 23:40 — forked from averyvery/.vimrc
Tweaked Vim minimap
function! ToggleMinimap()
if exists("s:isMini") && s:isMini == 0
let s:isMini = 1
else
let s:isMini = 0
end
if (s:isMini == 0)
@jathanism
jathanism / gist:2472893
Created April 23, 2012 18:26 — forked from akoumjian/gist:1625633
Tastypie One Time Retrieval Resource Using Celery Task as object_class
class TempResource(Resource):
class Meta:
resource_name = 'temp_resource'
object_class = temp_resource.delay
authorization = Authorization()
allowed_methods = ['post', 'get']
always_return_data = True
def get_resource_uri(self, bundle_or_obj):
"""
@jathanism
jathanism / mainwindow.diff
Created May 14, 2012 23:08
Components/MainWindow.xml
--- /Users/jathan/Desktop/trav_xml/before/Phoenix/Components/MainWindow.xml 2011-11-11 10:07:56.000000000 -0800
+++ /Users/jathan/Desktop/trav_xml/new/Phoenix/Components/MainWindow.xml 2012-05-14 14:33:30.000000000 -0700
@@ -182,13 +182,12 @@
</Component>
-
- <!--
+ <!--
//////////////////////////////////////////////
@jathanism
jathanism / paramiko_statemachine.py
Last active October 10, 2015 08:28
Simple state machine to pipeline commands over an SSH channel using Paramiko and select
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is a prototype of a simple state machine that remotely executes a list of
commands via SSH on network devices (expecting the prompt_pattern to match) and
returns the results to you.
"""
__author__ = 'Jathan McCollum'
@jathanism
jathanism / encrypt.py
Created November 9, 2012 00:33
Simple AES crypto thingy to to encrypt/decrypt passwords.
# -*- coding: utf-8 -*-
"""
Simple AES crypto thingy to to encrypt/decrypt passwords.
"""
from Crypto.Cipher import AES # http://pypi.python.org/pypi/pycrypto
DEFAULT_PADDER = '\x03'
DEFAULT_KEYLEN = 16
@jathanism
jathanism / inject.py
Created December 13, 2012 16:00
A decorator to inject a namespace into a function's internal global namespace, and then clean it up when you're done. It can be used with or without an argument.
from functools import wraps
framework_namespace = {'api_key':"This is the api_key"}
def inject_namespace(fn=None, namespace=None):
"""
Inject a dictionary into the global namespace of the wrapped function
and then clean it up afterward. Hacktastic!
Credit: http://stackoverflow.com/a/3910211/194311
@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__ = 'jathanism@aol.com'
@jathanism
jathanism / pty_mitm.py
Created January 8, 2013 23:58
Python script which becomes a pseudo terminal so that it can act as a man in the middle between your terminal emulator and a running process. Source: http://sqizit.bartletts.id.au/2011/02/14/pseudo-terminals-in-python/
# Copyright (c) 2011 Joshua D. Bartlett
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in