This file contains hidden or 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 BOM($scope) { | |
$scope.Materials = [ | |
{ "id": "MAT/TOMATOSOUP", | |
"name": "Tomato soup", | |
"unit": "L", | |
"Precision": 0.01 | |
}, { | |
"id": "MAT/ONION", | |
"name": "Onion", | |
"unit": "PCS", |
This file contains hidden or 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 Posts do | |
defrecord BlogPost, id: nil, title: nil, publishedOn: nil | |
defmodule FakeData do | |
def allPosts do | |
[ | |
BlogPost.new(id: 1,title: "Blog post one" ,publishedOn: "20130201"), | |
BlogPost.new(id: 2,title: "Blog post two" ,publishedOn: "20130202"), | |
BlogPost.new(id: 3,title: "Blog post three",publishedOn: "20130312"), |
This file contains hidden or 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 EasyPeasy | |
defrecord Post, | |
id: nil, | |
title: nil, | |
body: nil, | |
publishedOn: nil, | |
formatter: nil | |
def formatter(post) do | |
"#{post.id} - #{post.title}\n published on #{post.publishedOn}\n\n#{post.body}" |
This file contains hidden or 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
store=Posts.MemStore.start | |
store |> Posts.createPost("Another one bites the dust") | |
newPost = store |> Posts.Query.items |> Posts.OrderBy.recentlyCreated |> Enum.first | |
# now it works!!! | |
store |> Posts.publishPost(newPost.id) | |
recentPosts = store |> Posts.Query.items |> Posts.Filter.published |> Posts.OrderBy.recentlyPublished |
This file contains hidden or 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
REBAR := $(shell echo `pwd`/rebar) | |
ELIXIRC := bin/elixirc.bat --ignore-module-conflict $(ELIXIRC_OPTS) | |
ERLC := erlc -I lib/elixir/include | |
ERL := erl -I lib/elixir/include -noshell -pa lib/elixir/ebin | |
VERSION := $(strip $(shell cat VERSION)) | |
INSTALL_PATH := /usr/local | |
.PHONY: install compile erlang elixir dialyze test clean docs release_docs release_zip release_erl | |
.NOTPARALLEL: compile |
This file contains hidden or 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
#!/bin/sh | |
if [ $# -eq 0 ] || [ $1 = "--help" ] || [ $1 = "-h" ]; then | |
echo "Usage: `basename $0` [options] [.exs file] [data] | |
-v Prints version | |
-e \"command\" Evaluates the given command (*) | |
-r \"file\" Requires the given files/patterns (*) | |
-S \"script\" Finds and executes the given script (*) | |
-pr \"file\" Requires the given files/patterns in parallel (*) | |
-pa \"path\" Prepends the given path to Erlang code path (*) |
This file contains hidden or 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
defmacro for({ :in, _, [left, right] }, do: block) do | |
quote do | |
Enum.map unquote(right), fn unquote(left) -> unquote(block) end | |
end | |
end |
This file contains hidden or 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 Beer do | |
@moduledoc """ | |
# Beer Song | |
A program which produces the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall. | |
Note that Not all verses are identical. | |
The verse for 1 bottle is as follows: |
This file contains hidden or 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 Words do | |
@doc """ | |
Given a phrase can count the occurrences of each word in that phrase. | |
## Example | |
Words.count("olly olly in come free") | |
#=> #HashDict<[{"come",1},{"free",1},{"in",1},{"olly",2}]> | |
""" |
This file contains hidden or 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 Anagram do | |
@doc """ | |
# Anagram | |
Given a word and a list of possible anagrams, selects the correct one(s). | |
## Example | |
iex> Anagram.match "listen",%w(enlists google inlets banana) | |
["inlets"] |