Skip to content

Instantly share code, notes, and snippets.

View golgote's full-sized avatar

Bertrand Mansion golgote

  • Mamasam
  • Vincennes, France
View GitHub Profile
@MarkusH
MarkusH / serial-to-identity.sql
Last active June 4, 2024 06:14
A script that outputs the raw SQL to convert Django's serial columns to identity columns.
WITH tab AS (
SELECT
a.attrelid::regclass::text AS t,
a.attname AS c,
pg_get_serial_sequence(a.attrelid::regclass::text, a.attname) AS s,
nextval(pg_get_serial_sequence(a.attrelid::regclass::text, a.attname)) AS v
FROM pg_attribute a
JOIN pg_class c ON c.oid = a.attrelid
WHERE
a.attrelid::regclass::text LIKE '%'
@dmilith
dmilith / wezterm.lua
Last active September 16, 2023 21:38
Wezterm Nightly configuration dmilith
local wezterm = require 'wezterm';
local mux = wezterm.mux
local act = wezterm.action
local MY_EDITOR = "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
return {
default_cwd = "/Volumes/Projects",
@fabiolimace
fabiolimace / ksuid.sql
Last active July 10, 2024 19:00
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
@lkopocinski
lkopocinski / postal_codes_regex.json
Last active April 7, 2024 19:35
JSON file with postal codes regex patterns
[
{
"abbrev":"AF",
"name":"Afghanistan",
"postal":"[0-9]{4}"
},
{
"abbrev":"AL",
"name":"Albania",
"postal":"(120|122)[0-9]{2}"
@fabiolimace
fabiolimace / fn_tsid_milli.sql
Last active July 2, 2024 20:45
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
@rseon
rseon / Prestashop_exports.md
Last active June 4, 2024 14:58
Quelques scripts SQL d'export pour Prestashop

Prestashop exports

URL replacement

ps_configuration.name (PS_SHOP_DOMAIN, PS_SHOP_DOMAIN_SSL, PS_SSL_ENABLED)
ps_shop_url.domain
ps_shop_url.domain_ssl
@hmenke
hmenke / matheval.lua
Last active February 29, 2020 21:10
Simple mathematical expression parser and evaluator in Lua with LPEG
local lpeg = require"lpeg"
local C, P, R, S, V = lpeg.C, lpeg.P, lpeg.R, lpeg.S, lpeg.V
local white = S(" \t") ^ 0
local digit = R("09")
local dot = P(".")
local eE = S("eE")
local sign = S("+-")^-1
local mantissa = digit^1 * dot * digit^0 + dot * digit^1 + digit^1
@MarcelFox
MarcelFox / dns_cpmail.sh
Created April 8, 2018 15:21
dns_cpmail.sh | checks DMARC, DKIM & SPF of a primary domain of a user.
#!/bin/bash
#
# Name: dns_cpmail
# Version: 1.0
# By MarcelFox
#
# HOW TO WORK WITH?
# As 'root' and in a cPanel server run:
# bash dns_cpmail.sh
#
@MarcelFox
MarcelFox / 01_postfix_installer.md
Last active December 17, 2020 20:40 — forked from solusipse/01_postfix_installer.md
Postfix + Dovecot + Postgresql + Postfixadmin + Roundcube + Opendkim

Postfix Installer

Following script may be used for configuring complete and secure email server on fresh install of Debian 9. It will probably work on other distributions using apt-get. After minor changes you'll be able to use it on other Linux distros.

What it does?

02_postfix.sh:

  • Install Postfix and configure it with TLS support.
  • Install Dovecot and configure it's transport on Postfix.
  • Download, extract and correct permissions for Postfixadmin.
  • Download, extract and correct permissions for Roundcube.
@Noble-Mushtak
Noble-Mushtak / Calculator.lua
Last active April 8, 2024 16:56
Simple Calculator for Lua
function characterPresent(stringParam, character)
--[[
This function returns true if and only if character is in stringParam.
]]--
--Loop through stringParam:
for i=1, #stringParam do
--If the current character is character, return true.
if stringParam:sub(i, i) == character then return true end
end
--If we go through the whole string without returning true, we get to this point.