Skip to content

Instantly share code, notes, and snippets.

View fabiolimace's full-sized avatar

Fabio Lima fabiolimace

View GitHub Profile
@fabiolimace
fabiolimace / UUIDv6.sql
Last active April 30, 2024 06:04
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023-2024 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@fabiolimace
fabiolimace / temperature.sh
Created April 28, 2024 23:22
Get current temperature
# https://askubuntu.com/questions/15832/how-do-i-get-the-cpu-temperature
paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) \
| column -s $'\t' -t \
| sed 's/\(.\)..$/.\1°C/'
@fabiolimace
fabiolimace / fn_tsid_milli.sql
Last active April 25, 2024 04:23
Function for generating Time Sortable ID with millisecond precision on PostgreSQL
/**
* 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
@fabiolimace
fabiolimace / ksuid.sql
Last active April 24, 2024 09:40
Functions for generating Segment's KSUIDs on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@fabiolimace
fabiolimace / record-system-output-audio.sh
Last active April 20, 2024 08:06
Record system output audio with FFMPEG on Ubuntu Linux
#!/usr/bin/bash
#
# Records the oudio from your browser and other applications.
#
# USAGE:
#
# record-system-output-audio.sh DURATION
#
# Where DURATION is [<HH>:]<MM>:<SS> or <SS>[s] (read ffmpeg-utils manual)
#
@fabiolimace
fabiolimace / snowflake-id.sql
Created April 18, 2024 20:13 — forked from beginor/snowflake-id.sql
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;
@fabiolimace
fabiolimace / block-site-add.sh
Last active April 11, 2024 01:38
Block sites in /etc/hosts
#!/usr/bin/bash
#
# Removes a block to /etc/hosts.
#
# USAGE:
#
# $ block-site-add.sh EXAMPLE.COM
# 0.0.0.0 example.com
# 0.0.0.0 www.example.com
#
http://www.oreilly.com/data/free/files/2014-data-science-salary-survey.pdf
http://www.oreilly.com/data/free/files/2015-data-science-salary-survey.pdf
http://www.oreilly.com/data/free/files/Data_Analytics_in_Sports.pdf
http://www.oreilly.com/data/free/files/advancing-procurement-analytics.pdf
http://www.oreilly.com/data/free/files/ai-and-medicine.pdf
http://www.oreilly.com/data/free/files/analyzing-data-in-the-internet-of-things.pdf
http://www.oreilly.com/data/free/files/analyzing-the-analyzers.pdf
http://www.oreilly.com/data/free/files/architecting-data-lakes.pdf
http://www.oreilly.com/data/free/files/being-a-data-skeptic.pdf
http://www.oreilly.com/data/free/files/big-data-analytics-emerging-architecture.pdf
@fabiolimace
fabiolimace / Entity.java
Last active April 3, 2024 20:36 — forked from rajivrnair/Entity.java
Custom Hibernate UUID Generator
// Before
@Id
@Column(name = "entity_id")
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
private String entityId;
// After
@Id
@Column(name = "entity_id")
@fabiolimace
fabiolimace / worktime-xterm.sh
Last active April 3, 2024 09:24
worktime: counts the time worked in a day
#!/bin/bash
#
# Excecute `worktine.sh` with `xterm`.
#
# XTerm Options:
#
# * -bg: fackground color
# * -fg: foreground color
# * -fa: freeType font-selection pattern
# * -fs: font size