Skip to content

Instantly share code, notes, and snippets.

View jeremyf's full-sized avatar

Jeremy Friesen jeremyf

View GitHub Profile
@jeremyf
jeremyf / wp2bgg
Created September 25, 2012 00:54
Word Press to Board Game Geek
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'highline/import'
require 'open-uri'
conversions = [
["<blockquote>", '[q]' ],
["</blockquote>", '[/q]' ],
@jeremyf
jeremyf / .bashrc
Created October 8, 2012 19:17
.bashrc
PATH=$HOME/.rvm/bin:/usr/local/bin:/usr/local/sbin:$PATH # Add RVM to PATH for scripting
if [ -d ~/bin ]; then
echo "$PATH" | grep -q "$HOME/bin:" || export PATH="$HOME/bin:$PATH"
fi
if [ -f $HOME/.inputrc ]; then
export INPUTRC="$HOME/.inputrc"
fi
@jeremyf
jeremyf / override-engine-method.rb
Created January 18, 2013 16:48
Override and engine's method
require Sufia::Engine.config.root + 'app' + 'controllers' + 'dashboard_controller'
class DashboardController
def index
# And now index is overridden
end
end
@jeremyf
jeremyf / tools-for-troubleshooting-ruby.md
Last active February 7, 2018 19:05
Tools for Troubleshooting Ruby
@jeremyf
jeremyf / index.html.erb
Last active December 17, 2015 16:09
Follow-up to Extra Credit Challenge for Chicago 2013 RailsBridge for Code4Lib-ers
<!-- Found in /app/views/topics/index.html.erb -->
<h1>Listing topics</h1>
<table>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
@jeremyf
jeremyf / hooks_test.rb
Created May 28, 2013 18:53
hooks callback halting
should 'does not halt callbacks when a non-true result is encountered' do
@mum.class.after_eight { :before_failure }
@mum.class.after_eight { false }
@mum.class.after_eight { :after_failure }
results = @mum.run_hook(:after_eight)
assert_equal [:before_failure, false, :after_failure], results
end
@jeremyf
jeremyf / .gitconfig_for_pull_request
Created May 30, 2013 14:50
A naive set of git aliases for pull requests
[alias]
branch-current = rev-parse --symbolic-full-name --abbrev-ref HEAD
number-of-commits-since-master = "! sh -c 'git log master..`git branch-current` --oneline | wc -l | tr -d \" \"'"
squash = "! sh -c 'git rebase --interactive HEAD~`git number-of-commits-since-master`'"
@jeremyf
jeremyf / project
Last active December 19, 2015 01:39
bashable file for creating and opening a Git repository in Sublime
#!/usr/bin/env ruby -w
# This script assumes your Repositories are in ~/Repositories and your Sublime Projects are in ~/Projects
project_name = ARGV[0]
if !project_name && ENV['PWD']
project_name = ENV['PWD'].split("/").last
end
if project_name
@jeremyf
jeremyf / Rakefile
Created July 26, 2013 13:54
Rake file configuration for mountable Rails 3.x engine
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
# I want these tasks local to the project, not in Rake's 'app' namespace
Dir.glob('tasks/*.rake').each { |r| import r }
@jeremyf
jeremyf / latin1-to-utf8.rb
Last active August 19, 2019 16:52
A ruby script to help automate getting a Rails application out of MySQL's character encoding hell.
# The below script attempts to automate the character encoding challenges
# encountered with mysql, latin1 and UTF8
# http://www.bluebox.net/news/2009/07/mysql_encoding/
# ==============================================================================
# Copyright © 2013 University of Notre Dame
# Additional copyright may be held by others, as reflected in the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.