Skip to content

Instantly share code, notes, and snippets.

Oliver Severin Mulelid-Tynes olivermt

  • Microsoft / OMT Tech AS
  • Hamar, Norway
Block or report user

Report or block olivermt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:3fe2cde9ddb87abe51530c36c13eb7ab
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/
View changeset.ex
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")
View protocol.ex
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
View wat.ex
#== 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
View genserver.ex
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
View rounding.ex
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
View undefined.ex
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
View error.ex
==> 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
View parse.ex
room_name = case location do
"LANGUAGE=" <> rest ->
case rest do
#"en-US", "nb-NO" etc format
<<_x::bytes-size(2)>> <> "-" <<_x::bytes-size(2)>> <> ":" <> loc ->
loc
#"en", "zu" etc format
<<_x::bytes-size(2)>> <> ":" <> loc ->
loc
end
View prod.exs
config :example, Example.Endpoint,
http: [port: 4000],
url: [host: "example.com", port: 443],
cache_static_manifest: "priv/static/manifest.json",
force_ssl: [rewrite_on: [:x_forwarded_proto]],
server: true
You can’t perform that action at this time.