Skip to content

Instantly share code, notes, and snippets.

View ellispritchard's full-sized avatar

Ellis Pritchard ellispritchard

  • @funding-circle
  • UK
  • 07:52 (UTC +01:00)
View GitHub Profile
@ellispritchard
ellispritchard / memb-graphql-api-elixir-1.7-upgrade.patch
Last active September 12, 2018 20:14
Patch troublesome dependencies:
diff --git a/lib/graphql/clients/prometheus_clients.ex b/lib/graphql/clients/prometheus_clients.ex
index 37e211f..f41f4ab 100644
--- a/lib/graphql/clients/prometheus_clients.ex
+++ b/lib/graphql/clients/prometheus_clients.ex
@@ -4,6 +4,7 @@ defmodule Graphql.Clients.Prometheus do
require Prometheus.Metric.Gauge
require Prometheus.Metric.Histogram
require Prometheus.Contrib.HTTP
+ require Prometheus.Error
@ellispritchard
ellispritchard / config_eg.exs
Last active May 28, 2020 19:32
Logger backend with filters
config :logger, level: :debug,
backends: [
{Logger.Backends.FilterConsole, :debug_log},
{Logger.Backends.FilterConsole, :error_log}
]
# log my_app at debug level
config :logger, :debug_log,
level: :debug,
format: "[$level] $message\n",
@ellispritchard
ellispritchard / docker.build.ex
Last active July 3, 2017 11:27
Mix task to build docker image, and supporting files
defmodule Mix.Tasks.Docker.Build do
use Mix.Task
@shortdoc "Prepare a docker release image"
@moduledoc """
Runs system-independent tasks, such as npm install, and then builds a tagged docker image.
## Configuration
@ellispritchard
ellispritchard / README.md
Last active August 29, 2015 14:01
sym-link target directories to /run for faster builds

sym-link target directories to /run for faster builds

Just run this in your parent project directory (or anywhere below), it finds pom.xml files and sym-links target directories in those directories.

Run as root:

sudo runtargets.py

Caveats

  • deletes existing target directory
@ellispritchard
ellispritchard / README.md
Last active May 12, 2016 12:15
MarkLogic XQuery timezone conversion support: functions to convert times between named zones using the IANA Time Zone Database. Converts compiled tz database files for use with the conversion function.

MarkLogic Timezone support

Usage

timezone.xqy can convert between times in named timezones, using special TimeZoneInfo files produced from UNIX zoneinfo files, e.g. it allows you to look up the equivalent time in New York, based on a time in London.

tz:adjust-dateTime-to-timezone(xs:dateTime('2013-05-09T10:34:00+01:00'),'America/New_York')

=> xs:dateTime('2013-05-09T05:34:00-04:00')
@ellispritchard
ellispritchard / gist:5466339
Last active December 16, 2015 16:49
MarkLogic XQuery UUID version 1 implementation: generates version 1 UUIDs, but using xdmp:host() instead of MAC address (as MAC address of node is not accessible to XQuery). Posted here for comment, inspiration etc.
xquery version '1.0-ml';
module namespace uuid = "http://mobi1.co.uk/lib/uuid/v1";
declare private variable $g_node as xs:unsignedLong := xdmp:host();
declare private variable $g_uuidVersionBit as xs:unsignedLong := 1;
declare private variable $g_uuidReservedBit as xs:unsignedLong := 128;
declare private variable $g_gregorianTimeOffset as xs:unsignedLong := xdmp:hex-to-integer('1B21DD213814000');
(:
Calculates a type 1 UUID.