Skip to content

Instantly share code, notes, and snippets.

Joe Smith 123456 147852
Bill Jones 987654 369852
Steve Miller 654321 852147
@pgib
pgib / README.md
Last active August 29, 2015 13:58
Simple Unix program to output a terminal bell (beep)

Compile with:

gcc beep.c -o beep

Or on platforms that no longer have gcc by default (e.g. FreeBSD 10):

cc beep.c -o beep

Made for tmux/screen to get your attention in a background window.

@pgib
pgib / ext.rb
Created March 11, 2014 15:39
Optional Jekyll monkey patch to use terminal-notifier to signal a Jekyll build completion. Put in _plugins/ext.rb
require 'jekyll-assets'
# optional notification for jekyll build completion
#
# gem install terminal-notifier
# rbenv rehash
#
module Jekyll
class Site
@pgib
pgib / .profile
Last active December 27, 2015 01:29
export TERM="screen-256color"
if tty -s; then
if [ -z "$WINDOW" ]; then
if tmux has-session -t devops; then
echo -n "tmux found. Re-attach? [Y/n]: "
read response
case $response in
N*|n*)
echo "Okay. Type 'tmux attach' later..."
@pgib
pgib / tmux.conf
Created October 31, 2013 05:31
vim-style copy and paste for tmux
# =======================================================================
# vim-style copy and paste
setw -g mode-keys vi
bind ] paste-buffer
bind-key -t vi-copy 'v' begin-selection
#bind-key -t vi-copy 'y' copy-selection
bind-key -t vi-copy 'y' copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
@pgib
pgib / README.md
Last active December 24, 2015 15:19
Throw this in your Jekyll `_plugins/ext.rb` or into a separate file.

Terminal Notifier for Jekyll site builds

This Jekyll monkey patch triggers a Mac OS X Notification Center notification using the terminal-notifier gem.

If you start jekyll without bundle, first install the necessary gems:

gem install terminal-notifier
gem install terminal-notifier-guard

If you start jekyll with bundle exec (ie. bundle exec jekyll serve --watch, ensure the above two gems are in your Gemfile:

@pgib
pgib / README.md
Last active December 24, 2015 15:18
A simple example of a Liquid tag for Jekyll.

Throw this in your plugins folder and then in your posts or pages, you would just have something like:

Checkout my Twitter feed! {% social_link twitter pgib %}
@pgib
pgib / .irbrc
Created August 27, 2013 21:42
OMG WHY HAVE I NOT ALWAYS HAD THIS??
IRB.conf[:USE_READLINE] = true
# awesome print
begin
require 'awesome_print'
AwesomePrint.irb!
rescue LoadError => err
warn "Couldn't load awesome_print: #{err}"
end
@pgib
pgib / manual-ban.conf
Created April 3, 2013 16:08
Simple fail2ban filter for use with https://gist.github.com/pgib/5302582
[Definition]
# Option: failregex
# Notes.: regex to match the password failures messages in the logfile. The
# host must be matched by a group named "host". The tag "<HOST>" can
# be used for standard IP/hostname matching and is only an alias for
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values: TEXT
#
failregex = has requested that (<HOST>) be banned$
@pgib
pgib / banip.sh
Last active December 15, 2015 18:19
Simple script to write a log file suitable for fail2ban
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: banip <ip>"
exit 1
fi
for ip in $*; do
echo "Banning ip $ip"
date=`/bin/date +"%Y-%m-%d %H:%M:%S"`