Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
defimpl Poison.Encoder, for: Ecto.Association.NotLoaded do | |
def encode(_struct, _options) do | |
"null" | |
end | |
end |
export function promiseResolved(value : any) { | |
return new Promise((resolve, reject) => { | |
resolve(value) | |
}) | |
} |
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) |
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 |
Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
defmodule Something do | |
defstruct [ | |
material: nil | |
] | |
def get_material(%Something{material: material}) when material |> is_function do | |
material.() | |
end | |
def get_material(%Something{material: material}) do |
query = from workout in Workout, | |
where: workout.id == ^id, | |
left_join: group in assoc(workout, :workout_set_groups), | |
left_join: set in assoc(group, :workout_sets), | |
join: excercise in assoc(group, :excercise), | |
preload: [workout_set_groups: {group, excercise: excercise, workout_sets: set}] |
# don't attempt to sign in nil credentials at all | |
def create(conn, %{"session" => %{"login" => nil }}), do: nil | |
def create(conn, %{"session" => %{"password" => nil }}), do: nil | |
def create(conn, %{"session" => session_params}) do | |
member = Repo.one( | |
from w in Member, | |
where: w.email == ^session_params["login"] | |
or w.username == ^session_params["login"] | |
) |
def get_floor(instructions) do #snake_cased | |
# original | |
# list = String.codepoints(instructions) | |
# calculateFloor(list) | |
# here we can use the `|>` (read "pipe") operator like so | |
instructions | |
|> String.codepoints | |
|> calulate_floor |
package main | |
import ( | |
"math/big" | |
"os" | |
"strconv" | |
) | |
func Fib(n int) *big.Int { | |
switch n { |