Skip to content

Instantly share code, notes, and snippets.

View YellowSharkMT's full-sized avatar

The Yellow Shark YellowSharkMT

View GitHub Profile
@YellowSharkMT
YellowSharkMT / wp_fabfile.py
Created February 7, 2012 19:28
Wordpress Fabfile
# Wordpress Fabfile, for migrating the database, and deploying w/ git.
# For background: "My New & Improved Fabfile for Deploying WordPress"
# http://wp.me/p2a3Vy-1b
#
# This fabfile is specifically-geared for our unique setup, which consists
# of 2 servers (local, remote), and 3 sites (local, dev, and prod). Dev and
# prod sites both live on the remote server.
#
# In general, a little bit of the programming happens on a local site,
# but the database updates and file uploads (both in Wordpress, and edits
@YellowSharkMT
YellowSharkMT / nyt-paywall-blocker.pac
Created March 27, 2013 16:29
PAC Script to block NYT paywall. See http://www.proxypacfiles.com/proxypac/ for more info on Automatic Proxy Configuration
/*
Proxy PAC Script to block the NYT paywall
==========================================
Save this file to your local machine (example: my_proxy_config.pac), and then search "[your browser]
automatic proxy configuration" to find out how to implement it with your browser. For Firefox, go to
Tools -> Options -> Advanced -> Network tab -> Connection box -> Settings, and select Automatic Proxy
Configuration URL, and use a format like this for the file:
file:///c:/users/me/Dropbox/bin/my_proxy_config.pac
@YellowSharkMT
YellowSharkMT / gist:5623331
Last active December 17, 2015 14:19
Simple Fabric example script. Save it as "fabfile.py" in a folder, and open a shell up to that folder. Example commands: "fab prod test:AAAAAA", or "fab localhost tail".
# Most important thing to import
from fabric.api import *
# Not necessary, but useful for making timestamps
import time
# Allows Fabric to use profiles from your ~/.ssh/config file
env.use_ssh_config = True
def prod():
@YellowSharkMT
YellowSharkMT / pygit2.sh
Created March 12, 2014 16:53 — forked from olivier-m/pygit2.sh
Install LibGit2 & PyGit2 to a Virtual Environment (venv must be activated before executing this script). Tested on Ubuntu 12.04.4.
#!/bin/sh
set -e
if [ "${VIRTUAL_ENV}" = "" ]; then
echo "Error: Not in a virtual env"
exit 1
fi
OS=$(uname -s)
@YellowSharkMT
YellowSharkMT / BS Classname Helper
Created November 8, 2014 01:10
Javascript function that adds a class to the <body> element that denotes a particular responsive view/width for Bootstrap. Class names are bs-lg, bs-md, bs-sm, and bs-xs.
(function($, _window, undefined) {
$(document).ready(function () {
var $body = $('body');
var $tmp = $('<span id="bs-visibility-tester"/>');
var identifyBootstrapViewname = function (){
$tmp.appendTo($body);
var visible_for;
$.each(['lg','md','sm','xs'], function(z, viewname){
$tmp.addClass('visible-' + viewname);
@YellowSharkMT
YellowSharkMT / watch_memory_usage.py
Created December 2, 2014 20:43
Python shell script, displays memory usage for a user's processes. Also displays warning message if the usage is over a configurable amount.
#!/usr/bin/python
import subprocess
from datetime import datetime
import time
import sys
import itertools
# Configurable Values
MEM_LIMIT = 600000
#!/usr/env python
"""
Fetches a set of placeholder images from placehold.it. Iterates over the background colors specified, and
uses the same text for each slide. Image filenames contain an index, the size, and the bg color.
Warning: quick/dirty script. Would be cooler if options could be entered on the command-line. Also would
probably be cooler to use the subprocess module, instead of os.system()
"""
import os
@YellowSharkMT
YellowSharkMT / watch_mem_usage.py
Created December 6, 2015 02:27
Python script that polls memory usage for a Linux user
#!/usr/bin/python
"""
This script is intended to run infinitely (ctrl-c to exit). It executes a "ps" command, and then
parses the result to determine the total memory usage for a given user account. It will output a
warning message if that value exceeds a specified threshold.
The following values can be configured:
USER - the account to be watched. The $USER bash environment variable is the default.
MEM_WARNING_LEVEL - warning message will be shown if current usage is above this
@YellowSharkMT
YellowSharkMT / nginx_custom_configure.sh
Last active December 6, 2015 21:53
Compile Nginx for Webfaction
#!/bin/bash
# This script is intended to be executed from the root directory of
# the extracted Nginx ZIP file. The ZIP file is available http://nginx.org/en/download.html
# The Nginx config dir will be ~/etc/nginx.
# The default HTML directory will be ~/htdocs/html.
#
# IMPORTANT NOTE: this script makes an attempt to be "upgrade-friendly". It backs up
# up the existing nginx directory, prior to upgrading, and also makes a copy of the
# existing ~/etc/nginx/nginx.conf file.
#
@YellowSharkMT
YellowSharkMT / fabfile.py
Created November 29, 2016 00:23
Simple example of a "new-style" Fabric task
# For reference, see:
# - http://docs.fabfile.org/en/1.12.0/usage/tasks.html#new-style-tasks
# - http://docs.fabfile.org/en/1.12.0/api/core/tasks.html
# - http://docs.fabfile.org/en/1.12.0/usage/execution.html#execute
from fabric.api import env, run, roles, execute
from fabric.tasks import Task
env.use_ssh_config = True
env.roledefs = {