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 AsyncTest do | |
@contents ["foo", "bar", "foobar"] | |
@output "async_test" | |
def run do | |
File.rm_rf!(@output) | |
File.mkdir_p!(@output) | |
@contents | |
|> Enum.with_index | |
|> Enum.map(&write_content_async(&1)) |
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 User do | |
defstruct name: nil, gender: nil, roles: [:normal] | |
defmodule NameError do | |
defexception message: "Name is too short" | |
end | |
def add_name(%User{} = user, name) when is_binary(name) do | |
try do | |
validate!(name: name) |
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
ARGV << '--help' if ARGV.empty? | |
aliases = { | |
"g" => "generate", | |
"d" => "destroy", | |
"c" => "console", | |
"s" => "server", | |
"db" => "dbconsole", | |
"r" => "runner" | |
} |
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 'irb' | |
class Foobar | |
def foo | |
:foo | |
end | |
end | |
Foobar.class_eval do | |
def bar |
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
FROM ruby:2.2.3 | |
MAINTAINER [email protected] | |
# Install apt based dependencies required to run Rails as | |
# well as RubyGems. As the Ruby image itself is based on a | |
# Debian image, we use apt-get to install those. | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
nodejs |
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 'forwardable' | |
class CustomEnumerable | |
extend Forwardable | |
include Enumerable | |
def_delegators :@collection, :each, :map | |
# The above is the same of doing this: | |
# |
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 Demo do | |
def greet(name) do | |
IO.puts "Hello #{name} from Elixir" | |
end | |
def api_call do | |
{:ok, "foo"} | |
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
class A | |
def fred | |
puts "In Fred" | |
end | |
def create_method(name, &block) | |
self.class.send(:define_method, name, &block) | |
end | |
define_method(:wilma) { puts "Charge it!" } | |
end | |
class B < 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
function add(x) { | |
return function(y) { return x + y; }; | |
} | |
var addTo10 = add(10); | |
console.log(addTo10(5)); // 15 | |
console.log(addTo10(10)); // 20 |
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
NODE_ENV=production | |
APP_ACCESS_TOKEN=ed63f03d697993421e39848e66ede6d232c07cad | |
APP_SECRET=df5728ee-eb4b-47c0-831e-1f375eb51155 | |
APP_TOKEN_SEPARATOR=: | |
DOMAIN=localhost | |
PORT=5000 | |
############################ |