Skip to content

Instantly share code, notes, and snippets.

View MartinPavlik's full-sized avatar

Martin Pavlík MartinPavlik

View GitHub Profile
@MartinPavlik
MartinPavlik / table-sizes.md
Created November 21, 2021 10:04
Table sizes in posgres
SELECT nspname || '.' || relname AS "relation",
    pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
  FROM pg_class C
  LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
  WHERE nspname NOT IN ('pg_catalog', 'information_schema')
    AND C.relkind <> 'i'
    AND nspname !~ '^pg_toast'
  ORDER BY pg_total_relation_size(C.oid) DESC
 LIMIT 25;
// https://ramdajs.com/repl/#?%2F%2F%20https%3A%2F%2Fphilipnilsson.github.io%2FBadness10k%2Ffunctional-waterflow%2F%0A%0Aconst%20input%20%3D%20%5B2%2C%205%2C%201%2C%202%2C%203%2C%204%2C%207%2C%207%2C%206%5D%0A%2F%2F%20const%20input%20%3D%20%5B2%2C%201%2C%203%2C%204%2C%201%2C%202%2C%201%2C%203%2C%202%2C%201%2C%200%2C%202%2C%204%2C%203%2C%201%2C%205%2C%203%2C%201%2C%204%2C%201%2C%202%2C%201%2C%200%2C%205%2C%202%2C%201%2C%203%5D%0A%0A%0A%2F%2F%20When%20is%20a%20one%20block%20%60b%60%20of%20%60height%28b%29%60%20filled%20with%20water%3F%0A%0A%2F%2F%20there%20is%20some%20bL%20%28on%20the%20left%29%20that%20has%20height%28bL%29%20%3E%20height%28b%29%0A%2F%2F%20and%20there%20is%20some%20bH%20on%20the%20right%20that%20has%20height%28bH%29%20%3E%20height%28b%29%0A%0Aconst%20mapIndexed%20%3D%20addIndex%28map%29%0A%0A%2F%2F%20For%20each%20index%20in%20the%20input%2C%20compute%20highest%20wall%20from%20the%20left%20side%0Aconst%20leftWalls%20%3D%20source%20%3D%3E%20map%28%0A%20%20i%20%3D%3E%20pipe%28%0A%20%20%20%20take%2
@MartinPavlik
MartinPavlik / fizzbuzz.clj
Last active January 2, 2021 10:30
FizzBuzz katas
(ns clojure.examples.hello
(:gen-class))
;; how to execute a function? (fn argument1 argument2 ...)
;; this is how a function is defined
(defn isMod0 [i n]
(= 0 (mod i n)))
(defn fizzBuzz
@MartinPavlik
MartinPavlik / median.js
Created November 14, 2020 16:28
MongoDB median
db.getCollection('collection-name')
.find()
.sort( {"price":1} )
.skip(db.getCollection('collection-name').count() / 2 - 1)
.limit(1);
@MartinPavlik
MartinPavlik / keypress.js
Created March 14, 2020 08:43
omxplayer key code checker
const readline = require('readline');
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on('keypress', (str, key) => {
console.log(str)
console.log(key)
})
@MartinPavlik
MartinPavlik / useScrollDirection.js
Last active November 8, 2020 01:06
React useScrollDirection hook
import { useEffect, useState } from 'react';
export const SCROLL_UP = 'up';
export const SCROLL_DOWN = 'down';
export const useScrollDirection = (initialDirection = SCROLL_DOWN, thresholdPixels = 64) => {
const [scrollDir, setScrollDir] = useState(initialDirection);
useEffect(
() => {
@MartinPavlik
MartinPavlik / czechRepublicZipcodes.json
Last active March 11, 2019 09:24
List of all cities in Czech Republic and their zipcodes, regions, self governing regions and districts. Original data set was taken from this site: https://zvarik.cz/cs/databaze-psc
This file has been truncated, but you can view the full file.
[
{
"id": 1,
"zipcode": 36235,
"city": "Abertamy",
"district": "Karlovy Vary",
"selfGoverningRegion": "Karlovarský",
"region": "Jihočeský a Západočeský",
"country": "CZ"
},
@MartinPavlik
MartinPavlik / Main.elm
Created November 10, 2017 00:50 — forked from pdamoc/Main.elm
Req msg instead of Cmd msg
module Main exposing (..)
import Html exposing (..)
import Html.App as App
import Html.Events exposing (onClick)
import Req exposing (..)
main : Program Never
main =