Skip to content

Instantly share code, notes, and snippets.

Avatar
🇨🇴
sisas parce

Simon Escobar Benitez sescobb27

🇨🇴
sisas parce
View GitHub Profile
View custom_upload_s3.ex
defmodule CustomUploadS3 do
@moduledoc """
Represents an AWS S3 Multipart Upload operation
## Examples
```
"path/to/big/file"
|> S3.Upload.stream_file
|> S3.upload("my-bucket", "path/on/s3")
|> CustomUploadS3.to_custom_upload_s3()
|> ExAws.request!() #=> :done
View download_csv.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<input type="file" id="input" onchange="handle_csv(this.files)" />
View port_runner.ex
defmodule PortRunner do
use GenServer, restart: :temporary
defmodule State do
defstruct [:command, :exit_status, :port, arguments: []]
end
@spec start_link(State.t() | map() | keyword()) :: GenServer.on_start()
def start_link(args) do
GenServer.start_link(__MODULE__, args)
@sescobb27
sescobb27 / elixir.diagnostics.markdown
Created Dec 6, 2019 — forked from binarytemple/elixir.diagnostics.markdown
Generate a list of all processes in the system which are neither linked nor monitored.
View elixir.diagnostics.markdown

Inspired by Stuff Goes Bad - Erlang in Anger

Is the global process count indicative of a leak? If so, you may need to investigate unlinked processes, or peek inside supervisors’ children lists to see what may be weird-looking.

defmodule Diags do 

  @doc """
View from_module_to_fn.ex
fun =
Gobgpapi.StartBgpRequest
|> to_string()
|> String.split(".")
|> List.last()
|> String.replace("Request", "")
|> Macro.underscore()
|> String.to_atom()
apply(MyModule, fun, args)
View monitors_db.ex
defmodule MonitorsDB do
@spec new_db() :: :ets.tid()
def new_db() do
random_string()
|> new_db()
end
@spec new_db(String.t()) :: :ets.tid()
def new_db(name) do
name
View state_handoff.ex
defmodule ExCluster.StateHandoff do
use GenServer
require Logger
def start_link(opts) do
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
end
def child_spec(opts \\ []) do
%{
View restart_server.ex
defmodule RestartServer do
use GenServer
def start_link(args) do
GenServer.start_link(__MODULE__, args, [name: __MODULE__])
end
def init(_) do
IO.puts("RESTARTING")
num = Enum.random(1..1_000_000)
@sescobb27
sescobb27 / my_app.ex
Created Feb 6, 2019 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
View my_app.ex
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
View topological_sort.ex
defmodule Topological do
def sort(library) do
g = :digraph.new
Enum.each(library, fn {l,deps} ->
:digraph.add_vertex(g,l) # noop if library already added
Enum.each(deps, fn d -> add_dependency(g,l,d) end)
end)
if t = :digraph_utils.topsort(g) do
print_path(t)
else
You can’t perform that action at this time.