Skip to content

Instantly share code, notes, and snippets.

View klapuch's full-sized avatar
😊
Exploring world through OOP

Dominik Klapuch klapuch

😊
Exploring world through OOP
  • ČSFD
  • Czech Republic
View GitHub Profile
@klapuch
klapuch / solution.php
Created May 5, 2021 08:28
solution.php
<?php declare(strict_types=1);
$sections = json_decode(
<<<'JSON'
[
{
"title": "Getting started",
"reset_lesson_position": false,
"lessons": [
{"name": "Welcome"},
@klapuch
klapuch / array_reverse.sql
Created December 3, 2019 12:22
array_reverse function for postgres
CREATE FUNCTION array_reverse(anyarray) RETURNS anyarray RETURNS NULL ON NULL INPUT AS
$BODY$
SELECT array_agg(result.value ORDER BY ordinality DESC) FROM unnest($1) WITH ORDINALITY AS result(value);
$BODY$
LANGUAGE sql IMMUTABLE;
@klapuch
klapuch / redirect_uris.json
Last active May 16, 2019 11:10
redirect_uris
[
"https://cas.csfd.cz/mojeid-login/",
"https://cas.csfd.cz/mojeid-login/redirect/"
]
@klapuch
klapuch / check_enum_values.sql
Created April 7, 2018 10:46
Checks enum values
CREATE FUNCTION check_enum_value(in_enum text, in_value text, in_name text = NULL) RETURNS void AS $BODY$
DECLARE
items text[];
BEGIN
EXECUTE(format('SELECT enum_range(null::%I)::text', in_enum)) INTO items;
IF (NOT(items @> ARRAY[in_value])) THEN
RAISE EXCEPTION USING MESSAGE = format(
$$'%s' must be one of: %s - '%s' was given$$,
CASE WHEN in_name IS NOT NULL THEN in_name ELSE in_enum END,
array_to_string(
<?php
$iterations = 4000000;
$a = 'A';
$b = 'B';
$c = 'C';
$d = 'D';
$e = 10;
$f = 30;
@klapuch
klapuch / Dockerfile
Created January 14, 2018 12:48
php:7.2-rc-zts-alpine +pthreads +xdebug
FROM php:7.2-rc-zts-alpine
ARG APP_USER_USERNAME=app
RUN apk update && apk add --no-cache \
sudo bash \
g++ make autoconf \
libxml2-dev icu-dev curl-dev pcre-dev
RUN adduser -D -s /bin/bash $APP_USER_USERNAME \
@klapuch
klapuch / colors.sql
Last active December 2, 2017 21:12
Colors in SQL format
INSERT INTO colors (name, hex) VALUES
('AliceBlue', '#F0F8FF'),
('AntiqueWhite', '#FAEBD7'),
('Aqua', '#00FFFF'),
('Aquamarine', '#7FFFD4'),
('Azure', '#F0FFFF'),
('Beige', '#F5F5DC'),
('Bisque', '#FFE4C4'),
('Black', '#000000'),
('BlanchedAlmond', '#FFEBCD'),
CREATE FUNCTION restart_sequences() RETURNS VOID AS $$
DECLARE
public_schema CONSTANT INTEGER NOT NULL DEFAULT 2200;
statements CURSOR FOR SELECT 'ALTER SEQUENCE ' || relname || ' RESTART;' AS query
FROM pg_class
WHERE relkind = 'S'
AND relnamespace = public_schema;
BEGIN
FOR stmt IN statements LOOP
EXECUTE stmt.query;
SELECT string_agg(format('DROP DATABASE %I;', datname), '') FROM pg_database WHERE datistemplate = false AND datname LIKE 'test_%';
focus();
addEventListener('blur', function() {
if(document.activeElement === document.getElementById('rolex-corner-v3')) {
alert("I have clicked on iframe");
}
});