Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
fabiolimace / stdquote.js
Created March 27, 2025 10:22 — forked from thanpolas/stdquote.js
Normalize all UTF quotes in Javascript
/**
* Will normalize quotes in a given string. There are many variations of quotes
* in the unicode character set, this function attempts to convert any variation
* of quote to the standard Quotation Mark - U+0022 Standard Universal: "
*
* @param {string} str The string to normalize
* @return {string} Normalized string.
* @see https://unicode-table.com/en/sets/quotation-marks/
*/
helpers.stdQuote = (str) => {
@fabiolimace
fabiolimace / kvm_export_import.sh
Created September 16, 2024 09:11 — forked from KarthickSudhakar/kvm_export_import.sh
Bash script to import and export KVM virtual machine
#!/usr/bin/env bash
# ----------------------------------------------------------------------------------------------------
# AUTHOR : KARTHICK S
# PURPOSE : THIS SCRIPT WILL EXPORT/IMPORT THE CONFIG AND VM DISK.
#
# usage:
# export function will take care of exporting the necessary for all VM. Run as "<scriptname.sh> export"
# import function will take care of importing the necessary for all VM. Run as "<scriptname.sh> import"
#
@fabiolimace
fabiolimace / s3fs.service
Created May 17, 2024 09:33 — forked from klutchell/s3fs.service
systemd unit file for s3fs fuse auto-mount
Description=S3FS FUSE mount
Documentation=https://github.com/s3fs-fuse/s3fs-fuse
Wants=network-online.target
After=network-online.target
AssertPathIsDirectory=/mnt/s3fs
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/s3fs mybucket:/bucketdir /mnt/s3fs -o url=https://nyc3.digitaloceanspaces.com -o use_cache=/tmp -o allow_other -o use_path_request_style -o uid=1000 -o gid=1000
@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 / 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 / run_test_uuid.sh
Created February 4, 2024 00:55 — forked from ardentperf/run_test_uuid.sh
UUID benchmark driver script
#!/bin/bash
INIT_TABLE_ROWS=20000000
PGBENCH_TRANSACTIONS_PER_CLIENT=100000
PGBENCH_CLIENTS=10
run_test() {
echo "$(date +%y%m%d.%H%M) STARTING TEST $1"
pg_stop
@fabiolimace
fabiolimace / ThreadLocalWeakRefTest.java
Created December 14, 2023 23:09 — forked from chrisvest/ThreadLocalWeakRefTest.java
ThreadLocals and weak references
import org.junit.Test;
import java.lang.ref.WeakReference;
import static org.junit.Assert.assertNull;
public class ThreadLocalWeakRefTest {
/**
* Many Java web servers and containers go out of their way to find and null
* out ThreadLocals that an application might have created. Question is, is
@fabiolimace
fabiolimace / markdown-flavors.md
Created November 25, 2023 23:29 — forked from vimtaai/markdown-flavors.md
Comparison of features in various Markdown flavors

Comparison of syntax extensions in Markdown flavors

I created a crude comparison of the syntax of the various common Markdown extensions to have a better view on what are the most common extensions and what is the most widely accepted syntax for them. The list of Markdown flavors that I looked at was based on the list found on CommonMark's GitHub Wiki.

Flavor Superscript Subscript Deletion*
Strikethrough
Insertion* Highlight* Footnote Task list Table Abbr Deflist Smart typo TOC Math Math Block Mermaid
GFM
@fabiolimace
fabiolimace / pt_br.affix
Created November 14, 2023 19:20 — forked from CauanCabral/pt_br.affix
Dicionários Hunspell PT-BR preparados para busca textual (FTS) com Postgresql. Fonte: https://cgit.freedesktop.org/libreoffice/dictionaries/tree/pt_BR
This file has been truncated, but you can view the full file.
SET UTF-8
TRY áàãâéêíóõôúüçesianrtolcdugmphbyfvkwjqxz
# VERO - Verificador Ortográfico Livre - Versão 3.2
# Copyright (C) 2006 - 2013 por Raimundo Santos Moura
# <[email protected]>
# Brasil - outubro 2013
# Este é um dicionário para correção ortográfica da língua Portuguesa
# para o Hunspell.
# Este programa é livre e pode ser redistribuído e/ou modificado nos
@fabiolimace
fabiolimace / defrag_ext4_filesystem.md
Created October 28, 2022 11:13 — forked from rmi1974/defrag_ext4_filesystem.md
How to optimize / defrag ext4 filesystem #ext4 #commandlinefu

How to optimize / defrag ext4 filesystem

Make sure the target filesystem is sane

Open up the terminal and run:

sudo fsck.ext4 -y -f -v /dev/<disk/partition>