Skip to content

Instantly share code, notes, and snippets.

View inertialbit's full-sized avatar

Jeremiah Heller inertialbit

  • Willamette Valley, Oregon, US
View GitHub Profile
@inertialbit
inertialbit / ansible-ubuntu-ruby-playbook.yml
Created January 21, 2013 18:10
installs rbenv via rbenv-installer, ruby matching $ruby_version and passenger + apache2 module to $user home and updates $user/.bash_profile w/ rbenv env vars
---
- name: install rb-installer
action: shell curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
- name: update PATH in ~/.bash_profile for rb-env
action: lineinfile dest=/home/$user/.bash_profile line=export\ PATH="$HOME/.rbenv/bin:$PATH" regexp=PATH.*rbenv
- name: add rb-env init to ~/.bash_profile
action: lineinfile dest=/home/$user/.bash_profile line='eval "$(rbenv init -)"' regexp=eval.*rbenv
@inertialbit
inertialbit / vacuum.rb
Created October 24, 2012 19:18
remove blank lines from a file
##
#
# Remove blank lines from a file.
#
# Usage:
#
# ruby vacuum.rb /path/to/file
#
module Vacuum
def self.run(filepath)
@inertialbit
inertialbit / decode64.rb
Created March 28, 2012 20:46
Quick script to help recover garbled base64 encoded mail attachments.
# Quick script to help recover garbled base64 encoded mail attachments.
# Converts files in place.
# Usage:
# # decode files in the current directory
# ruby decode64.rb ./ file_one.jpg file_two.png file_three.gif
# # decode files in another directory
# ruby decode64.rb /path/to/else/where other.png estimate.doc
require 'base64'
@inertialbit
inertialbit / encode_images.rb
Created February 24, 2012 11:28
generate base64 multipart messages
require 'base64'
cur_dir = File.dirname(File.expand_path(__FILE__))
img_dir = File.join cur_dir, 'images'
Dir.chdir cur_dir
Dir.glob("*.{jpg,png}").each do |filename|
img = File.new(filename, 'r')
encoded_data = Base64.encode64 img.read
@inertialbit
inertialbit / 10 addition probs (0..10)
Created November 5, 2011 19:50
quick and dirty arithmetic cli
def ask question
print question
STDIN.gets.chomp
end
new_problem = true
10.times do
if new_problem
one = rand(10)
@inertialbit
inertialbit / behavior.coffee
Created May 19, 2011 15:47
coffee script ex jquery+lowpro behavior
TextareaExpander = $.klass({
contructor: (pixelsToGrowBy, maxHeight) ->
@pixelsToGrowBy = pixelsToGrowBy ? 20
@maxHeight = maxHeight ? 999
this.onkeypress
onkeypress: (event) ->
currentHeight = this.element.height
scrollHeight = this.element[0].scrollHeight
while currentHeight < scrollHeight and currentHeight < @maxHeight
@inertialbit
inertialbit / culerity.js
Created May 5, 2011 17:41 — forked from jlindsey/culerity.js
Using Cucumber/Capybara/Culerity, a step to wait until all AJAX calls are complete.
// this allows culerity to wait until all ajax requests have finished
jQuery(function($) {
var original_ajax = $.ajax;
var count_down = function(callback) {
return function() {
try {
if(callback) {
callback.apply(this, arguments);
};
} catch(e) {
<ul class="events">
<li><span class="collapsible open">2010</span>
<ul>
<li><span class="collapsible closed">January</span>
<ul>
<li>
<p class="collapsible closed">Primary Content Identifier 1</p>
<p>Primary Content</p>
</li>
var Collapsible = $.klass({
initialize: function() {
this.element.find('.open').each(function(i, e) {
$(e).siblings().show();
});
this.element.find('.closed').each(function(i, e) {
$(e).siblings().hide();
});
},
onclick: $.delegate({
# send path helper to correct engine when mounting engine routes
class EngineHelper::ApplicationController < ApplicationController
helper_method :engine_path
private
def registered_engines
Rails::Engine.subclasses.map do |sc|
sc.to_s.underscore.gsub("/engine", "")
end << 'main_app'