This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# | |
# Remove blank lines from a file. | |
# | |
# Usage: | |
# | |
# ruby vacuum.rb /path/to/file | |
# | |
module Vacuum | |
def self.run(filepath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ask question | |
print question | |
STDIN.gets.chomp | |
end | |
new_problem = true | |
10.times do | |
if new_problem | |
one = rand(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |