Skip to content

Instantly share code, notes, and snippets.

View un33k's full-sized avatar
🎯
Focusing

Avid Coder un33k

🎯
Focusing
View GitHub Profile
@un33k
un33k / nt.sh
Created September 26, 2010 00:45 — forked from epall/nt.sh
OSX: Start a new terminal with PWD=current directory
#!/usr/bin/env sh
# A simple script to open a new tab in Terminal in the current directory
# Author: Eric Allen
osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' > /dev/null 2>&1
osascript -e "tell application \"Terminal\" to do script \"cd $PWD && clear\" in window 1" > /dev/null 2>&1
@un33k
un33k / plex_watchdog.sh
Last active April 6, 2024 13:38
Plex on OSX often falls into a tight loop and consumes %100 of the CPU. This watchdog is to restart Plex to avoid running the CPU hot for an extended period of time.
#!/bin/sh
PLEX_APP='/Applications/Plex Home Theater.app/Contents/MacOS/Plex Home Theater'
COUNT=0
PLEX_CPU=0
LOOP=1
while [ $LOOP -le 14 ] ; do
PLEX_CPU=`ps aux | grep "$PLEX_APP" | awk '{print $3}' | head -n 1`
@un33k
un33k / vm.sh
Created June 3, 2011 18:05
Script to run Linux vmware image on Mac OSX in headless mode
# Start and stop headless VMs
# put this on your path as save it as vm or vm.sh.
# no need to turn your vmware on when running on Mac
# just run as vm start and it will list all the available vm images.
# then choose which one you want to start. perfect for running Linux under OSX
# in headless mode for development
# Note:, some of this script is from gist (72638254422dc741b299)
# Some rework and enhancement to make it work better and handle windows
#!/bin/bash
@un33k
un33k / pylink
Created June 3, 2011 18:14
Put Current Directory on Python Path (for quick testing)
@un33k
un33k / pyulink
Created June 3, 2011 18:16
Remote a directory from the python path (site packages directory)
@un33k
un33k / df
Created June 3, 2011 18:18
Directory information cleaned up for dispaly
#!/bin/sh
# github:norm:homedir:bin/df
# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*-
#
# Present the output of `df` in a more understandable fashion.
# Save this gist as df and put it on your path
/bin/df -h "$@" 2>/dev/null | perl -e '
$prefix = <>;
$longest_fs = 20;
@un33k
un33k / virtualenv_instruction
Created June 3, 2011 18:22
Setup your virtualenv & virtualenvwrapper to create directory for each work item
#=== Add VirtualEnv =======
# add local bin to path
PATH=$HOME/projects/bin:$PATH
export PATH
# virtualevnwrapper
export VHOME_DIR=$HOME/projects
export WORKON_HOME=$VHOME_DIR/.$HOSTNAME-virenv
export PIP_DOWNLOAD_CACHE=$VHOME_DIR/.pip_cache_dir
source /usr/local/bin/virtualenvwrapper.sh
### Basic daemon config
ServerRoot "/etc/apache2"
PidFile ${APACHE_PID_FILE}
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
ServerTokens ProductOnly
ServerAdmin [email protected]
### Listen on localhost:8000 (behind the proxy)
@un33k
un33k / replication_fabfile.py
Created June 4, 2011 02:22 — forked from jacobian/replication_fabfile.py
A fab task to start pg9 hot standby.
def start_replication():
"""
Begin Postgresql standby
"""
# Stop pg on the slave machine.
with settings(host_string=env.db_slave):
run('service postgresql-9.0 stop')
# Create the backup on the master machine
with settings(host_string=env.db_master):
@un33k
un33k / check_postgres_replication.py
Created June 4, 2011 02:25 — forked from jacobian/check_postgres_replication.py
Nagios plugin to check PostgreSQL 9 streaming replication lag.
#!/usr/bin/env python
"""
Nagios plugin to check PostgreSQL 9 streaming replication lag.
Requires psycopg2 and nagiosplugin (both installable with pip/easy_install).
MIT licensed:
Copyright (c) 2010 Jacob Kaplan-Moss. All rights reserved.