(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
module ArelHelpers | |
extend self | |
def self.included(base) | |
base.extend self | |
end | |
def asterisk(arel_table_or_model) | |
arel_table, columns = case arel_table_or_model | |
when Arel::Table |
defmodule Life do | |
def run(board) when is_binary(board) do | |
board |> parse_board |> run | |
end | |
def run(board) do | |
IO.write("\e[H\e[2J") | |
Life.print_board board | |
:timer.sleep 1000 | |
board = next_board(board) |
# rebuttal of http://www.try-alf.org/blog/2013-10-21-relations-as-first-class-citizen | |
require 'arel' | |
require 'sqlite3' | |
require 'pry' | |
def suppliers | |
@suppliers ||= Arel::Table.new(:suppliers) | |
end |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# encoding: utf-8 | |
class AlbumForm < BaseForm | |
has_many :songs, class_name: 'SongForm' | |
validates :songs, form_collection: true | |
end |
# UPD from 2018: | |
# This gist was written for pre-1.0 version of Elixir and won't work on post-1.0 versions. | |
# You probably consider using something else! | |
defmodule SecureRandom do | |
@moduledoc """ | |
Ruby-like SecureRandom module. | |
## Examples |
# 1. Add rack-rewrite to your Gemfile and run 'bundle install': | |
# gem 'rack-rewrite' | |
# | |
# 2. Create a file with the contents below in config/initializers/asset_server_middleware.rb | |
# | |
# 3. Rename 'YourApp' below | |
# | |
# 4. In config/environments/production.rb and config/environments/test.rb, set: | |
# config.serve_static_assets = true | |
# config.assets.compile = false |
defmodule Life do | |
def run(board) when is_binary(board) do | |
board |> parse_board |> run | |
end | |
def run(board) do | |
IO.write("\e[H\e[2J") | |
Life.print_board board | |
:timer.sleep 1000 | |
board = next_board(board) |