Skip to content

Instantly share code, notes, and snippets.

View johnhamelink's full-sized avatar
🔨
Building

John Hamelink johnhamelink

🔨
Building
View GitHub Profile
def search_param_datetime(query: nil, attribute_key: nil, attribute_array: [])
fail 'Must have a valid query' if query.nil?
fail 'Must have a valid attribute key' if attribute_key.nil?
logger.debug "[Search param DateTime] Searching #{attribute_key} -> #{attribute_array.to_json}"
if attribute_array.nil? || attribute_array.empty?
logger.debug "[Search param DateTime] Backing out of filter - no values exist for #{attribute_key}"
return query
end
def project do
[app: :api,
version: "0.3.43",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.0",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
let results = expand_address(
address.as_ptr(),
options,
num_results as size_t*
);
defmodule Api.Discovery do
require Logger
def discover do
# Attempt to connect to any other outside nodes.
# This command makes use of the /opt/api/.hosts.erlang file
hosts_path = Path.expand("/opt/api/.hosts.erlang")
case File.exists?(hosts_path) do
true ->
<!DOCTYPE html>
<html>
<head>
<title>My Tangram Refill Style Map</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2/leaflet.css" />
<style>
#map {
height: 100%;
width: 100%;
position: absolute;
defmodule ExrmDebTest.ConfigTest do
use ExUnit.Case, async: false
import ExUnit.CaptureIO
test "Configuration is sanitized correctly" do
out = ExrmDeb.Utils.Config.sanitize_config(%{ name: "$!JIM-B+O.B,'" })
assert Map.fetch!(out, :sanitized_name)
assert Map.fetch!(out, :sanitized_name) == "jim-b+o.b"
end
defmodule ReleaseManager.Utils.Logger do
use GenServer
def start_link() do
GenServer.start_link(__MODULE__, %{verbosity: :normal}, name: __MODULE__)
end
def configure(verbosity) when is_atom(verbosity) do
GenServer.cast(__MODULE__, {:configure, verbosity})
end
defmodule ReleaseManager.Utils do
@moduledoc """
This module provides helper functions for the `mix release` and
`mix release.clean` tasks.
"""
import Mix.Shell, only: [cmd: 2]
alias ReleaseManager.Utils.Logger
# Relx constants
@relx_output_path "rel"
def project_dir do
[
Application.app_dir(:exrm_deb),
"..", "..", "..", "..",
] |> Path.join
end
class UpdatePlayerService
def initialize
@pn_service = PlayerPushNotification
end
def update(current_user: nil, player: nil, changes: nil)
fail '[UpdatePlayerService#update] Must supply current_user' if current_user.nil?
fail '[UpdatePlayerService#update] Must supply player' if player.nil?
fail '[UpdatePlayerService#update] Must supply changes' if changes.nil?
player.update_attributes(changes)