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
# TODO |
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
-- Table in question: | |
CREATE TABLE product_tags ( | |
id integer NOT NULL, | |
product_id integer NOT NULL, | |
tag_id integer NOT NULL, | |
"position" integer | |
); | |
-- Renumber the position column based on row number in partition: | |
UPDATE product_tags pt |
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
# config/locales/en.yml | |
en: | |
exception: | |
show: | |
not_found: | |
title: "Not Found" | |
description: "The page you were looking for does not exists." | |
internal_server_error: | |
title: "Internal Server Error" |
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
require "coderay" | |
require "pdfkit" | |
require File.join(File.dirname(__FILE__), "styles/tomorrow_night") | |
module Meta | |
class Code | |
attr_reader :creator | |
def initialize(options = {}) | |
@creator = options[:creator] |
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
Afghanistan | |
Albania | |
Algeria | |
Andorra | |
Angola | |
Antigua & Deps | |
Argentina | |
Armenia | |
Australia | |
Austria |
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 ConstantGardener | |
def self.create(*booleans) | |
Class.new do | |
def initialize(bitmask) | |
@bitmask = bitmask | |
end | |
booleans.each_with_index do |b, i| | |
const_set b.to_s.upcase, 2**i |
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 Object | |
def metaclass | |
class << self; return self; end | |
end | |
end | |
class Foo | |
# 1. def within class definition | |
def self.set_a |
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 Object | |
def metaclass | |
class << self; self; end | |
end | |
end | |
# - Normal cases - | |
class Foo | |
@@bar = 0 |
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 User < ActiveRecord::Base | |
def email | |
# Make REST call, parse response, extract email address and return it. | |
# Probably not the most concise and expressive code. | |
end | |
end | |
# Is more or less equal to: | |
class RemoteUser < ActiveResource::Base |
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
# HTTP Basic Auth | |
class User < ActiveRecord::Base | |
has_remote :site => "http://example.com", :user => "foo", :password => "bar" do |remote| | |
#... | |
end | |
end | |
# API key | |
class User < ActiveRecord::Base | |
has_remote :site => "http://example.com?api_key=12x34x5" do |remote| |
NewerOlder