Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jordan0day on github.
  • I am jordan0day (https://keybase.io/jordan0day) on keybase.
  • I have a public key whose fingerprint is 10F4 E64B 6371 3FEA AA36 4B84 11E7 26F0 E1DD A726

To claim this, I am signing this object:

@jordan0day
jordan0day / cronitor.ex
Created April 22, 2016 18:26
Example cronitor elixir module
defmodule Cronitor do
# Make sure you've started the :inets and :ssl applications beforehand
@type code :: String.t
@type auth_key :: String.t
@type opts :: [auth_key: auth_key]
@type fail_opts :: [auth_key: auth_key | nil, msg: String.t | nil]
@spec run(code, opts) :: boolean
def run(code, opts \\ []) do
url = get_url(code, "run", nil, opts)
{[{total,1287042248},
{processes,1253359264},
{processes_used,1253356888},
{system,33682984},
{atom,553569},
{atom_used,539991},
{binary,1131208},
{code,16866752},
{ets,6810664}],
[{{sys_alloc,0},[{options,[{e,true},{m,libc}]}]},
{[{total,641545160},
{processes,608037848},
{processes_used,608035472},
{system,33507312},
{atom,553569},
{atom_used,539991},
{binary,954832},
{code,16866752},
{ets,6810664}],
[{{sys_alloc,0},[{options,[{e,true},{m,libc}]}]},
{[{total,137550528},
{processes,104008200},
{processes_used,104005680},
{system,33542328},
{atom,553569},
{atom_used,539991},
{binary,1001240},
{code,16866752},
{ets,6810664}],
[{{sys_alloc,0},[{options,[{e,true},{m,libc}]}]},
@jordan0day
jordan0day / largest_prime_factor.exs
Created August 17, 2015 16:40
Comments on twcrone/euler/problem3/largest_prime_factor.exs
ExUnit.start
defmodule LargestPrimeFactor do
use ExUnit.Case, async: true
@moduledoc """
Project Euler
Largest prime factor
@jordan0day
jordan0day / gist:fc7cf64dc473c2a6ed1b
Created June 18, 2015 19:47
Example of Ecto transactions not working as expected
# The %Name{} table has a unique index on firstname, lastname, so attempts to insert identical records will fail with a Postgrex error: "** (Postgrex.Error) ERROR (unique_violation): duplicate key value violates unique constraint "names_first_name_last_name_index"
test "try to insert a name a lot" do
first_name = "test"
last_name = "user"
name = %Name{first_name: first_name, last_name: last_name}
IO.puts "Here 1"