Skip to content

Instantly share code, notes, and snippets.

View RobertBendun's full-sized avatar

Robert Bendun RobertBendun

View GitHub Profile
@RobertBendun
RobertBendun / index.1
Created February 26, 2024 11:45
bendun.cc transition phase original
.TH bendun 7 2022-11-09 People Diana\ Bendun
.SH NAME
Diana Bendun \- programming language reasercher
.SH SYNOPSIS
Diana is a programming language reasercher, software engineer, hacker
and student at AMU Poznań.
.SH CONFORMING TO
Free software, art and freedom of self-expression
.SH ENVIRONMENT
Arch Linux + KDE on Thinkpad x270
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 4 columns, instead of 1 in line 5.
Waypoints Statue of The Seven 37 https://act-webstatic.hoyoverse.com/map_manage/20231214/c59585d1fabc9c22ad3fcf94e1622aa8_357413506633071859.png?x-oss-process=image%2Fresize%2Cw_85%2Fquality%2CQ_90%2Fformat%2Cwebp
Waypoints Teleport Waypoint 323 https://act.hoyoverse.com/map_manage/20221125/7d650757c10b70cb42189f7fca0c9778_7547860493386240880.png?x-oss-process=image%2Fresize%2Cw_85%2Fquality%2CQ_90%2Fformat%2Cwebp
Waypoints Domain 56 https://act.hoyoverse.com/map_manage/20220928/186a776c87addad503af2d730230e333_5715047075425774284.png?x-oss-process=image%2Fresize%2Cw_85%2Fquality%2CQ_90%2Fformat%2Cwebp
Waypoints The Crux: The Alcor 1 https://act.hoyoverse.com/map_manage/20220922/4a0f9e1667273d98ebe66fdfb99b331d_4041655545632778907.png?x-oss-process=image%2Fresize%2Cw_85%2Fquality%2CQ_90%2Fformat%2Cwebp
Waypoints Jade Chamber 1 https://act.hoyoverse.com/map_manage/20220922/5f447e0aa6631d19cddaa725ac504871_8968142801522331020.png?x-oss-process=image%2Fresize%2Cw_85%2Fquality%2CQ_90%2Fformat%2Cwebp
Special Items
@RobertBendun
RobertBendun / example.cpp
Last active June 14, 2023 08:25
How to ensure that there are all required values of enumeration inside static array in C++ and D (comparison). In both cases error message is shown, mentioning which case has not been defined inside array
enum class Keyword : u16
{
#define Keywords_Enumeration(X) \
X(If) \
X(Else)
#define X(KW) KW,
Keywords_Enumeration(X)
#undef X
};
-- | Having fun with continued fractions
module ContinuedFraction where
import Data.Ratio
-- To print them in decimal form you can use:
-- > map fromRational phi
phi, sqrt2, e, pi :: [Rational]
@RobertBendun
RobertBendun / path.hs
Last active April 17, 2023 01:19
`/` overloading for path separator in various programming languages
main = putStrLn . getPath $ root/home/user
where
root = Path "/"
home = Path "home"
user = Path "students"
data Path = Path { getPath :: String }
instance Num Path where
-- TODO: Proper path concatenation
@RobertBendun
RobertBendun / packagers.sh
Created April 14, 2023 14:32
Top 10 packagers in your Arch distro
#!/usr/bin/env bash
pacman -Qq | xargs pacman -Qi | grep '^Packager' | awk -F': ' '{ print $2 }' | sort | uniq -c | sort -rn | head -n10 | awk '{ print $1 / '"$(pacman -Qq | wc -l)"' * 100, $0 }
@RobertBendun
RobertBendun / flatten.hs
Created February 3, 2023 20:41
Flatten all the way down in Haskell
{-# LANGUAGE TypeFamilies, FlexibleInstances, FlexibleContexts #-}
type family Flat a where
Flat [[a]] = Flat [a]
Flat [a] = a
class Flatten a where
flatten :: a -> [Flat a]
-- Base case.
trait StartsWith<T> {
fn starts_with(self, other: T) -> bool;
}
// This should work for pairs of iterators, used to compare if
// both iterators describe the same beggining of the sequence
impl<It, OtherIterator> StartsWith<OtherIterator> for It
where
OtherIterator: Iterator,
It: Iterator<Item = <OtherIterator as Iterator>::Item>,
module params_loader;
struct Variable
{
string type, value;
}
private Variable[string] parse(string source)
{
import std.array, std.algorithm, std.string;

Range generator in Lua

function range(start, stop, step)
  if step == nil then step = 1 end
  if stop == nil then stop = start start = 0 end

  return function()
    if start < stop then
 local value = start