Skip to content

Instantly share code, notes, and snippets.

@fljdin
fljdin / .nethackrc.ini
Last active July 31, 2023 21:54
Nethack Options
OPTIONS=role:Ra
OPTIONS=race:random,gender:random,align:random
OPTIONS=disclose:yi -a -v -g -c +o
OPTIONS=lit_corridor,hitpointbar
OPTIONS=!autopickup,!legacy
OPTIONS=guicolor,color
OPTIONS=windowtype:curses
OPTIONS=windowcolors:menu white/black message green/yellow status white/blue text #ffffff/#000000
@fljdin
fljdin / readme.md
Last active April 12, 2023 07:44
Outil de mise en synchro et synchro régulière basé sur le logshipping Oracle Database. La réplication impose que les bases sources et cibles aient le mode ARCHIVELOG actifs et que la FRA soit un système de fichier standard (EXT4, ACFS, etc.)

repctl

Outil de mise en synchro et synchro régulière basé sur le logshipping Oracle Database.

La réplication impose que les bases sources et cibles aient le mode ARCHIVELOG actifs et que la FRA soit un système de fichier standard (EXT4, ACFS, etc.)

Configuration

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "rockylinux/8"
config.vm.hostname = "rocky8"
config.vm.provider "libvirt" do |libvirt|
libvirt.memory = 512
libvirt.cpus = 2
libvirt.machine_virtual_size = 40
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.hostname = "centos7"
config.vm.provider "libvirt" do |libvirt|
libvirt.memory="1512"
libvirt.cpus=2
libvirt.disk_driver :cache => "none"
@fljdin
fljdin / borg-create.sh
Last active September 29, 2021 12:18
#/bin/bash
# encrypted USB stick by uuid
UUID=a20ec820-de7d-40ec-ac29-4595a10c38e7
PASS=xxxxxxxx
EXCLUDE=$HOME/.config/borg/exclude.list
# helpers
info() { notify-send "$*"; }
trap 'echo $( date ) Backup interrupted >&2; disk_unmount; exit 2' INT TERM
@fljdin
fljdin / init.sql
Last active June 8, 2021 10:54
Sample demo for daterange blogpost
DROP TABLE IF EXISTS staff;
CREATE TABLE staff (
id int PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
name varchar(50),
start date NOT NULL,
finish date,
period daterange GENERATED ALWAYS AS (daterange(start, finish, '[]')) STORED,
CHECK (start < finish OR finish IS NULL)
);
@fljdin
fljdin / is_public_holiday.sql
Last active August 6, 2020 07:39
ecrire-ses-tests-unitaires-en-sql
-- Type month_day
DROP TYPE IF EXISTS month_day CASCADE;
CREATE TYPE month_day AS (month int, day int);
-- Function easter_date(date)
CREATE OR REPLACE FUNCTION easter_date(year int)
RETURNS date LANGUAGE plpgsql
AS $$
DECLARE
g integer := year % 19;
SELECT i.indrelid::regclass AS "Table", i.indexrelid::regclass AS "Index",
pg_size_pretty(pg_relation_size(i.indexrelid)) AS "Taille de l'index"
FROM pg_index i JOIN (
SELECT indrelid, indclass, indkey, indexprs, indpred
FROM pg_index GROUP BY indrelid, indclass, indkey, indexprs, indpred
HAVING COUNT (*) > 1
) g ON i.indrelid = g.indrelid AND i.indclass = g.indclass AND i.indkey = g.indkey
AND COALESCE(i.indexprs::text,'x') = COALESCE(g.indexprs::text,'x')
AND COALESCE(i.indpred::text,'x') = COALESCE(g.indpred::text,'x')
ORDER BY pg_relation_size(i.indexrelid) DESC, i.indexrelid::regclass;
@fljdin
fljdin / testing.h
Last active January 27, 2020 16:23
#ifndef __testing_h__
#define __testing_h__
#include <stdio.h>
#define ANSI_GREEN "\033[0;32m"
#define ANSI_RED "\033[0;31m"
#define ANSI_RESET "\033[0m"
#define log_passed(M,...) fprintf(stderr,\
@fljdin
fljdin / blocking session.sql
Last active November 21, 2019 11:15
Detect blocked and blocking sessions in PostgreSQL 9.6+
SELECT pid, state,
CASE WHEN wait_event is not null
THEN concat(wait_event, ' (', wait_event_type, ')')
ELSE NULL::text END AS lock_intel,
pg_blocking_pids(pid) AS blocked_by,
substr(query, 1, 20)
FROM pg_stat_activity
WHERE state IS NOT NULL;