Skip to content

Instantly share code, notes, and snippets.

View junjie-landing's full-sized avatar
🚀

Junjie Guan junjie-landing

🚀
View GitHub Profile
@beginor
beginor / snowflake-id.sql
Last active May 11, 2024 18:48
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@ajsharp
ajsharp / migrate-route53-dns
Last active July 3, 2023 18:35
This script makes it very easy to migrate an entire DNS zone from one AWS Route53 zone to another. This script expects you to have downloaded the old zone file via the AWS CLI to a json file called DOMAIN.zone.json. It uses the AWS CLI to perform the request, so make sure that your credentials are properly configured.
#!/usr/bin/env ruby
require 'json'
# This is the json output of the old zone, fetched using the AWS CLI.
zone = JSON.parse(File.read('DOMAIN.zone.json'))['ResourceRecordSets']
new_zone_id = 'NEW_ZONE_ID'
# We don't want to migrate the SOA and NS records from the old zone.