Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Uses a PID file to add daemon-like behavior to an arbitrary program.
################################################################################
usage() {
echo "Usage: `basename $0` PROGRAM {start|stop|restart|force-stop|force-restart|status} [PIDFILE|PID]" >&2
echo "Where: PROGRAM is an executable file." >&2
echo " PIDFILE is the file that contains (or will contain) the PID." >&2
echo " PID is a process id to use in place of a PIDFILE." >&2
}
@jrosco
jrosco / StatusIcon.py
Last active May 23, 2016 12:57 — forked from pklaus/StatusIcon.py
tray icon application using PyGTK
#!/usr/bin/env python
# found on <http://files.majorsilence.com/rubbish/pygtk-book/pygtk-notebook-html/pygtk-notebook-latest.html#SECTION00430000000000000000>
# simple example of a tray icon application using PyGTK
import gtk
def message(data=None):
"Function to display messages to the user."
@jrosco
jrosco / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jrosco
jrosco / onchange.sh
Last active August 29, 2015 14:13 — forked from senko/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@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

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@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
@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 / 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 / progress_bar.rb
Created March 24, 2016 04:39 — forked from kuntoaji/progress_bar.rb
Simple progress bar script without Gem using Ruby.
#!/usr/bin/env ruby
progress = 'Progress ['
1000.times do |i|
# i is number from 0-999
j = i + 1
# add 1 percent every 10 times
if j % 10 == 0