This file contains hidden or 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
| /** | |
| * Returns a Time Sortable ID with millisecond precision. | |
| * | |
| * Time component: 42 bits (2^42 = ~69 years) | |
| * | |
| * Random component: 22 bits (2^22 = 4,194,304) | |
| * | |
| * The time component is the count of milliseconds since 2020-01-01T00:00:00Z. | |
| * | |
| * Tags: tsid ulid snowflake id-generator generator time sortable sort order id |
This file contains hidden or 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 uuid; | |
| import java.nio.ByteBuffer; | |
| import java.security.SecureRandom; | |
| import java.time.Instant; | |
| import java.util.UUID; | |
| public class OtherUUIDUtil { | |
| private static final int UUID_LENGTH = 16; |
This file contains hidden or 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
| version: '3' | |
| services: | |
| traefik: | |
| container_name: traefik | |
| image: traefik:v2.0 | |
| command: | |
| - "--api.insecure=true" | |
| - "--providers.docker=true" |
This file contains hidden or 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
| -- Copy/paste this file or execute with `psql -f thisfile.sql` | |
| CREATE ROLE owner CREATEDB LOGIN ENCRYPTED PASSWORD 'secret' CONNECTION LIMIT 3; | |
| ALTER ROLE owner SET statement_timeout = 20000; | |
| ALTER ROLE owner SET lock_timeout = 3000; | |
| ALTER ROLE owner SET idle_in_transaction_session_timeout = 3000; -- v9.6+ | |
| CREATE ROLE readwrite_users NOLOGIN; | |
| CREATE ROLE readonly_users NOLOGIN; |
This file contains hidden or 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 ROLE owner LOGIN ENCRYPTED PASSWORD 'secret' CONNECTION LIMIT 3; | |
| ALTER ROLE owner SET statement_timeout = 20000; | |
| ALTER ROLE owner SET lock_timeout = 3000; | |
| ALTER ROLE owner SET idle_in_transaction_session_timeout = 3000; -- v9.6+ | |
| CREATE ROLE readwrite_users NOLOGIN; | |
| CREATE ROLE readonly_users NOLOGIN; | |
| CREATE DATABASE exampledb WITH OWNER owner ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8'; |
This file contains hidden or 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
| # https://github.com/onnx/models/tree/master/vision/body_analysis/emotion_ferplus | |
| require "onnxruntime" | |
| require "mini_magick" | |
| img = MiniMagick::Image.open("ranger.jpg") | |
| img.crop "100x100+60+20", "-gravity", "center" | |
| img.resize "64x64^", "-gravity", "center", "-extent", "64x64" | |
| img.colorspace "Gray" | |
| img.write("resized.jpg") |
This file contains hidden or 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
| # https://hakibenita.com/fast-load-data-python-postgresql | |
| from typing import Iterator, Dict, Any, Optional | |
| from urllib.parse import urlencode | |
| import datetime | |
| #------------------------ Profile | |
| import time |
This file contains hidden or 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/python | |
| # $Id: $ | |
| # Converts Oracle, SQL-Server, and other DDL to Snowflake DDL | |
| def usage(): | |
| print """\ | |
| # Usage: sql2sf.py input-file [output-file] | |
| """ |
This file contains hidden or 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 "unaccent" | |
| CREATE OR REPLACE FUNCTION slugify("value" TEXT) | |
| RETURNS TEXT AS $$ | |
| -- removes accents (diacritic signs) from a given string -- | |
| WITH "unaccented" AS ( | |
| SELECT unaccent("value") AS "value" | |
| ), | |
| -- lowercases the string | |
| "lowercase" AS ( |
This file contains hidden or 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 OR REPLACE FUNCTION generate_sequential_uuid(p_interval_length int DEFAULT 60) | |
| RETURNS uuid | |
| LANGUAGE plpgsql | |
| AS $$ | |
| DECLARE | |
| v_i int; | |
| v_time bigint; | |
| v_bytes int[16] = '{}'; | |
| v_hex text[16] = '{}'; | |
| BEGIN |