Map [1]
Operation | Time Complexity |
---|---|
Access | O(log n) |
Search | O(log n) |
Insertion | O(n) for <= 32 elements, O(log n) for > 32 elements [2] |
Deletion | O(n) for <= 32 elements, O(log n) for > 32 elements |
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"github.com/golang-jwt/jwt" | |
"log" | |
"net/http" | |
"time" | |
) |
## Sort Algorithms in Elixir | |
# Selection Sort | |
defmodule Selection do | |
def sort(list) when is_list(list) do | |
do_selection(list, []) | |
end | |
def do_selection([head|[]], acc) do |
defmodule RequestHelper do | |
@moduledoc """ | |
Reference from https://gist.github.com/avdi/7990684 | |
Stream download large file from url | |
""" | |
require Logger | |
@doc """ | |
Get stream data from url | |
mode could be `:binary` or `:line` |
def download_video(Episode[filename: filename] = episode) do | |
Stream.resource(fn -> begin_download(episode) end, | |
&continue_download/1, | |
&finish_download/1) | |
|> File.stream_to!(filename) | |
|> Stream.run | |
end | |
def begin_download(Episode[video_url: video_url, | |
account: Account[login: login, |
defmodule MyApp do | |
use Application | |
def start(_type, _args) do | |
import Supervisor.Spec, warn: false | |
children = [ | |
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [ | |
dispatch: dispatch | |
]) |
defmodule Counter do | |
use GenServer | |
def start_link(init_value \\ 0, opts \\ []) do | |
GenServer.start_link(__MODULE__, init_value, opts) | |
end | |
## client apis | |
def get(c) do | |
GenServer.call(c, {:get}) | |
end |
use opencv::{ | |
Result, | |
prelude::*, | |
objdetect, | |
highgui, | |
imgproc, | |
core, | |
types, | |
videoio, | |
}; |
image: node:12.13.0-alpine | |
before_script: | |
- npm i -g firebase-tools | |
test-functions: | |
stage: test | |
script: | |
- cd functions | |
- npm install |