This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Poller do | |
use GenServer | |
def start_link do | |
# this starts the genserver (for supervision) | |
GenServer.start_link(__MODULE__, [], name: __MODULE__) | |
end | |
def init(_) do | |
set_timer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def defines_function?(module, name, arity) do | |
defines_function?(module, name, arity) | |
end | |
def defines_function?(module, {name, arity}) do | |
try do | |
module.__info__(:functions) | |
|> Enum.member?({name, arity}) | |
rescue | |
UndefinedFunctionError -> | |
# this rescues the call to module.__info__(:functions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function promiseResolved(value : any) { | |
return new Promise((resolve, reject) => { | |
resolve(value) | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defimpl Poison.Encoder, for: Ecto.Association.NotLoaded do | |
def encode(_struct, _options) do | |
"null" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface FormFieldParams { | |
form: any | |
field: string | |
} | |
const applySetterAndGetter = <T extends Function>(component: T, params: FormFieldParams): T => { | |
let options = { | |
get: () => { | |
return params.form.payload()[params.field] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@turfbytes-dgraph-01:~# dgraph --bindall | |
Dgraph version : v0.8.0 | |
Commit SHA-1 : 7c419b3f | |
Commit timestamp : 2017-07-21 14:13:34 +1000 | |
Branch : HEAD | |
2017/07/23 11:21:53 read p/000003.sst: invalid argument | |
github.com/dgraph-io/badger/y.Wrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/data/bin $ cat /data/var/db/pkgin/pkg_install-err.log | |
---Oct 03 15:50:22: installing perl-5.24.1... | |
---Oct 03 15:50:22: installing libpaper-1.1.24... | |
---Oct 03 15:50:23: installing ghostscript-fonts-8.11nb3... | |
---Oct 03 15:50:23: installing expat-2.2.0... | |
---Oct 03 15:50:23: installing ghostscript-gpl-9.06nb8... | |
/bin/chown: changing ownership of '/data/etc/fontconfig': Operation not permitted | |
/bin/chgrp: changing group of '/data/etc/fontconfig': Operation not permitted | |
---Oct 03 15:50:24: installing libxcb-1.12nb1... | |
pkg_add: package `libxcb-1.12nb1' was already installed as dependency, now marked as installed manually |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now = DateTime.utc_now() | |
entries = | |
boxes | |
|> Enum.map(fn | |
%_{} = box -> | |
Map.from_struct(box) | |
%{} = attrs -> | |
attrs | |
end) | |
|> Enum.reduce([], fn attrs, acc -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iex(11)> :timer.tc(fn -> Outcomes.run end) | |
Dealer showing 0 partitions = 417334 | |
Dealer showing 1 partitions = 560954 | |
Dealer showing 2 partitions = 658854 | |
Dealer showing 3 partitions = 679464 | |
Dealer showing 4 partitions = 680299 | |
Dealer showing 5 partitions = 680305 | |
Dealer showing 6 partitions = 680305 | |
Dealer showing 7 partitions = 680305 | |
Dealer showing 8 partitions = 680305 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyTokenRefresher do | |
use GenServer | |
def start_link(_) do | |
GenServer.start_link(__MODULE__, nil, name: __MODULE__) | |
end | |
def init(_) do | |
async_fetch_token() | |
{:ok, %{token: nil}} |