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
#This works in iex console: | |
:zip.create('c:/Users/oliver/AppData/Local/Temp/5f18ffe7-f925-47e7-8583-3f16a1acdf01/bundle.zip',['c:/Users/oliver/AppData/Local/Temp/5f18ffe7-f925-47e7-8583-3f16a1acdf01/2-cutedog.jpg']) | |
#This does not work from a Task: | |
zip_files = Enum.map(files, fn %{"id" => id, "name" => name} -> | |
Path.join(dest_dir, "#{id}-#{name}") | |
end) | |
|> Enum.map(&String.to_char_list/1) | |
zip_target = Path.join(dest_dir, "bundle.zip") |> String.to_char_list |
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
zip_files = Enum.map(files, fn %{"id" => id, "name" => name} -> | |
Path.join(dest_dir, "#{id}-#{name}") | |
end) | |
|> Enum.map(&String.to_char_list/1) | |
zip_target = Path.join(dest_dir, "bundle.zip") |> String.to_char_list | |
Logger.debug "Zipping files #{inspect zip_files} to #{inspect zip_target}" | |
zip_ret = :zip.create(zip_target, files, [:memory]) | |
Logger.debug "Zip return: #{inspect zip_ret}" |
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
product_answer_path GET /api/v1/org/:org_id/land/:land_id/application/:app_id/answers Sow.ProductAnswerController :show | |
product_answer_path PUT /api/v1/org/:org_id/land/:land_id/application/:app_id/answers Sow.ProductAnswerController :update | |
product_answer_path DELETE /api/v1/org/:org_id/land/:land_id/application/:app_id/answers Sow.ProductAnswerController :delete | |
product_answer_path POST /api/v1/org/:org_id/land/application/:app_id/answer_status Sow.ProductAnswerController :land_answer_status | |
product_answer_path GET /api/v1/org/:org_id/product/:prod_id/application/:app_id/answers Sow.ProductAnswerController :show | |
product_answer_path PUT /api/v1/org/:org_id/product/:prod_id/application/:app_id/answers Sow.ProductAnswerController :update | |
product_answer_path DELETE /api/v1/org/:org_id/product/:prod_id/application/:app_id/answers Sow.ProductAnswerController :delete | |
product_answer_path POST /api/v1/org/:org_id/product/application/:app_id/ |
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
def validate_version(cs = %{ | |
valid?: true, | |
changes: %{definition: new_def, version: client_version}, | |
data: %{definition: old_def, version: db_version}}) | |
when client_version > db_version do | |
case Map.equals(new_def, old_def) do | |
true -> | |
put_change(cs, :version, version+1) | |
false -> | |
add_error(cs, :definition, "definition_out_of_sync") |
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 Core.SyslogParser do | |
require Logger | |
alias Core.SyslogService | |
def start_link(ref, socket, transport, opts) do | |
pid = spawn_link(__MODULE__, :init, [ref, socket, transport, opts]) | |
{:ok, pid} | |
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
#== Compilation error on file lib/syslog/syslog_parser.ex == | |
#** (SyntaxError) lib/syslog/syslog_parser.ex:24: unexpected token: ")". "do" starting at line 22 is missing terminator "end" | |
# (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1 | |
#line 24 == 9 | |
def loop(socket, transport, buffer) do | |
case transport.recv(socket, 0, 5000) do | |
{:ok, data} -> | |
String.split((buffer <> data)), "\n", parts: 2) | |
|> case do |
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 Core.SyslogService do | |
use GenServer | |
require Logger | |
def start_link(ref, socket, transport, opts \\ []) do | |
Logger.debug "Trying to start_link" | |
:proc_lib.start_link(__MODULE__, :init, [ref, socket, transport, opts]) | |
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
Ecto.Date.utc | |
|> Map.update(:year, nil, fn y -> y+1 end) | |
|> case do | |
in_a_year = %{month: 2, day: 29} -> | |
in_a_year = Map.update(:day, nil, fn y -> y-1 end) | |
put_change(changeset, :renewal_date, in_a_year) | |
in_a_year -> | |
put_change(changeset, :renewal_date, in_a_year) | |
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
cond do | |
pin != "" and allow_guests == false -> | |
"Pin code: #{pin}.\n" | |
pin != "" and allow_guests == true and guest_pin == "" -> | |
"No pin required. Guests will wait in lobby until host connects.\n" | |
pin =! "" and allow_guests == true and guest_pin != "" -> | |
"Pin code: #{vmr.guest_pin}.\n" | |
true -> | |
"" | |
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
==> postgrex | |
Compiling 45 files (.ex) | |
warning: undefined behaviour function handle_deallocate/4 (for behaviour DBConnection) | |
lib/postgrex/protocol.ex:1 | |
warning: undefined behaviour function handle_declare/4 (for behaviour DBConnection) | |
lib/postgrex/protocol.ex:1 | |
warning: undefined behaviour function handle_first/4 (for behaviour DBConnection) | |
lib/postgrex/protocol.ex:1 |