Skip to content

Instantly share code, notes, and snippets.

@bereal
bereal / inoagent.user.js
Last active May 2, 2021 06:09
Скрываем хрень про иностранного агента с сайта Медузы
// ==UserScript==
// @name iNoAgent
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove foreign agent bs
// @author sdolotom
// @match https://meduza.io/*
// @grant none
// ==/UserScript==
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Rhapsody where
import Data.Char (toLower, toUpper)
import Data.Data (Data, Typeable, showConstr, toConstr)
import Data.List (intercalate)
import Text.Printf (printf)
@bereal
bereal / docker_whois.sh
Created August 27, 2020 17:54
Describe Docker scientists
#!/bin/bash
# Docker names container after notable scientists, this script describes them. Add it to your $PATH and enjoy :)
# Usage:
# docker_whois: find scientists for all running containers
# docker_whois <name>: find a single scientist (e.g. docker_whois einstein)
if [[ $# -eq 0 ]]; then
names=$(docker ps --format '{{.Names}}' | sed 's/.*_//g' | egrep '[a-z]+');
@bereal
bereal / Roman.hs
Created March 18, 2019 08:23
Conversion between Roman and decimals numbers
import System.Environment
import qualified Data.Map as M
import Data.Maybe
import Data.Char
letters = "MDCLXVI"
values = [1000, 500, 100, 50, 10, 5, 1]
-- convert in to Roman
import System.Environment
letters = "MDCLXVI"
values = [1000, 500, 100, 50, 10, 5, 1]
-- Convert an int to Roman representation
toRoman n = concat $ norm (reverse letters) (coeffs values n []) []
where coeffs (v : vs) n buf = let (val, n') = divMod n v in coeffs vs n' (val:buf)
coeffs [] n buf = buf
norm (s1:(s2:ss@(s3:_))) (4:(1:(vs))) buf = norm ss vs ([s1, s3]:buf)