Skip to content

Instantly share code, notes, and snippets.

View eriklott's full-sized avatar

Erik Lott eriklott

  • Toronto, Canada
View GitHub Profile
@eriklott
eriklott / Client.elm
Last active February 19, 2019 10:12
Elm Backend Client
module YourAPIClient exposing (Config, otherFunctions)
import Http
import Json.Decode as Decode
import Json.Encode as Encode
-- Config
@eriklott
eriklott / touch.Elm
Last active November 19, 2019 18:56
module Touch exposing (..)
{-| A useful set of utilities for decoding browser touch events
# Types
@docs Position
# Decoders
@docs position, target, identifier, touches, touch, targetTouches, targetTouch,
changedTouches, changedTouch, touchList
@eriklott
eriklott / ulid_converter.sql
Created February 26, 2022 08:56 — forked from kenji4569/ulid_converter.sql
ULID (26 characters in Crockford's base32) conversion for MySQL function
# Define ULID_DECODE and ULID_ENCODE which convert a ulid string to a binary and vice versa.
delimiter //
DROP FUNCTION IF EXISTS ULID_DECODE//
CREATE FUNCTION ULID_DECODE (s CHAR(26)) RETURNS BINARY(16) DETERMINISTIC
BEGIN
DECLARE s_base32 CHAR(26);
SET s_base32 = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(s), 'J', 'I'), 'K', 'J'), 'M', 'K'), 'N', 'L'), 'P', 'M'), 'Q', 'N'), 'R', 'O'), 'S', 'P'), 'T', 'Q'), 'V', 'R'), 'W', 'S'), 'X', 'T'), 'Y', 'U'), 'Z', 'V');
RETURN UNHEX(CONCAT(LPAD(CONV(SUBSTRING(s_base32, 1, 2), 32, 16), 2, '0'), LPAD(CONV(SUBSTRING(s_base32, 3, 12), 32, 16), 15, '0'), LPAD(CONV(SUBSTRING(s_base32, 15, 12), 32, 16), 15, '0')));
END//