defimpl Poison.Encoder, for: Usic.User do
@attributes ~W(id email inserted_at updated_at)a
def encode(song, _options) do
song
|> Map.take(@attributes)
|> Poison.encode!
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 Foo do | |
defp make_guard(:any), do: true | |
defp make_guard(token) do | |
quote do | |
head == token | |
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
defp table_action("create"), do: table_create("authors") | |
defp table_action("destroy"), do: table_drop("authors") | |
def authors(cd) do | |
#Connect to the database. | |
conn = RethinkDB.connect([host: "10.0.0.30", port: 28015]) | |
q = table_action(cd) |> run(conn) |
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
def authors(cd) do | |
#Connect to the database. | |
conn = RethinkDB.connect([host: "10.0.0.30", port: 28015]) | |
q = case cd do | |
"create" -> table_create("authors") | |
"destroy" -> table_drop("authors") | |
end | |
|> run(conn) |
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/bash | |
timestamp() { | |
date +%s%3N | |
} | |
watch_dir=$1 | |
echo "Watching $watch_dir ..." |
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
<kml:kml xmlns:kml="http://earth.google.com/kml/2.1"> | |
<kml:Document id="featureCollection"> | |
<Folder id="???"> | |
<Placemark id="fid-7adab59e_14f666dec01_-7f70"> | |
<ExtendedData> | |
<SchemaData> | |
<SimpleData name="an_int">1</SimpleData> | |
<SimpleData name="a_string">1</SimpleData> | |
<SimpleData name="a_float">1.1</SimpleData> | |
</SchemaData> |
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
def(at(<<var!(head) :: binary - size(2), rest :: binary>>, ptr, meta) when ptr >= 8 and ptr <= 9) do | |
new_posn = ptr + 2 | |
case({:meta, {:header_length, head}}) do | |
{:halt, _} = halt -> | |
halt | |
{:meta, {key, val}} -> | |
{rest, new_posn, Dict.put(meta, key, val), []} | |
result -> | |
{rest, new_posn, meta, [result]} | |
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
00:47:26.460 [error] GenServer #PID<0.276.0> terminating | |
** (Poison.EncodeError) unable to encode value: {nil, "user"} | |
(poison) lib/poison/encoder.ex:339: Poison.Encoder.Any.encode/2 | |
(poison) lib/poison/encoder.ex:213: anonymous fn/4 in Poison.Encoder.Map.encode/3 | |
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map."-encode/3-lists^foldl/2-0-"/3 | |
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map.encode/3 | |
(poison) lib/poison/encoder.ex:213: anonymous fn/4 in Poison.Encoder.Map.encode/3 | |
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map."-encode/3-lists^foldl/2-0-"/3 | |
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map.encode/3 | |
(poison) lib/poison/encoder.ex:213: anonymous fn/4 in Poison.Encoder.Map.encode/3 |
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 KVStore do | |
use GenServer | |
# This executes within the supervisor or whoever starts the KVStore | |
def start_link do | |
# First arg is the callback module (this module) | |
# The name arg registers the process globally as `KVStore`, essentially making it a singleton | |
GenServer.start_link(KVStore, [], name: KVStore) | |
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
foo | bar | |
---|---|---|
1 | 2 |