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
defmodule Success do | |
@type t :: %Success{value: any} | |
defstruct value: nil | |
end | |
defmodule Failure do | |
@type t :: %Failure{value: any, reason: String.t} | |
defstruct value: nil, reason: nil | |
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
defmodule EmailValidation do | |
def validate(email) do | |
email_validation_result = {:ok, email} | |
check_for_validity(email_validation_result) | |
|> check_if_email_taken | |
end | |
defp check_for_validity({:ok, email}) do | |
case check_against_regex(email) do |
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
Dir.glob("**/*.rb").each do |file| | |
`vim -c "set ts=4 sts=4 noet|retab!|set ts=2 sts=2 et|retab|wq" #{file}` | |
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
module Example | |
class Dog | |
attr_reader :stomach | |
def initialize(stomach) | |
@stomach = stomach | |
end | |
def hungry? | |
stomach.empty? |
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
"Joe Letizia's awesome blog 2.0".parameterize | |
# => "joe-letizia-s-awesome-blog-2-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
require 'active_record' | |
ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.colorize_logging = false | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:dbfile => ":memory:" | |
) |
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
module Products | |
# What if we want to differ the content between iOS and Web? | |
class IndexResource | |
def initialize(product_presenters, content_type) | |
@product_presenters = product_presenters | |
@content_type = content_type | |
end | |
def render(rendering_engine = RenderingEngine) | |
rendering_engine.render(partial_path, product_presenters: product_presenters) |
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
module Products | |
# What if we want to differ the content between iOS and Web? | |
class IndexResource | |
def initialize(product_presenters, content_type) | |
@product_presenters = product_presenters | |
@content_type = content_type | |
end | |
def render(rendering_engine = RenderingEngine) | |
rendering_engine.render(partial_path, product_presenters: product_presenters) |
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
public class SubordinateLoggingContext | |
{ | |
private static string CONNECTIONSTRING = "mongodb://connotate:connotate@linus.mongohq.com:10002/ConnotateLogs"; | |
MongoServer mongo; | |
MongoDatabase db; | |
MongoCollection collection; | |
public SubordinateLog log; | |
public SubordinateLoggingContext() |
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 'open-uri' | |
def adj_sum(multi,x,y) | |
sum = multi[x][y].to_i | |
if x > 0 | |
sum += multi[x-1][y].to_i | |
end | |
if x < 999 |
NewerOlder