Skip to content

Instantly share code, notes, and snippets.

@evolkmann
evolkmann / postgres_serial_to_uuid.sql
Created October 25, 2021 21:01
Change a serial ID column to a UUID column with predictable values
alter table example_table
alter column id drop default,
alter column id set data type uuid using uuid_generate_v5(uuid_ns_url(), id::text),
alter column id set default gen_random_uuid();
insert into currencies (code, "name") values
('AED', 'VAE-Dirham'),
('AFN', 'Afghani'),
('ALL', 'Albanischer Lek'),
('AMD', 'Armenischer Dram'),
('ANG', 'Antillen-Gulden'),
('AOA', 'Kwanza'),
('ARS', 'Argentinischer Peso'),
('AUD', 'Australischer Dollar'),
('AWG', 'Aruba-Florin'),
@evolkmann
evolkmann / countries-and-codes-german.sql
Created April 14, 2021 11:44
SQL with three-letter-codes and names according to https://laendercode.net/de/countries.html
insert into countries ("name", code) values
('Afghanistan', 'AFG'),
('Åland', 'ALA'),
('Albanien', 'ALB'),
('Algerien', 'DZA'),
('Amerikanisch-Samoa', 'ASM'),
('Andorra', 'AND'),
('Angola', 'AGO'),
('Anguilla', 'AIA'),
('Antarktis', 'ATA'),
@evolkmann
evolkmann / makes-and-models.sql
Last active April 14, 2021 16:10
Vehicle Makes and Models (SQL and Generator Script)
-- Generated on 2021-04-08
insert into "make" ("id", "name") values (1, 'Abarth');
insert into "model" ("brand", "name") values (1, '124 Spider');
insert into "model" ("brand", "name") values (1, '500');
insert into "model" ("brand", "name") values (1, '500C');
insert into "model" ("brand", "name") values (1, '595');
insert into "model" ("brand", "name") values (1, '595 Competizione');
insert into "model" ("brand", "name") values (1, '595 Turismo');
insert into "model" ("brand", "name") values (1, '595C');
@evolkmann
evolkmann / countries.enum.ts
Last active November 3, 2023 16:56
TypeScript Enum Country Codes ISO 3166
// Inspired by https://gist.github.com/kyranjamie/646386d5edc174e8b549111572897f81
// see https://gist.github.com/KingDarBoja/cf664cc395c4d95e645fd1f720c13746 for the three-letter-variant
export enum Country {
AF = 'Afghanistan',
AX = 'AlandIslands',
AL = 'Albania',
DZ = 'Algeria',
AS = 'American Samoa',
AD = 'Andorra',
AO = 'Angola',
@evolkmann
evolkmann / importing.module.ts
Created January 4, 2019 15:34
Create Nest.js modules with custom config
import { Module } from '@nestjs/common';
import { MyLibModule } from './my-lib.module';
@Module({
imports: [
MyLibModule.register({ name: 'Enzo' }),
]
})
export class ImportingModule {}
<html>
<head>
<style>
.no-decoration,
.no-decoration:hover {
color: inherit;
text-decoration: none;
}
const performARequest = () => {
const httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = () => {
if (httpRequest.readyState === 4 && httpRequest.status === 200) {
console.log('Request successful!');
}
};
httpRequest.open('GET', window.ENVIRONMENT.backendUrl + '/users/john');
httpRequest.send();
/**
* Represents the environment variables for PRODUCTION environment.
*/
(function (window) {
'use strict';
window['ENVIRONMENT'] = {
backendUrl: 'https://prod.my-backend.com'
};
<!DOCTYPE html>
<html lang="de">
<head>
<!-- Some more stuff here... -->
<!-- Our environment variables will be injected here -->
<!-- build:environment-vars --><!-- endbuild -->
</head>
<body>