Skip to content

Instantly share code, notes, and snippets.

View dzfranklin's full-sized avatar

Daniel Franklin dzfranklin

  • Dundee, UK
  • 13:09 (UTC +01:00)
View GitHub Profile
defmodule Wrench.Hex.Api.Requester do
use GenServer
require Logger
@config Application.get_env(:wrench, __MODULE__)
@api_key @config[:api_key]
@ua "Wrench/#{Application.spec(:wrench, :vsn)} (contact #{Application.get_env(:wrench, :operator_contact)})"
@endpoint "https://hex.pm/api"
def start_link(opts) do
defp clear_record_id_error(changeset) do
errors =
changeset.errors
|> Enum.filter(fn
{:record_id, _} -> false
_ -> true
end)
if Enum.empty?(errors) do
%{changeset | errors: [], valid?: true}
@dzfranklin
dzfranklin / gist:abbd3028589de0abe8dc51b5757c4ea6
Created March 30, 2023 10:45
Output of cargo test -- --list
0 tests, 0 benchmarks
encoding_any_prop: test
encoding_prop: test
2 tests, 0 benchmarks
test::json_any_array: test
test::json_any_bool: test
test::json_any_map: test
test::json_any_null: test
test::json_any_number: test
Jun 05 01:44:40 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:44:40 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:44:40 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:45:40 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:45:40 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:45:40 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:46:40 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:46:41 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:46:41 geder gnome-shell[6176]: Removing a network device that was not added
Jun 05 01:47:41 geder gnome-shell[6176]: Removing a network device that was not added
@dzfranklin
dzfranklin / script.turf-sandbox
Created June 15, 2024 23:28
turf-sandbox snippet
// Paste into <https://turf-sandbox.netlify.app/>
function sampleLine(inputLine, distanceMeters) {
let inputLength = turf.length(inputLine, "m")
let samples = []
for (let i = 0; i < Math.floor(inputLength); i+=distanceMeters) {
let point = turf.along(inputLine, i, 'm')
samples.push(point["geometry"]["coordinates"])
}
samples.push(inputLine["geometry"]["coordinates"].at(-1))