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 Trier do | |
require IEx | |
def thing do | |
x = 0 | |
try do | |
1 / x | |
rescue | |
e in ArithmeticError -> |
defmodule ImportExample do | |
# on this line Enum is not imported, yet. | |
import Enum #imports are not Module-wide. they only apply below the import. | |
def all_funcs do | |
map([1,2,3], fn n -> n + 1 end) #map is from Enum | |
end |
defp planting_operations_only do | |
from operation in Operation, | |
where: operation.operation_type == "planting", | |
preload: :variety | |
end | |
def crop_plan_preloads(query) do | |
from q in query, | |
preload: :crop, | |
preload: :fields, |
defmodule SimpleFib do | |
def fib(0), do: 0 | |
def fib(1), do: 1 | |
def fib(n) do | |
do_fib(n, 2, 1, 0) | |
end | |
defp do_fib(x, x, prev, prevprev) do | |
prev + prevprev | |
end |
package main | |
import ( | |
"math/big" | |
"os" | |
"strconv" | |
) | |
func Fib(n int) *big.Int { | |
switch n { |
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 |
# 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"] | |
) |
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}] |
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 |
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)