This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# A single-file pure-python implementation of UUIDv7: (e.g. 01941230-851a-77fd-9b0b-8c8eac3b2d23) | |
# - makes sure UUIDv7s are always generated in alphabetic order (using system time + nanoseconds + extra monotonic random bits) | |
# - store millisecond, microsecond, nanosecond / variable precision timestamps all using same format | |
# - graceful degradation in precision, falls back to monotonic urandom bytes depending on user-provided timestamp precision | |
# - fully compatible with standard UUIDv7 spec (48 bit millisecond unix epoch time with rand_a & rand_b monotonic randomness) | |
# - allows you to generate a UUIDv7 with a given timestamp (of any precision), and parse the timestamp back out from any UUIDv7 | |
# - helps guarantee that UUIDv7s generated back-to-back in the same thread are always monotonically sortable | |
# - helps lower the risk of UUIDv7s colliding with other UUIDv7s generated in other threads / on other machines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Load data from https://coast.noaa.gov/htdata/CMSP/AISDataHandler/2024/index.html into Iceberg | |
-- | |
-- To prepare: create extension crunchy_spatial_analytics cascade; | |
-- Clean up previous creation | |
-- drop table if exists ais, loaded_ais_files; | |
-- Create the AIS Iceberg table | |
create table ais ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import math | |
import copy | |
import numpy as np | |
def shuffle_songs(songs): | |
"""Return a list of shuffled songs.""" | |
num_songs = len(songs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- create_temporal_past_table creates a new table with the same structure | |
-- as the current table. Adds triggers to copy all changed or deleted rows | |
-- from the current table to the past table. | |
CREATE PROCEDURE admin.create_temporal_past_table(curr_tbl regclass, past_tbl text) AS $fn$ | |
DECLARE | |
curr_tbl_qual text := simc.quote_regclass(curr_tbl); | |
past_tbl_schema text := (parse_ident(past_tbl))[1]; | |
past_tbl_name text := (parse_ident(past_tbl))[2]; | |
past_tbl_qual text := quote_ident(past_tbl_schema) || '.' || quote_ident(past_tbl_name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from base64 import urlsafe_b64encode | |
from blake3 import blake3 | |
import krock32 | |
from time import time | |
import secrets | |
import math | |
def generate_token(namespace: str) -> str: | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.6-slim | |
ARG UID | |
ARG GID | |
RUN groupadd -g "${GID}" app \ | |
&& useradd --create-home --no-log-init -u "${UID}" -g "${GID}" app | |
RUN apt-get update && \ | |
apt-get -y install python3-pip && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module github.com/brandur/prequire | |
go 1.19 | |
require github.com/stretchr/testify v1.8.1 | |
require ( | |
github.com/davecgh/go-spew v1.1.1 // indirect | |
github.com/pmezard/go-difflib v1.0.0 // indirect | |
gopkg.in/yaml.v3 v3.0.1 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
"strconv" | |
"strings" | |
) | |
type Student struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE EXTENSION IF NOT EXISTS pgcrypto; | |
CREATE OR REPLACE FUNCTION uuid_generate_ulid () | |
RETURNS uuid | |
AS $$ | |
DECLARE | |
timestamp bytea = E'\\000\\000\\000\\000\\000\\000'; | |
unix_time bigint; | |
BEGIN | |
unix_time = (EXTRACT(EPOCH FROM clock_timestamp()) * 1000)::bigint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clean the database | |
DROP TABLE IF EXISTS _orders CASCADE; | |
DROP TABLE IF EXISTS _users CASCADE; | |
DROP TABLE IF EXISTS orders CASCADE; | |
DROP TABLE IF EXISTS users CASCADE; | |
# Build the database (for hard deletion) | |
CREATE TABLE users ( | |
id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | |
name text NOT NULL |
NewerOlder