Skip to content

Instantly share code, notes, and snippets.

Val Neekman un33k

View GitHub Profile
@un33k
un33k / nt.sh
Created Sep 26, 2010 — forked from epall/nt.sh
OSX: Start a new terminal with PWD=current directory
View nt.sh
#!/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 Sep 24, 2015
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.
View plex_watchdog.sh
#!/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 Jun 3, 2011
Script to run Linux vmware image on Mac OSX in headless mode
View vm.sh
# 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 Jun 3, 2011
Put Current Directory on Python Path (for quick testing)
View pylink
@un33k
un33k / pyulink
Created Jun 3, 2011
Remote a directory from the python path (site packages directory)
View pyulink
@un33k
un33k / df
Created Jun 3, 2011
Directory information cleaned up for dispaly
View df
#!/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 Jun 3, 2011
Setup your virtualenv & virtualenvwrapper to create directory for each work item
View virtualenv_instruction
#=== 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
View apache2.conf
### Basic daemon config
ServerRoot "/etc/apache2"
PidFile ${APACHE_PID_FILE}
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
ServerTokens ProductOnly
ServerAdmin webmaster@djangoproject.com
### Listen on localhost:8000 (behind the proxy)
@un33k
un33k / replication_fabfile.py
Created Jun 4, 2011 — forked from jacobian/replication_fabfile.py
A fab task to start pg9 hot standby.
View replication_fabfile.py
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 Jun 4, 2011 — forked from jacobian/check_postgres_replication.py
Nagios plugin to check PostgreSQL 9 streaming replication lag.
View check_postgres_replication.py
#!/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.
You can’t perform that action at this time.