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 balancer.java
EventLoopGroup group = new NioEventLoopGroup();
try {
for(UdpLoadBalancerConfig config : configList) {
System.out.println("Started load balancer on port: " + config.port + " and with servers: " + java.util.Arrays.toString(config.servers));
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new UdpLoadBalancerHandler(config.servers, debug));
b.bind(config.port).sync().channel().closeFuture().await();
View error.ex
ႋ窝ᬀ退Request: POST /api/v2/graphql
** (exit) an exception was raised:
** (KeyError) key :parent_name not found
(ecto) lib/ecto/repo/queryable.ex:249: anonymous fn/2 in Ecto.Repo.Queryable.process/4
(stdlib) maps.erl:257: :maps.fold_1/3
(ecto) lib/ecto/repo/queryable.ex:249: Ecto.Repo.Queryable.process/4
(ecto) lib/ecto/repo/queryable.ex:219: anonymous fn/3 in Ecto.Repo.Queryable.postprocessor/4
(elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/ecto/repo/queryable.ex:153: Ecto.Repo.Queryable.execute/4
(ecto) lib/ecto/repo/queryable.ex:18: Ecto.Repo.Queryable.all/3
View channel.ex
def join("room:" <> room_id, _params, socket) do
#this prints
IO.inspect(room_id)
case RoomCtx.find(room_id) do
nil ->
#does not print
IO.inspect("not found")
Logger.debug("[channel:room] attempted to join nonexistent room #{room_id}")
{:error, :not_found}
View gist:7c7b3b3e71e4571d0e1d81d904daa7ff
defp do_send_file(conn, file, opts \\ []) do
path = Path.join(filestorage_path(), file.file_path_hash)
Logger.debug "Streaming file #{path}"
if File.exists?(path) do
conn = case Keyword.has_key?(opts, :attachment) do
true -> put_resp_header(conn, "content-disposition", "attachment; filename=\"#{file.original_file_name}\"")
false -> put_resp_header(conn, "content-disposition", "filename=\"#{file.original_file_name}\"")
end
put_resp_header(conn, "content-type", file.content_type)
|> send_file(200, path)
View reset-test.bat
SET MIX_ENV=fixtures
mix ecto.drop
mix ecto.create
psql -U postgres -c "CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public" sow_test
mix ecto.migrate
mix sow.db.fixtures
SET MIX_ENV=
View hex.ex
script/ci/build_release.sh
* creating /home/ubuntu/.mix/archives/hex-0.16.0.ez
* creating /home/ubuntu/.mix/rebar
* creating /home/ubuntu/.mix/rebar3
Running dependency resolution...
** (Version.InvalidRequirementError) 1.6.3 or 1.6.5 or 1.7.1
(hex) lib/hex/version.ex:89: Hex.Version.parse_requirement!/2
(hex) lib/hex/version.ex:23: anonymous fn/3 in Hex.Version.match?/3
(hex) lib/hex/version.ex:98: Hex.Version.cache/2
(elixir) lib/enum.ex:738: anonymous fn/3 in Enum.filter/2
View plug.ex
conn
|> put_status(401)
|> json(%{ "error" => "Token invalid", "invalid" => true })
halt(conn)
View errors.erl
[error] 05:59:13.770 Error in process #PID<0.22274.1> on node :"core@10.0.2.143" with exit value:
{:function_clause,
[{:cowboy_protocol, :parse_method,
["",
{:state, #Port<0.52289>, :ranch_tcp, [:cowboy_router, :cowboy_handler],
false,
[listener: Core.Endpoint.HTTP,
dispatch: [{:_, [],
[{["ws", "v1", "client", "websocket"], [],
Phoenix.Endpoint.CowboyWebSocket,
@olivermt
olivermt / query.sql
Created Mar 7, 2017
[42P01] ERROR: invalid reference to FROM-clause entry for table "locations" Hint: Perhaps you meant to reference the table alias "location".
View query.sql
select
operations.legal_name as legal_name,
operations.operation_name as organization_name,
operations.general_description as general_description,
operations.is_exempt as is_exempt,
operations.does_export,
operations.phone,
operations.url,
operations.year_started,
operations.employees,
View bug.ex
#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
You can’t perform that action at this time.