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
event = %Ical.Event{} | |
lines = String.split(text, line_break_regex) | |
Enum.reduce(lines, fn(line, event) -> | |
updates = Regex.named_captures(line_regex, line) | |
event = update_event(event, updates) | |
end) | |
IO.puts event |
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
a = 5 | |
Enum.each [1,2,3], fn x -> a = x * a end | |
IO.puts a # returns 5, while I expect 15, the last iterated value |
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 Mix.Tasks.Phoenix.Gen.Resource do | |
use Mix.Task | |
alias Phoenix.Naming | |
@shortdoc "Generates resource files" | |
@moduledoc """ | |
Generates a Phoenix resource. | |
mix phoenix.gen.resource User users name:string age:integer |
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 Mix.Tasks.Phoenix.Gen.Controller do | |
use Mix.Task | |
import Mix.Generator | |
@shortdoc "Generates a new controller" | |
@moduledoc """ | |
Generates a new controller. |
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 Mix.Tasks.Phoenix.Gen.Controller do | |
use Mix.Task | |
import Mix.Generator | |
@shortdoc "Generates a new controller" | |
@moduledoc """ | |
Generates a new controller. |
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 MyApp.Repo.Migrations.CreateTalks do | |
use Ecto.Migration | |
def up do | |
"CREATE TABLE talks ( | |
id serial primary key, | |
title varchar(255), | |
timestamp integer) " | |
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
# Currently we have these two function signatures for handling `IO.inspect "string"` | |
# https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/io.ex#L191-L205 | |
def inspect(item, opts \\ []) do | |
inspect group_leader(), item, opts | |
end | |
def inspect(device, item, opts) when is_list(opts) do | |
opts = struct(Inspect.Opts, opts) | |
iodata = Inspect.Algebra.format(Inspect.Algebra.to_doc(item, opts), opts.width) | |
puts device, iodata |
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
<%= Enum.map_reduce @messages, initial_value, fn current, prev -> %> | |
<li> | |
<% if current.type != prev.type do %> | |
<span class="msg-type"><%= current.type %></span> | |
<% end %> | |
<br/><%= current.msg %> | |
</li> | |
<% end |> elem(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
<%= for [prev,next] <- Enum.chunk(@messages, 2, 1) do %> | |
<li> | |
<%= if next.type != current.type do %> | |
<span class="msg-type"><%= current.type %></span> | |
<% end %> | |
<br/><%= current.msg %> | |
</li> | |
<% 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
<?xml version="1.0" encoding="UTF-8"?> | |
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="urn:mpeg:dash:schema:mpd:2011" | |
xmlns:xlink="http://www.w3.org/1999/xlink" | |
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" | |
profiles="urn:mpeg:dash:profile:isoff-live:2011" | |
type="static" | |
mediaPresentationDuration="PT9M56.458S" | |
minBufferTime="PT1.5S"> | |
<ProgramInformation> |