Skip to content

Instantly share code, notes, and snippets.

View jrosco's full-sized avatar
:shipit:
winning

Joel Cumberland jrosco

:shipit:
winning
View GitHub Profile
@jrosco
jrosco / osx_socks.py
Created October 13, 2015 09:23 — forked from michaelballantyne/osx_socks.py
Yet another Mac SSH SOCKS proxy script. This one handles connection failure properly.
#!/usr/bin/env python
# Public domain.
"""A script to establish an SSH SOCKS proxy and enable it in the OS X network configuration.
Cleanly handles failure to connect. Kills ssh and removes network configuration on CTRL-C.
First argument gives the hostname for use with ssh."""
import subprocess, sys, signal
proxy_command_base = ['networksetup', '-setsocksfirewallproxystate', 'Wi-Fi']
@jrosco
jrosco / rds.sh
Last active September 5, 2015 06:00 — forked from onyxraven/rds.sh
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
@jrosco
jrosco / tmux.conf
Last active August 29, 2015 14:24 — forked from spicycode/tmux.conf
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
class LogWrappedFunction(object):
def __init__(self, function):
self.function = function
def logAndCall(self, *arguments, **namedArguments):
print "Calling %s with arguments %s and named arguments %s" %\
(self.function.func_name, arguments, namedArguments)
self.function.__call__(*arguments, **namedArguments)
def logwrap(function):
class SetterNGetter():
def __init__(self, *args, **kwargs):
self.my_age = kwargs['age']
self.my_name = kwargs['name']
@property
def my_age(self):
return self.my_age
def outsideFunc(Func):
def one(*args, **kwargs):
print Func(*args, **kwargs)
def two(*args, **kwargs):
print Func(*args, **kwargs)
def nothing(*args, **kwargs):
print Func(*args, **kwargs)
@jrosco
jrosco / nadar.py
Last active August 29, 2015 14:14 — forked from emad-elsaid/nadar.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# prerequisites :
# sudo apt-get install nmap
#
# nmap.py
# Network Radar
#
#
# This program is free software; you can redistribute it and/or modify
@jrosco
jrosco / popup gtk.window
Last active December 4, 2017 00:20
Gtk icon popup gtk.window
#!/usr/bin/python
import gtk
class StatusIcon:
def __init__(self):
self.statusicon = gtk.StatusIcon()
@jrosco
jrosco / restart_py.py
Last active March 9, 2025 10:05
Restart running python program from inside app
#!/usr/bin/env python
import sys
import os
def restart_program():
"""Restarts the current program.
Note: this function does not return. Any cleanup action (like
saving data) must be done before calling this function."""
python = sys.executable
os.execl(python, python, * sys.argv)