Skip to content

Instantly share code, notes, and snippets.

@rbrooks
rbrooks / gist:2124882
Created March 19, 2012 19:17
SSH - Forward Tunnel
# Use Case
# --------
# You have solely SSH (port 22) access to a box on a remote LAN.
# You have no Admin access to the firewall to forward ports.
# You need to browse the website on the box via a Web browser.
# From your local, desktop machine:
sudo ssh -NL 80:localhost:80 root@<IP or hostname>
@rbrooks
rbrooks / gist:2480247
Created April 24, 2012 14:54
jQuery from Chrome Console
// Paste these 7 lines into Chrome JS console.
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
@rbrooks
rbrooks / gist:2512905
Created April 27, 2012 20:41
Changelog Generator
#!/usr/bin/env ruby
# Changelog Generator
# Right now, this is date-based.
# TODO: Changelog between two Tags, eg: --tags=1.0.0..1.0.1
from_date = ARGV[0]
cmd = `git log --no-merges --since='#{from_date}' --pretty='format:%ci::%an <%ae>::%s'`.split /\n/
@rbrooks
rbrooks / gh_to_pt.rb
Created May 15, 2012 18:20
Migrate GitHub Issues to Pivotal Tracker
#!/usr/bin/env ruby
# Author: Russ Brooks, TelVue Corporation (www.telvue.com)
# Description: Migrates GitHub Issues to Pivotal Tracker.
# Dependencies: Ruby 1.9.2+
# GitHub API gem: https://github.com/peter-murach/github
# Pivtal Tracker gem: https://github.com/jsmestad/pivotal-tracker
# 1. Change the constants below accordingly for your project.
# 2. Change the options in list_repo() method for your GitHub project.
# 3. Change the options in stories.create() method accordingly.
@rbrooks
rbrooks / shape_bandwidth.sh
Created May 17, 2012 16:03
Bandwidth Shape (Throttle) a Network Interface
#!/bin/bash
#
# tc uses the following units when passed as a parameter.
# kbps: Kilobytes per second
# mbps: Megabytes per second
# kbit: Kilobits per second
# mbit: Megabits per second
# bps: Bytes per second
# Amounts of data can be specified in:
# kb or k: Kilobytes
@rbrooks
rbrooks / ffmpeg_ffprobe.sh
Last active July 4, 2024 19:49
FFmpeg & FFprobe Cheatsheet
# Don't use FFmpeg for metadata extraction. Use FFprobe.
# Its output is geared toward parsabilty.
# Container and stream information in JSON format:
ffprobe -show_format -print_format json 'Serenity - HD Trailer.mp4'
ffprobe -show_streams -print_format json 'Serenity - HD Trailer.mp4'
# Human-readable values:
ffprobe -show_format -pretty -print_format json 'Serenity - HD Trailer.mp4'
# Trim video to first 30 seconds, without transcoding.
@rbrooks
rbrooks / delete_all_but_certain_dirs.sh
Created June 11, 2012 20:12
Delete all but certain directories in current directory.
# Do the Find first, as a trial run.
find . -type d \( ! -iname "7604e960-3fc9-012f-2342-52540002105a" ! -iname "760660a0-3fc9-012f-2342-52540002105a" ! -iname "cac012a0-46b5-012f-1584-52540002105a" ! -iname "981fc740-8bf0-012f-2d2b-52540002105a" ! -iname "e268a4d0-95f6-012f-c815-52540002105a" \)
# Then do the actual delete.
find . -type d \( ! -iname "7604e960-3fc9-012f-2342-52540002105a" ! -iname "760660a0-3fc9-012f-2342-52540002105a" ! -iname "cac012a0-46b5-012f-1584-52540002105a" ! -iname "981fc740-8bf0-012f-2d2b-52540002105a" ! -iname "e268a4d0-95f6-012f-c815-52540002105a" ! -iname "a6e42e40-66fc-012f-f998-525400977599" \) -execdir rm -rfv {} +
@rbrooks
rbrooks / diff_two_folders.sh
Created August 27, 2012 16:39
Find differences between two directory trees recursively
diff -qr dir dir2 | grep -v -e '.DS_Store' -e '.git' -e '.log' | sort > diffs.txt
@rbrooks
rbrooks / regex.rb
Created September 24, 2012 16:38
Useful RegExs
# Match from beginning of line to last occurrence of slash (/). Great for parsing filename off full paths.
# ^.*/(?!.*/)
@rbrooks
rbrooks / aspect_ratio_decimal_to_rational.rb
Created October 5, 2012 14:59
Convert Decimal Aspect Ratio to Rational in Ruby
# 4:3
1.333.to_r.rationalize(Rational('0.001'))
# => (4/3)
# 16:9
1.778.to_r.rationalize(Rational('0.001'))
# => (16/9)
# Common PAR:
1.212.to_r.rationalize(Rational('0.001'))