Skip to content

Instantly share code, notes, and snippets.

View Nircek's full-sized avatar

Marcin Zepp Nircek

View GitHub Profile
@Nircek
Nircek / randomart.html
Last active July 18, 2023 06:22 — forked from malexmave/randomart.html
"Drunk Bishop" RandomArt algorithm (from SSH), implemented as Javascript. Only demo code here, but can be trivially changed to give some return value to do something with the randomart.
<!-- I was recently asked what license this code is under. Since it is fairly trivial code,
I don't really feel it "deserves" a "real" license, so I am hereby placing it in the public domain.
In countries where this is not posible, I am placing it under Creative Commons CC0
(https://creativecommons.org/publicdomain/zero/1.0/), which is basically just a more formal way of
putting it in the public domain for people who like to be sure.
If you want to credit me anyway, that is of course fine with me :) -->
<!DOCTYPE html>
<html>
<body>
<div id="renderDiv" style='font-family:"Lucida Console", Monaco, monospace' />
@Nircek
Nircek / shell.nix
Created July 16, 2023 22:36
rust wasm environment
let
moz_overlay = import (builtins.fetchTarball
"https://github.com/oxalica/rust-overlay/archive/master.tar.gz");
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
in { pkgs ? nixpkgs }:
pkgs.mkShell {
name = "rust env";
buildInputs = with pkgs; [
(rust-bin.stable.latest.default.override {
# extensions = [ "rust-src" ]; # for rust-analyzer
'''
// SRC: https://klimapoint.pl/kalkulator-wilgotnosci-bezwzglednej/ z htmla po prostu
// temp - temperatura w °C (-20 - 50)
// rh - wilgotność względna w % (1 - 100)
function getDP(temp, rh) {
var h = ((Math.log10(rh)-2)/0.4343) + ((17.62*temp)/(243.12+temp));
h = ((243.12*h)/(17.62-h));
return Math.round(h*100)/100;
}
s() { g++ -O2 $1.cpp; for e in $([ -z "$2" ] && echo ./$1/data/sample/*.ans || echo ./$1/data/*/*.ans); do f=${e%.*}; echo $f.in; diff -wyBIEZ $f.ans <(./a.out < $f.in); done }; s bob; # s bob 1
% src: https://www.youtube.com/watch?v=fCzF5gDy60g
1)
\documentclass{article} % albo beamer
\usepackage[margin=1.25in]{geometry}
\usepackage{amsmath, amssymb} % do jakiejkolwiek matmy
\usepackage{graphicx} % do wstawiania obrazków
\begin{document}
\begin{center} \end{center}
@Nircek
Nircek / maze_generator.py
Created August 27, 2022 15:26 — forked from Marwyk2003/maze_generator.py
Maze generation algorithm using iterative dfs
from random import shuffle, randint
from PIL import Image
def generate_maze(X, Y):
'''
Generate a maze and return its walls
Return type (x_walls, y_walls)
x_walls/y_walls - bool array, True = wall, False = no wall
x_walls/y_walls ordered from left to right / top to bottom
'''
openssl genrsa $((1024*16)) | openssl rsa -text
python3 -c "import re;print(int(''.join(re.split('[:\s ]', open(0).read())), 16))"
@Nircek
Nircek / task-roulette.py
Last active March 6, 2022 13:04
Dynamic task roulette
#!/usr/bin/env python3
import random
import shutil
import math
N = 100
bag, weights = [], []
W = shutil.get_terminal_size((80, 20))[0]
class BreakException(Exception):
#!/bin/bash
function confirm() {
# https://stackoverflow.com/a/1885534/6732111
read -p "Is it ok? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
}
@Nircek
Nircek / split.py
Last active December 24, 2021 22:46
split audio files not evenly
#!/usr/bin/env python3
# Copyright 2021 Marcin Zepp <nircek-2103@protonmail.com>
# SPDX-License-Identifier: MIT
import sys
import subprocess
import re
import math
opus, oldmagic, quiet, magic = False, False, True, True