This file contains hidden or 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
module Foo | |
def self.included(klass) | |
klass.extend ClassMethods | |
end | |
module ClassMethods | |
def foo(name) | |
(class << self; self; end).send :attr_accessor, name | |
end | |
end | |
end |
This file contains hidden or 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
require 'csv' | |
module Exporter | |
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ] | |
DESTINATION_FOLDER = "tmp/" | |
def self.included(klass) | |
klass.extend ClassLevelMethods | |
end |
This file contains hidden or 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
def add(key, value, dictionary = Proc.new{}) | |
lambda do |x| | |
key == x ? value : dictionary.call(x) | |
end | |
end | |
d = add("a",5) | |
d = add("b",6, d) | |
p d.call("b") |
This file contains hidden or 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 *)*)&)^)^%*%&*%** | |
ÜglÈÊCÕnsªnt = "HAIUGLYCODEZ" | |
alias :send ∴; alias :get ∵ | |
%w|rubygems sinatra|.each{|_|require _} | |
%w|gem load|.each{|_| ∴ _, 'kitty'} | |
(℧=Kitty).∴ *%w(define_method print) do |*⇧| ⇧.∴:join end | |
∵ %r{\/} do content_type "nialp/txet".reverse and ℧.new.random_kitty end | |
# gem install kitty | |
# ruby kitty_server.rb & | |
# curl http://localhost:4567 |
This file contains hidden or 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
def create | |
@user = User.new(params[:user]) | |
pw_match! | |
if @user.save | |
flash[:notice] = "User created" | |
redirect_to admin_url | |
else | |
render :action => "new" | |
end | |
end |