Skip to content

Instantly share code, notes, and snippets.

View olivermt's full-sized avatar

Oliver Severin Mulelid-Tynes olivermt

  • AMOI / OMT Tech AS
  • Hamar, Norway
  • 04:19 (UTC +02:00)
View GitHub Profile
#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
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}"
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/
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")
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
#== 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
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
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
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
==> 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