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
# encoding: utf-8 | |
# code from: http://techtime.getharvest.com/blog/harvest-is-now-on-ruby-1-dot-9-3 | |
# and also: https://gist.github.com/1976864 | |
# Serialized columns in AR don't support UTF-8 well, so set the encoding on those | |
class ActiveRecord::Base | |
def unserialize_attribute_with_utf8(attr_name) | |
traverse = lambda do |object, block| | |
if object.kind_of?(Hash) |
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
# Encodes a string from encoding "from" to encoding "to" in | |
# a way that works for both ruby 1.8 and 1.9 | |
def convert_string_encoding(to, from, str) | |
if "1.9".respond_to?(:force_encoding) | |
str = str.dup if str.frozen? | |
str.encode(to, from, :undef => :replace) | |
else | |
require 'iconv' | |
Iconv.conv(to, from, str) | |
end |
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
class Cocktail | |
attr_accessor :name | |
def initialize(name) | |
@name = name | |
end | |
def liquor | |
case self.name | |
when "journalist": "gin" | |
when "sazerac": "whiskey" |
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
hello world |
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
#!/usr/bin/env ruby | |
require 'open3' | |
include Open3 | |
skip_erb_files = true | |
compiler_ruby = `which rbx`.strip | |
compiler_ruby = `which ruby`.strip if compiler_ruby.length == 0 |