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
angular.module('utils.watcher_hider', []) | |
.service 'WatcherHider', ['$log', ($log)-> | |
($scope)-> | |
@scope = $scope | |
# Don't try this at home kids... | |
listeners = [] | |
watches = [] | |
@$watch = (name_or_fn, watcher_fn)=> |
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 ElmDemo where | |
import Graphics.Element exposing (..) | |
import Graphics.Collage exposing (..) | |
import Color exposing (..) | |
import Time | |
import Text | |
import Window | |
-- MODEL |
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 ElmDemo where | |
import Graphics.Element exposing (..) | |
import Graphics.Collage exposing (..) | |
import Color exposing (..) | |
import Time | |
import Text | |
import Window | |
-- MODEL |
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 ElmDemoRefactored where | |
import Graphics.Element exposing (..) | |
import Graphics.Collage exposing (..) | |
import Color exposing (..) | |
import Time | |
import Text | |
import Window | |
-- MODEL |
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
# machine 1 | |
# start up with `iex --name [email protected] --cookie greeter` | |
# This isn't really necessary but it won't hurt anything | |
Node.connect :"[email protected]" | |
# All `Node.connect/1` calls can go to the same machine and every machine | |
# in the cluster will automatically be connected. | |
# machine 2 | |
# start up with `iex --name [email protected] --cookie greeter` |
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
# Lets create a bartender in the same way you would in a imperative language. | |
defmodule Bartender do | |
def serve(user, drink) do | |
if user.age >= 21 do | |
IO.puts "The bartender slides #{user.name} a #{drink}." | |
else | |
IO.puts "Sorry #{user.name}, you'll have to wait #{21 - user.age} more year(s)." | |
end | |
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
# The Elixir language is very extensible to allow for future additions or | |
# third party developers to take the language in directions that the original | |
# authors could not predict. | |
# | |
# Lets start with understanding what an Elixir macro is | |
iex> quote do | |
...> 1 + 1 | |
...> end | |
{:+, [context: Elixir, import: Kernel], [1, 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
# To show hot code uploading, we first need to build a simple phoenix project so we can see it happen in real time. | |
# Start by making a new phoenix project | |
$ mix phoenix.new hotcode | |
# Go into the directory | |
$ cd hotcode | |
# Add exrm dependency to mix.exs file | |
{:exrm, "~> 1.0.3"} |
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
# The golden trinity of Erlang is the secret sauce behind what makes | |
# Elixir a strong choice for any backend application and/or system. | |
# https://tkowal.wordpress.com/2015/10/20/failing-fast-and-slow-in-erlang-and-elixir/ | |
# The supervision and worker system, commonly referred to as OTP (Open | |
# Telecom Platform, which has nothing to do with telephony), is what | |
# gives Erlang/Elixir applications them a robust "self-healing" type | |
# property that makes them extremely fault tolerant. |
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
# Elixir has lazily evaluated enumerable objects that allow you | |
# to work with enumerable objects like lists either only as needed | |
# or infinitely. | |
# Start up iex to play around | |
$ iex | |
# Typical enumeration is done eagerly where the result is computed ASAP | |
iex> Enum.map(1..10, fn i -> i * 2 end) | |
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20] |
OlderNewer