Skip to content

Instantly share code, notes, and snippets.

View KamilLelonek's full-sized avatar
🏋️‍♂️
Do you even lift?

Kamil Lelonek KamilLelonek

🏋️‍♂️
Do you even lift?
View GitHub Profile
defmodule PipelinexTest do
use ExUnit.Case, async: true
use Pipelinex
require Pipelinex
@text "Some random STRING."
describe "~>" do
test "should behave the same as the regular pipe operator" do
defmodule PipelinexTest do
use ExUnit.Case, async: true
alias Pipelinex.{Video, Rating}
describe "serialize" do
@rating1 %Rating{author: "James Bond", comment: "Quite nice."}
@rating2 %Rating{author: "Sherlock Holmes", comment: "Pretty good."}
@ratings [@rating1, @rating2]
@video %Video{title: "Iron Man 3", ratings: @ratings}
defmodule Pipelinex.Rating do
@enforce_keys ~w(author comment)a
defstruct @enforce_keys
def new(params), do: struct!(__MODULE__, params)
def encode(%__MODULE__{author: author, comment: comment}) do
%{
"author" => author,
"comment" => comment
defmodule Download do
use Pipe
def start(api_key) do
api_key
~> download()
~> parse()
end
defp download(123), do: {:ok, "valid result"}

Keybase proof

I hereby claim:

  • I am kamillelonek on github.
  • I am squixy (https://keybase.io/squixy) on keybase.
  • I have a public key ASD3Lm-T43lABWqBPR_nCYc9Wm07aKZwNAMwm-fDXUab2wo

To claim this, I am signing this object:

defmodule Colors do
@colors ~w(R G B)
def calculate(string)
when byte_size(string) in [0, 1],
do: string
def calculate(string) do
string
|> String.graphemes()
defmodule GlobalId do
@moduledoc """
GlobalId module contains an implementation of a guaranteed globally unique id system.
It can be used for generating 64-bit unique IDs at high scale.
The IDs generated by this service are roughly time sortable.
"""
# NOTE: On production don't change it once set
epoch = {{1970, 1, 1}, {0, 0, 0}}

Foxbox N-Grams Code Challenge

This is a small programming problem to test your technical ability and coding style.

Instructions

Write a simple script to generate a set of n-grams from a string of text. N-grams are a contiguous sequence of n words from a string of text, and have many applications from full-text search indexes to machine learning.

You'll generate a set of every permutation of contiguous n-grams from a string of text, from 1-gram to n-grams where n is the number of words in the string

Example

defmodule Healthchex.Probes.Liveness do
# ...
def call(%Plug.Conn{request_path: path} = conn, %{path: path, resp: resp}) do
conn
|> send_resp(200, resp)
|> halt()
end
def call(conn, _opts), do: conn
defmodule Healthchex.Probes.Liveness do
import Plug.Conn
@default_path Application.get_env(:healthchex, :liveness_path, "/health/live")
@default_resp Application.get_env(:healthchex, :liveness_response, "OK")
def init(opts) do
%{
path: Keyword.get(opts, :path, @default_path),
resp: Keyword.get(opts, :resp, @default_resp)