π΅π°
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
| stock_list = [["Mint", "unavailable", "UK 4"], ["Nude", "unavailable", "UK 4"], | |
| ["Mint", "unavailable", "UK 6"], ["Nude", "unavailable", "UK 6"], | |
| ["Mint", "unavailable", "UK 8"], ["Nude", "low_stock", "UK 8"], | |
| ["Mint", "unavailable", "UK 10"], ["Nude", "unavailable", "UK 10"], | |
| ["Mint", "unavailable", "UK 12"], ["Nude", "low_stock", "UK 12"], | |
| ["Mint", "unavailable", "UK 14"], ["Nude", "low_stock", "UK 14"], | |
| ["Mint", "unavailable", "UK 16"], ["Nude", "low_stock", "UK 16"], | |
| ["Mint", "unavailable", "UK 18"], ["Nude", "available", "UK 18"]] | |
| 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
| params[:id].downcase! | |
| camera = get_cam(params[:id]) | |
| if params[:from].present? and params[:to].present? and params[:from].to_i > params[:to].to_i | |
| raise(BadRequestError, "From can't be higher than to") | |
| end | |
| from = Time.at(params[:from].to_i).to_s || 0 | |
| to = Time.at(params[:to].to_i).to_s | |
| to = Time.now.to_s if params[:to].blank? | |
| limit = params[:limit] || DEFAULT_LIMIT | |
| page = params[:page] || 0 |
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.CloudRecording do | |
| def validate_params(params) do | |
| with :ok <- validate(:frequency, params["frequency"]), | |
| :ok <- validate(:storage_duration, params["storage_duration"]), | |
| :ok <- validate(:status, params["status"]), | |
| :ok <- validate(:schedule, params["schedule"]), | |
| do: :ok | |
| end | |
| defp validate(key, value) when value in [nil, ""], do: invalid(key) |
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 Password do | |
| def generate(mac_address) do | |
| mac_address |> check |> do_generate | |
| end | |
| @regex_for_mac ~r/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/ | |
| defp check(mac) do | |
| if Regex.match?(@regex_for_mac, mac) do | |
| {:ok, mac} | |
| else |
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 validate_params(params) do | |
| with :ok <- validate?("frequency", params["frequency"]), | |
| :ok <- validate?("storage_duration", params["storage_duration"]), | |
| :ok <- validate?("status", params["status"]), | |
| do: :ok | |
| end | |
| def validate?("status", "on"), do: :ok | |
| def validate?("status", "off"), do: :ok | |
| def validate?("status", "on-scheduled"), do: :ok |
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 validate_params(params) do | |
| cond do | |
| !validate?(params["frequency"]) -> | |
| {:invalid, "The parameter 'frequency' isn't valid."} | |
| !validate?(params["storage_duration"]) -> | |
| {:invalid, "The parameter 'storage_duration' isn't valid."} | |
| !cr_status?(params["status"]) -> | |
| {:invalid, "The parameter 'status' isn't valid."} | |
| true -> | |
| {:ok} |
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
| Short but not appreciated enough | |
| defp validate_params(params) do | |
| cond do | |
| !validate?(params["frequency"]) -> | |
| {:invalid, "The parameter 'frequency' isn't valid."} | |
| !validate?(params["storage_duration"]) -> | |
| {:invalid, "The parameter 'storage_duration' isn't valid."} | |
| !cr_status?(params["status"]) -> | |
| {:invalid, "The parameter 'status' isn't valid."} |
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 Password do | |
| @regex_for_mac ~r/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/ | |
| def generate(mac_address) do | |
| case check_mac(mac_address) do | |
| {:invalid, message} -> | |
| message | |
| {:ok} -> | |
| password = |
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
| fnShowHide = (iCol, oTable) -> | |
| bVis = oTable.fnSettings().aoColumns[iCol].bVisible | |
| oTable.fnSetColumnVis iCol, if bVis then false else true |
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
| <!DOCTYPE html> | |
| <html > | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>WEATHER API</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="stylesheet" href="css/reset.css"> | |
| <link rel="stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans"> |