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 ClassWithAttr | |
def self.my_attr_accessor(attr_name) | |
define_method("#{attr_name}=") do |arg| | |
instance_variable_set("@#{attr_name}", arg) | |
end | |
define_method(attr_name) do | |
instance_variable_get("@#{attr_name}") | |
end | |
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
import java.util.*; | |
public class StringUtil { | |
public static String encode (String[] ss) { | |
StringBuilder sb = new StringBuilder(); | |
for (String s : ss) { | |
if (sb.length() > 0) | |
sb.append(','); | |
if (s != null) | |
sb.append(s.replaceAll("\\\\", "\\\\\\\\") |
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 | |
# Be sure to restart your server when you modify this file. | |
# Add new inflection rules using the following format | |
# (all these examples are active by default): | |
# ActiveSupport::Inflector.inflections do |inflect| | |
# inflect.plural /^(ox)$/i, '\1en' | |
# inflect.singular /^(ox)en/i, '\1' | |
# inflect.irregular 'person', 'people' | |
# inflect.uncountable %w( fish sheep ) |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |