Skip to content

Instantly share code, notes, and snippets.

View cskeeters's full-sized avatar

Chad Skeeters cskeeters

View GitHub Profile
@cskeeters
cskeeters / broadcast_calc.sh
Created December 8, 2016 19:17
Bash script for calculating network and broadcast addresses from ip and netmask or CIDR Notation
#!/bin/bash
# Calculates network and broadcast based on supplied ip address and netmask
# Usage: broadcast_calc.sh 192.168.0.1 255.255.255.0
# Usage: broadcast_calc.sh 192.168.0.1/24
tonum() {
if [[ $1 =~ ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+) ]]; then
# This script allows a users to open files from finder in vim inside of iTerm
#
# If vim is already running in iTerm, this script won't open the file from within
# vim. The script is not that smart.
#
# This script will work in three different scenarios:
# 1. iTerm is not running at all. In this case, when iTerm is launched, a new
# window is created, but only after a second. This window won't have
# anything running in it, so we can start vim in that window without
# creating a new tab first.
#!/bin/bash
if [ "$#" -ne "1" ]; then
echo "Usage: $0 package_list"
exit 1
fi
cat $1 | xargs -I {} bash -c "echo {}; brew deps {}" | sort | uniq > /tmp/brew_keep
comm -23 <(brew list -1 | sort) <(cat /tmp/brew_keep) > /tmp/brew_rm
lines=$(cat /tmp/brew_rm | wc -l | sed -e 's/ //g')
@cskeeters
cskeeters / .dir_colors
Last active January 19, 2017 00:59
dircolors compatible with 16 color base-vim (Started with RHEL6 /etc/DIR_COLORS)
# Configuration file for the color ls utility
# Synchronized with coreutils 8.5 dircolors
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR tty
@cskeeters
cskeeters / applescript_utils.rb
Last active May 24, 2016 16:01
Corrected applescript_utils.rb in "Search Safari and Chrome Tabs" Alfred 2 Workflow
module BrowserTabs
module AppleScriptUtils
class AppleScriptError < StandardError; end
class << self
def run_file(filename, *args)
osascript(true, *args)
end
def run(src, *args)
@cskeeters
cskeeters / Beep.java
Created December 16, 2015 19:30
Script to test the PC speaker
import java.awt.*;
public class Beep
{
public static void main(String[] argv) {
java.awt.Toolkit.getDefaultToolkit().beep();
}
}
@cskeeters
cskeeters / base16-default-20.sh
Created March 20, 2014 21:45
Demo setting colors in the terminal/vim starting with 20
#!/bin/sh
# Base16 Default - Console color setup script
# Chris Kempson (http://chriskempson.com)
color00="15/15/15" # Base 00 - Black
color01="ac/41/42" # Base 08 - Red
color02="90/a9/59" # Base 0B - Green
color03="f4/bf/75" # Base 0A - Yellow
color04="6a/9f/b5" # Base 0D - Blue
color05="aa/75/9f" # Base 0E - Magenta