Skip to content

Instantly share code, notes, and snippets.

@joeyates
joeyates / coverage.json
Last active January 20, 2024 17:54
JSON File Generated by joeyates/mork's GitHub Actions Pipeline for Use with shields.io
{"schemaVersion":1,"label":"Coverage","message":"92%","color":"brightgreen"}
@joeyates
joeyates / coverage.json
Last active November 1, 2023 17:12
JSON File Generated by solar_edge's GitHub Actions Pipeline for Use with shields.io
{"schemaVersion":1,"label":"Coverage","message":"94%","color":"brightgreen"}
@joeyates
joeyates / coverage.json
Last active November 16, 2023 18:55
JSON File Generated by imap-backup's GitHub Actions Pipeline for Use with shields.io
{"schemaVersion":1,"label":"Coverage","message":"99%","color":"brightgreen"}
@joeyates
joeyates / writable.md
Created October 7, 2018 21:04
Gist Writable URL
  • get the Repo's hash from the Gist URL
  • the writable URL is:
git@gist.github.com:<hash>
@joeyates
joeyates / chewy-date-range-query.rb
Created April 10, 2018 09:36
Use Chewy to extract a date range
bars =
FooIndex::Bar.all.
query(range: {start_date: {lt: "2018-03-31"}}).
query(range: {end_date: {gt: "2018-03-31"}}).
load.to_a
@joeyates
joeyates / rename_media.rb
Last active February 18, 2018 16:06
Classify Photos and Movies Downloaded from Android Phone into nested directories by Year, Month and Day
#!/usr/bin/env ruby
require "fileutils"
require "rake"
ROOT = File.expand_path(ARGV[0] || ".", Dir.pwd)
ANDROID_MATCH = /
\/ # The whole file name
(IMG|VID) # starts with an image or film indicator.
_ # An underscore is followed by
@joeyates
joeyates / certificate-expiry
Last active January 25, 2021 15:21
Get the expiry date for an online TLS/SSL certificate
#!/usr/bin/env bash
hostname=$1
online-certificate $hostname | \
openssl x509 -inform pem -noout -enddate
# Upload an item with an image field
export DATO_CMS_API=https://site-api.datocms.com
export DATO_CMS_API_TOKEN={{your read-write API token}}
# Get info about your Models (item-types):
curl \
-H "Authorization: Api-Key $DATO_CMS_API_TOKEN" \
-H "Accept: application/json" \
@joeyates
joeyates / merge_keyword_lists_and_maps.ex
Created July 9, 2017 11:05
Merge Elixir keyword lists and maps
defp combine(list1, list2) do
Keyword.merge(keyword_list(list1), keyword_list(list2), fn _k, _v1, v2 ->
v2
end)
end
def keyword_pair({key, value}) when is_atom(key) do
{key, value}
end
def keyword_pair({key, value}) do
@joeyates
joeyates / extend_jsx_encoder.ex
Last active July 10, 2017 21:29
JSON Serialization of Elixir 2-ples
defimpl JSX.Encoder, for: Tuple do
def json({__t1, __t2}) when is_list(i1) do
[:start_object, "__t1", __t1, "__t2", JSX.encode!(__t2), :end_object]
end
def json({__t1, __t2}) do
[:start_object, "__t1", __t2, "tuple_list", __t2, :end_object]
end
end