Skip to content

Instantly share code, notes, and snippets.

@rbrooks
rbrooks / vagrant_plugin_installation_fail.sh
Last active July 25, 2016 21:24
Vagrant Plugin installation fails due to Gem installation failure by way of Bundler
# Someetimes `vagrant up` fails with a message like:
# Installing the 'vagrant-butcher' plugin. This can take a few minutes...
# Bundler, the underlying system Vagrant uses to install plugins,
# reported an error. The error is shown below. These errors are usually
# caused by misconfigured plugin installations or transient network
# issues. The error from Bundler is:
#
# An error occurred while installing rack (2.0.1), and Bundler cannot continue.
# Make sure that `gem install rack -v '2.0.1'` succeeds before bundling.
-- MySQL
-- Search all tables, databse-wide, for a column name.
-- EXACT MATCH
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('col_name')
AND TABLE_SCHEMA='db_name';
-- PARTIAL MATCH
@rbrooks
rbrooks / font-awesome-collection.rb
Created March 7, 2013 16:26
Output the entire Font Awesome icon set to the browser, in Decimal-Entity Notation.
%span{ style: "font-family: 'FontAwesome';" }
- (61440..61720).each do |n|
= ('&#' + n.to_s).html_safe;
@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'))
@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 / 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 / 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 / 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 / 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 / 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.