Skip to content

Instantly share code, notes, and snippets.

View rjsamson's full-sized avatar

Robert J Samson rjsamson

View GitHub Profile
@rjsamson
rjsamson / test_substr.rb
Created November 3, 2012 14:02
Illustration of Rubinius Encoding Issues with Substring Ranges
puts "Substring Range Test"
str = "utf-8 character (\u20AC) in a utf-8 string"
str2 = "normal ASCII-ONLY string"
puts "str: #{str}"
puts "str2: #{str2}"
puts "str[1...-1]: #{str[1...-1]}" # => "tf-8 character (€) in a utf-8 string"
puts "str2[1...-1]: #{str2[1...-1]}" # => "ormal ASCII-ONLY Strin"
@rjsamson
rjsamson / test.rb
Created November 3, 2012 13:49
Illustration of Rubinius Encoding Issues with String Interpolation
str = "a utf-8 string (\u20AC) with utf-8 chars".force_encoding("utf-8")
str2 = "This string is #{str} but looks like ascii-only"
puts "str: #{str}"
puts "str.ascii_only?: #{str.ascii_only?}" # => false
puts "str2: #{str2}"
puts "str2 encoding: #{str2.encoding}" # => UTF-8
puts "str2.ascii_only?: #{str2.ascii_only?}" # => true
puts "str2.dup.ascii_only?: #{str2.dup.ascii_only?}"
puts "<< broken encoding:"
str3 = "an ascii string with "
@rjsamson
rjsamson / gist:3929092
Created October 22, 2012 00:37
rvm rbx-head install --trace (zsh)
rbx-head --trace
rvm 1.16.15 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
+__rvm_parse_args:639> [[ -n 4.3.11 ]]
+__rvm_parse_args:674> [[ -z reinstall ]]
+__rvm_parse_args:677> [[ error == reinstall || 0 -eq 1 || -n '' ]]
+__rvm_parse_args:16> [[ -n '' ]]
+__rvm_parse_args:682> : rvm_ruby_args:0::
+__rvm_parse_args:684> [[ -n '' ]]