Skip to content

Instantly share code, notes, and snippets.

View optparse-template.rb
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
View gist:95270b8d9522438367ef
Some notes on remote debugging mac builds on Travisci. It's hard to tell when something hangs what the cause it. Trial and error via commits is tedious. And on Mac , sometimes it's the gui asking for input. So I worked my around to get the access I needed for faster debugging a build.
#################################################
# Enable remote ssh access to travisci build for debugging
#################################################
# Add a key so we can login to travisci vm
- cat ssh/travisci.pub >> ~/.ssh/authorized_keys
- chmod 600 ssh/travisci
# Install netcat
View ruby_confs_2013.md
@svenfuchs
svenfuchs / en.yml
Created Aug 4, 2011 — forked from mislav/en.yml
will_paginate i18n keys
View en.yml
en:
# ommitting the :views namespace here probably isn't an option?
will_paginate:
page_entries_info:
single_page:
zero: "No %{model} found"
one: "Displaying 1 %{model}"
other: "Displaying all %{count} %{model}"
multi_page: "Displaying %{model} %{from} - %{to} of %{total} in total"
models:
View gist:1027175
diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb
index cd9f54e..365841e 100644
--- a/actionpack/test/template/translation_helper_test.rb
+++ b/actionpack/test/template/translation_helper_test.rb
@@ -53,6 +53,12 @@ class TranslationHelperTest < ActiveSupport::TestCase
assert_equal false, I18n.translate(:"translations.missing").html_safe?
end
+ def test_i18n_translate_returns_unsafe_even_if_using_html_rescue_format
+ expected = '<span class="translation_missing" title="translation missing: en.translations.missing">Missing</span>'
View ruby_rvm_system_invocation.rb
#!/usr/bin/env ruby
# How to run a system command from ruby within a clean bash that has never sourced rvm using a custom ruby version
# 1) install rvm as the correct user
# 2) do NOT follow the instructions about sourcing and adding this to your .bashrc
# 3) run the following (change the versions accordingly)
ruby_versions = %w(ruby-1.8.7-p330 rbx-head)
View install rubycocoa over rvm's 1.8.7
~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
View hubcut
#!/usr/bin/env ruby
# This script copies all .gem files for all versions of a gem from gems.github.com to gemcutter.org.
# For all versions of a gem, it does a gem fetch, repackages the gem with the non-namespaced name,
# and does a gem push. You must have permission to push the gem, so your gemcutter key must be
# set in ~/.gemrc
require 'rubygems'
require 'yaml'
require 'fileutils'
View snippet.rb
const_set(:"(•___){", Class.new do
def initialize
puts "too many tweets!"
end
end)
const_get(:"(•___){").new
# ... hmmmm.
View return.rb
module Enumerable
def return(*)
if block_given?
each do |i|
value = yield(i)
return value if value
end
nil
else
super