Skip to content

Instantly share code, notes, and snippets.

@kenji4569
kenji4569 / ulid_converter.sql
Last active May 7, 2024 21:46
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//
# # GTFS Viewer
# ## Refs
# - https://gtfs.org/ja/
# - https://www.gtfs.jp/
# - https://nttdocomo-developers.jp/entry/20231218_1
# ## Setup
# $ pip install streamlit streamlit-folium folium pydeck pandas requests geopy gtfs-realtime-bindings
# $ streamlit run gtfs-viewer-app.py
# # Dynamic Vehicle Routing
# ## Refs
# - https://github.com/lb-robotics/python-vehicle-routing
# - https://zenn.dev/ohtaman/articles/streamlit_start_stop
# ## Setup
# $ pip install streamlit numpy scipy pandas altair readerwriterlock
# $ pip install wandb # Optional. Please do "wandb login" when you use it.
# $ streamlit run dynamic-vehicle-routing-streamlit-app.py
"""
streamlit-folium-example-app
Run the following commands to launch the app:
$ pip install streamlit streamlit-folium
$ streamlit run streamlit-folium-example-app.py
"""
import time
import express from 'express'
import cluster from 'cluster'
import { cpus } from 'os'
import process from 'process'
const workers = Math.min(Number(process.argv[2]) || 1, cpus().length)
const blockTime = Number(process.argv[3])
const app = express()
const port = 4000
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.