Skip to content

Instantly share code, notes, and snippets.

View langpavel's full-sized avatar

Pavel Lang langpavel

View GitHub Profile
@langpavel
langpavel / GraphQLTimestamp.js
Last active July 28, 2023 08:46
GraphQLTimestamp.js
import { Kind } from 'graphql/language';
import { GraphQLScalarType } from 'graphql';
function serializeDate(value) {
if (value instanceof Date) {
return value.getTime();
} else if (typeof value === 'number') {
return Math.trunc(value);
} else if (typeof value === 'string') {
return Date.parse(value);
@langpavel
langpavel / uaccent.sql
Last active July 12, 2021 10:18
PostgreSQL URL slug usable for indices
/**
* original unaccent function isn't usable for indices
*/
CREATE OR REPLACE FUNCTION uaccent(text) RETURNS text AS
$uaccent$
SELECT unaccent('unaccent',$1::text);
$uaccent$ LANGUAGE sql IMMUTABLE;
@langpavel
langpavel / template1.sql
Created February 11, 2016 06:03
PostgreSQL česká template1 šablona
/* PostgreSQL česká template1 */
UPDATE pg_database SET datistemplate = false WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 template=template0 encoding='UTF-8' LC_COLLATE='cs_CZ.UTF-8' LC_CTYPE='cs_CZ.UTF-8';
COMMENT ON DATABASE template1 IS 'Výchozí česká databáze';
UPDATE pg_database SET
datacl = (SELECT datacl FROM pg_database WHERE datname = 'template0'),
datistemplate = true
WHERE datname = 'template1';