Skip to content

Instantly share code, notes, and snippets.

View rahearn's full-sized avatar

Ryan Ahearn rahearn

  • 18F (work) + personal projects
  • Baltimore, MD
View GitHub Profile
@rahearn
rahearn / translate.rb
Created July 8, 2016 14:42
translate pipe-delimited files to CSV
require 'csv'
path = ARGV[0]
fail "path required" if path.nil?
csv = CSV.open "#{path}.csv", "w"
begin
File.open(path).each do |line|
line = line.strip.force_encoding('iso-8859-1').encode 'UTF-8'
csv << line.split('|', -1)
@gruber
gruber / make_bookmarklet.pl
Last active May 5, 2024 21:11
JavaScript Bookmarklet Builder
#!/usr/bin/env perl
#
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR
@prwhite
prwhite / Makefile
Last active July 16, 2024 02:14
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
@omnifroodle
omnifroodle / .vimrc
Last active December 20, 2015 00:09
My fish ~/.config/fish/config.fish with rbenv, go, custom git status icons, and aws ec2/cfn tools
set shell=bash
@rahearn
rahearn / auto_strip_text_attributes.rb
Created March 20, 2012 19:17
Adding functionality to every model in a system
# This file is in lib
module AutoStripTextAttributes
extend ActiveSupport::Concern
included do
text_columns = columns.collect do |c|
c.name.to_sym if c.type == :string || c.type == :text
end.compact