π΅π°
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 EvercamMedia.PublicView do | |
| use EvercamMedia.Web, :view | |
| alias EvercamMedia.Util | |
| def render("index.json", %{cameras: cameras, total_pages: total_pages, count: count}) do | |
| %{ | |
| cameras: Enum.map(cameras, fn(camera) -> | |
| %{ | |
| id: camera.id, | |
| name: camera.name, |
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 EvercamMedia.PublicController do | |
| use EvercamMedia.Web, :controller | |
| alias EvercamMedia.PublicView | |
| import Ecto.Query | |
| require IEx | |
| @default_distance 1000 | |
| @default_offset 0 | |
| @default_limit 100 |
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
| {"ID":68814,"KIND":10,"POSTDATE":"01\/02\/2012","NUMBER":"SI-000539","REFERENCE":null,"MANAGERNAME":"","CURRENCYID":3,"CURRENCYSYMBOL":"\u20AC","FRGAMTVATINC":263.3,"FRGDUEAMT":0,"NEXTCREATEDATE":null} |
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
| { | |
| "cloud_recordings": [ | |
| { | |
| "frequency": 60, | |
| "storage_duration": 30, | |
| "status": "on", | |
| "schedule": { | |
| "Monday": [ | |
| "00:00-23:59" | |
| ], |
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 from_list(list) do | |
| {_, matrix} = do_from_list(list, [], %{}) | |
| matrix | |
| end | |
| defp do_from_list(list, indices, matrix) do | |
| Enum.reduce(list, {0, matrix}, fn | |
| sublist, {idx, matrix} when is_list(sublist) -> | |
| {sublist_idx, map} = do_from_list(sublist, [idx | indices], matrix) | |
| {idx + 1, map} |
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
| function sanitizeErrors(errs) { | |
| var msg = errs.message; | |
| var result = {}; | |
| for (var key in msg) { | |
| result[key] = key.replace('_', ' ') + ' ' + msg[key][0]; | |
| } | |
| return result; | |
| } |
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 EvercamMedia.Validation.Archive do | |
| import String, only: [equivalent?: 2] | |
| def validate_params(params) do | |
| with :ok <- validate(:title, params["title"]), | |
| :ok <- validate(:from_date, params["from_date"]), | |
| :ok <- validate(:to_date, params["to_date"]), | |
| :ok <- validate(:requested_by, params["requested_by"]), | |
| :ok <- validate_boolean(:embed_time, params["embed_time"]), | |
| :ok <- validate_boolean(:public, params["public"]), |
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
| # params = Enum.reject(params, fn {_key, value} -> value == "" end) |> Enum.into(%{}) |
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
| defp generate_exid(title) do | |
| clip_exid = | |
| title | |
| |> String.replace_trailing(" ", "") | |
| |> String.downcase | |
| |> String.slice(0..5) | |
| chars = (?a..?z |> Enum.into([]) |> Enum.map(&to_string([&1]))) ++ (1..9 |> Enum.to_list) | |
| random_string = Enum.map(0..3, fn(_) -> Enum.random(chars) end) |> Enum.join("") | |
| "#{clip_exid}-#{random_string}" |
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
| clip_exid = title.downcase.gsub(' ','') | |
| chars = [('a'..'z'), (0..9)].flat_map { |i| i.to_a } | |
| random_string = (0...3).map { chars[rand(chars.length)] }.join | |
| clip_exid = "#{clip_exid[0..5]}-#{random_string}" |