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 add_attr(event_attr, person_attrs) do | |
new_attr_value = [%Person.AttributeValue{ | |
:timestamp => event_attr.timestamp, | |
:confidence => event_attr.confidence, | |
:value => event_attr.value | |
}] | |
curr_attr = Map.get(person_attrs, event_attr.field) | |
if (curr_attr === nil) do #the person doesn't have that attr | |
# add_new(person_attrs, ) | |
new_attr_source = %{ |
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
str = SSHEx.stream connection, 'ping -c 5 www.google.com' | |
Enum.reduce(str, {:ok, :running}, fn | |
_, {:error, reason} -> {:error, reason | |
{:stdout,row}, {:ok, :running} -> | |
IO.puts row | |
{:ok, :running} | |
{:stderr,row}, {:ok, :running} -> | |
IO.puts row | |
{:ok, :running} |
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 Test.Sup do | |
use Supervisor | |
def start_link(opts), do: Supervisor.start_link(__MODULE__, opts, name: __MODULE__) | |
def init([]) do | |
children = [ | |
# Supervisor.Spec.worker(Test.Server, [[]]), | |
Test.Server | |
] |
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
// See http://brunch.io for documentation. | |
exports.files = { | |
javascripts: { | |
entryPoints: { | |
'game.js': 'brunchtest.js' | |
} | |
}, | |
}; | |
exports.paths = { |
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
var look = function(lineid) { | |
var find; | |
find = (lines_json.find( function(value) { | |
return (value.lineid === lineid); | |
})); | |
if(find.speakerid !== "" || (typeof find.speakerid === "undefined")) { | |
find.retrievedSpeaker = line(entity(find.speakerid).entityname); | |
} | |
lines_out.push(find); | |
if(find.advance_lineid !== "" || (typeof find.advance_lineid === "undefined")) { |
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
-module(chat_server). | |
-export([start/1]). | |
handle_socket(Router, Client) -> | |
case gen_tcp:recv(Client, 0) of | |
{ok, "quit!} -> | |
gen_tcp:close(Client); | |
{ok, Data} -> | |
Router ! {msg, Client, Data} |
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 Datastore do | |
use Behaviour | |
@type key :: any | |
@type value :: any | |
defcallback start_link() :: Agent.t | |
defcallback get(Agent.t, key) :: value | |
defcallback put(Agent.t, key, value) :: :ok | |
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 HTMLCharacters do | |
def sanitize(phrase) do | |
chars = %{""" => "\"", "'" => "'", "&" => "&", "<" => "<", ">" => ">"} | |
cond do | |
String.match?(phrase, ~r/&\#?.+;/) -> | |
[code] = Regex.run(~r/&\#?.+;/, phrase) | |
Regex.replace(Regex.compile!(code), phrase, chars[code]) | |
true -> phrase |