Skip to content

Instantly share code, notes, and snippets.

@fallwith
fallwith / gist:9383650
Created March 6, 2014 06:37
rubyctags - Bash script for generating an Exuberant Ctags file for a Ruby project
#!/usr/bin/env bash
# Generate an Exuberant Ctags file for a Ruby project
#
# - Accepts an optional argument of the starting search directory or file.
# - The starting path will be walked up until either a tags file or other
# project root indicating file/dir can be found.
tags_file=.tags
declare -a root_markers=(.git .hg .svn .bzr _darcs)
@fallwith
fallwith / gist:b2d51706747937cbf5ea
Created September 25, 2014 22:30
Upgrade Bash from source in response to shellshock
#!/bin/sh
# build and install a fully patched bash 4.3 to mitigate shellshock
#
# to determine vulnerability:
# %> env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
mkdir bash_src
cd bash_src
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
# Use Ack to find offending source files and Perl to perform the following:
# convert Windows newlines to unix newlines
# convert tabs to two spaces
# strip trailing whitespace
ack " +$|\t|\r" -l|xargs perl -pi -e "s/\r\n?/\n/g;s/\t/ /g;s/[ ]*$//g"
# Implement a clean() method in Bash:
# Clean up source code by converting tabs to 2 spaces, Windows newlines to
# unix ones, and by stripping away trailing whitespace. Pass in a list of
# ~/.gitconfig
[user]
email = address@domain.com
name = username
editor = mate -w
[color]
diff = auto
status = auto
branch = auto
[alias]
#!/usr/bin/env ruby -w
require 'redis'
require 'benchmark'
HOST = 'localhost'
PORT = 6379
SETNAME = 'benchmark_testing_set'
SETSIZE = 7500
def prep(array)
#!/usr/bin/env ruby -w
require 'redis'
require 'benchmark'
HOST = 'localhost'
PORT = 6379
SETNAME = 'benchmark_testing_set'
SETSIZE = 3000
def prep(array=[])
@fallwith
fallwith / .ackrc
Created October 25, 2010 23:40
My ~/.ackrc file
--ignore-dir=log
--ignore-dir=logs
--ignore-dir=images
--ignore-dir=javascripts
--ignore-dir=stylesheets
--ignore-dir=tmp
--ignore-dir=vendor
--ignore-case
--smart-case
@fallwith
fallwith / Homebrew MySQL 5.5 formula
Created March 13, 2011 06:44
Replacement 'mysql' formula to use 5.5 (via Dr. Watson's 'mysql55' formula)
# Adapted from Dr. Watson's 5.5.8 formula
# https://github.com/dctrwatson/homebrew/blob/5fe26cbc27eceb0955836f9b5434c3ed6ef0de76/Library/Formula/mysql55.rb
require 'formula'
class Mysql < Formula
homepage 'http://dev.mysql.com/doc/refman/5.5/en/'
url 'http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.5.9.tar.gz'
md5 '701c0c44b7f1c2300adc0dc45729f903'
depends_on 'readline'
@fallwith
fallwith / mempercent.sh
Created March 28, 2011 03:31
Determine system memory usage as a percentage (Linux)
free|grep /|awk '{print $3/($3+$4)*100}'
@fallwith
fallwith / netflix_ratings_spider.rb
Created May 12, 2011 06:28
Via AppleScript, tell Safari to fetch the HTML for every page of your Netflix ratings and output the collected ratings to a CSV file.
#!/usr/bin/env ruby
require 'iconv'
# This is a simple script to spider your Netflix paginated "What You've Rated" list.
# It requires an OS X based system with Ruby 1.9+, Safari, and AppleScript
#
# I could not find a way to back up my ratings (for all titles, not just my rental activity)
# without registering for a Netflix API key or handing my Netflix credentials over to someone
# who had an API key, so I decided to take a brute force approach and just parse the HTML for
# every page of my ratings history on Netflix's site.