Skip to content

Instantly share code, notes, and snippets.

Avatar
🎻
practicing

Raitis Veinbahs siers

🎻
practicing
View GitHub Profile
@siers
siers / index.html
Last active Mar 6, 2022
mandelbrot set with smoothing
View index.html
<!-- original: https://jsfiddle.net/poetix/KtCnB/ -->
<!-- testing hypothesis for generating: https://twitter.com/matthen2/status/1498717789233758222 -->
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<canvas width="500px" height="500px" id="canvas"></canvas>
<input type="range" id="iterations" name="iterations" min="0" max="100" value="50" step="1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
@siers
siers / Supergraphs.hs
Last active Jun 8, 2021
Lattice joining graph connected components by their partition order
View Supergraphs.hs
module Main where
import Algebra.PartialOrd (PartialOrd(..))
import Data.Bifunctor (bimap)
import Data.Foldable (for_)
import Data.Function (on)
import Data.List.Extra (groupSortOn)
import Data.List (sortOn)
import Data.Set (Set)
import qualified Data.POSet as POSet
@siers
siers / LensSuffix.hs
Created Apr 24, 2021
Lens Template Haskell data fields with suffix
View LensSuffix.hs
import Control.Lens.Internal.FieldTH (makeFieldOptics, LensRules(..))
import Language.Haskell.TH.Syntax (mkName, nameBase)
import Control.Lens.TH (DefName(..), lensRules)
data Field = { a :: Int, b :: Int }
makeFieldOptics lensRules { _fieldToDef = (\_ _ -> (:[]) . TopName . mkName . (++ "L") . nameBase) } ''Field
-- hopefully someone find this useful
@siers
siers / yourkit.nix
Last active Sep 7, 2021
YourKit Java profiler Nix/NixOS package
View yourkit.nix
{ stdenv, fetchzip, zlib, openjdk8, openjdk11, version ? "v2019" }:
# https://www.yourkit.com/docs/java/help/running_profiler.jsp
let
versions = {
v2019 = {
date = "2019.1";
buildnr = "b133";
sha256 = "06p8y0mmyfrzjk5jz783gcfjsq6mk4rqddbqxarkkar7va5w5vk6";
View tar exclude test
#! /usr/bin/env bash
set -eu
pwd | grep -q '^/tmp'
cat > excl <<-EOF
a
b/*c*
./d
@siers
siers / bank-statement-parser.sh
Last active Feb 17, 2020
Swedbank bank statement parser
View bank-statement-parser.sh
#! /usr/bin/env zsh
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p python36Packages.csvkit
# map <f9> :%!./parse 2>/dev/null <CR>
summer() {
(echo "Saņēmējs/Maksātājs,Summa,Datums"; grep -v "Summa,Datums") | \
csvsql --tables input --query 'SELECT SUM("Summa")/100.0 FROM input'
View ncdu-cache
#!/usr/bin/env zsh
# create or use ncdu's output from cache, then open ncdu
set -eu
sanit-path() { echo "$(tr / : <<< "$1" | tr -cd '0-9a-z\-.:')"; }
cache="$HOME/data/cache/ncdu" # RUN mkdir yourself!
dir="$1"; shift
@siers
siers / ss-parse.rb
Created Jul 30, 2019
dumb, simple ss.com scraper for displaying notifications on diffs
View ss-parse.rb
#!/usr/bin/env ruby
script = <<-EOF
ccurl() {
curl -b cookie.txt -c cookie.txt "$@"
}
ccurl 'https://www.ss.com/lv/real-estate/flats/riga/agenskalns/filter/' -H 'authority: www.ss.com' -H 'cache-control: max-age=0' -H 'origin: https://www.ss.com' -H 'upgrade-insecure-requests: 1' -H 'content-type: application/x-www-form-urlencoded' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'referer: https://www.ss.com/lv/real-estate/flats/riga/agenskalns/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' &> /dev/null || exit
ccurl 'https://www.ss.com/lv/real-estate/flats/riga/agenskalns/filter/fDgSeF4belI=.html' -H 'authority: www.ss.com' -H 'cache-control: max-age=0' -H 'origin: https://www.ss.com' -H 'upgrade-insecure-requests: 1' -H 'conte
@siers
siers / redecorate.py
Created Jul 17, 2018
recursive chown uid/guid mapping for migrating ownership to LDAP
View redecorate.py
#!/usr/bin/env python
# recursive chown uid/guid mapping for migrating files' owners to
# the new LDAP ids by matching users' duplicate names in /etc/passwd and
# treating the upper ones (from `getent passwd` list) as the real ones
# Created around January, 2017
# raitis.veinbahs.lv
# This file may be freely used, modified, copied and repurposed. Public domain.
View etc-init.d-docker-compose
#!/usr/bin/env bash
### BEGIN INIT INFO
# Provides: dockercompose
# Required-Start: $docker
# Required-Stop: $docker
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Docker Services
### END INIT INFO