Skip to content

Instantly share code, notes, and snippets.

View rsl's full-sized avatar
🏳️‍🌈
still a bad fish and free bird

Russell Norris rsl

🏳️‍🌈
still a bad fish and free bird
View GitHub Profile
# UTF-8, 'nuff said
contents = IO.read(file)
high_chars = []
contents.scan(/./m){|x|
high_chars << x[0] if x[0] > 128
}
high_chars.uniq!
unicode_1 = %w{Ä Å Ç É Ñ Ö Ü á à â ä ã å ç é è ê ë í ì î ï ñ ó ò ô ö õ ú ù û ü † ° ¢ £ § • ¶ ß ® © ™ ´ ¨ ≠ Æ Ø ∞ ± ≤ ≥ ¥ µ ∂ ∑ ∏ π ∫ ª º Ω æ ø ¿ ¡ ¬ √ ƒ ≈ ∆ « » …}
unicode_2 = %w{À Ã Õ Œ œ – — “ ” ‘ ’ ÷ ◊ ÿ Ÿ ⁄ € ‹ › fi fl ‡ · ‚ „ ‰ Â Ê Á Ë È Í Î Ï Ì Ó Ô  Ò Ú Û Ù}
mac = high_chars.all?{|x|
#!/bin/bash
source ~/.rvm/scripts/rvm
cd .
exec ruby "$@"
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/Library/PostgreSQL/9.0/bin:/usr/local/mysql/bin:/Users/rsl/.rvm/bin:/Users/rsl/bin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
export EVENT_NOKQUEUE=yes
export EDITOR='mate -w'
export PGOPTIONS='-c client_min_messages=WARNING'
export TM_GIT='/opt/local/bin/git'
export HIDE_ENV_BADGE=true
export NO_TEMPLATE_INLINER=true
function n {
Last login: Thu Mar 3 14:24:49 on ttys001
rsl@channel5 ~ $ rvm info
system:
system:
uname: "Darwin channel5.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
@rsl
rsl / xml.rb
Created January 21, 2011 22:21
ruby-1.8.7-p302 :001 > xml = Builder::XmlMarkup.new
=> <inspect/>
ruby-1.8.7-p302 :002 > xml.send :foo, "bar"
=> "<inspect/><send:foo>bar</send:foo>"
<html>
<head>
<title>FUBAR</title>
</head>
<body>
<p>This is not how we indent, is it?</p>
@rsl
rsl / foo.rb
Created October 20, 2010 17:09
puts File.exists?(File.join(File.dirname(__FILE__), '../init.rb')) # Returns true
require File.join(File.dirname(__FILE__), '../init.rb') # Raises MissingSourceFile
module DumbQuoter
def self.included(base)
base.class_eval do
before_validation :dumb_down_strings
end
base.extend ClassMethods
end
def dumb_down_strings
self.class.string_attribute_names.each do |name|
class ApplicationController
# Yadda
private
def static_pages(*names)
names.each do |name|
define_method name do
render
end
end