Skip to content

Instantly share code, notes, and snippets.

View lovely-error's full-sized avatar
😆
Don't forget that you will die some day

Enigma Lav lovely-error

😆
Don't forget that you will die some day
View GitHub Profile
@lovely-error
lovely-error / kern.cl
Last active March 6, 2024 07:52
Conditional execution without branches on gpu
// this kernel writes a value only if invoaction index is even *_*
// when _flag is true, the store adress gets computed to be beyound (1 << 48) byte location .
// apparently stores beyound valid adress space on gpu... just become noops!
#define store_if_true(Ty, addr, val, flag) \
*((__global Ty*)(((unsigned long)addr) + (((unsigned long)(flag == 0)) * ((1LU << 48) - ((unsigned long)addr))))) = val;
__kernel void kern(__global unsigned int* buffer) {
@lovely-error
lovely-error / crapy_integ.hs
Last active February 21, 2024 07:21
Computing definite integral over sinus in range [0;pi] (with terrible precision :3 ~2.0097% deviation from analytic solution)
-- basically this in wolfram alpha terms
-- 2*(Integrate[sin\(40)x\(41),{x,0,Divide[pi,4]}]+Integrate[sin\(40)x\(41),{x,Divide[pi,4],Divide[pi,2]}])
-- https://www.desmos.com/calculator/1fokxfyphz
-- https://www.wolframalpha.com/input?i2d=true&i=Integrate%5Bsin%5C%2840%29x%5C%2841%29%2C%7Bx%2C0%2Cpi%7D%5D
-- https://www.wolframalpha.com/input?i2d=true&i=2*%5C%2840%29Integrate%5Bsin%5C%2840%29x%5C%2841%29%2C%7Bx%2C0%2CDivide%5Bpi%2C4%5D%7D%5D%2BIntegrate%5Bsin%5C%2840%29x%5C%2841%29%2C%7Bx%2CDivide%5Bpi%2C4%5D%2CDivide%5Bpi%2C2%5D%7D%5D%5C%2841%29
import Text.Printf (printf)
@lovely-error
lovely-error / ptrs.zig
Created January 13, 2024 10:06
zig pointer utils
const std = @import("std");
pub const @"1KiB of bytes": comptime_int = 1024;
pub const @"1MiB of bytes": comptime_int = 1024 * 1024;
pub const @"1GiB of bytes": comptime_int = 1 << 30;
pub const @"Byte amount fitting within 48 bit address space": comptime_int = (1 << 48) - 1;
pub fn Ptr(comptime Pointee: type, comptime is_mutable: bool) type {
const Ty = if (is_mutable) *Pointee else *const Pointee;
return struct {
@lovely-error
lovely-error / erase.zig
Last active January 15, 2024 12:48
Easified type erasure in zig
pub fn main() !void {
const AbstractedObject = Opaque(&.{
.{"f1", fn (*anyopaque) u1},
.{"f2", fn (*anyopaque, u8, u8, u8, u8) L},
.{"ferry", fn (*anyopaque)error{boo}!void},
});
var a = std.heap.ArenaAllocator.init(std.heap.page_allocator);
var T = K {};
@lovely-error
lovely-error / lol.agda
Last active January 13, 2024 10:03
automorphisms of Z2
{-# OPTIONS --type-in-type #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Sigma
open import Agda.Builtin.List
data Void : Set where
@lovely-error
lovely-error / kal.hs
Created August 3, 2023 08:26
The world simplest calculator with infix expressions and parens
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PartialTypeSignatures #-}
import Data.Char (isNumber, isSpace)
infixl |>
v |> f = f v
main = do
print "Hey! I am ready to accept input :)"
@lovely-error
lovely-error / hs.hs
Created April 20, 2023 14:24
Stochastic bin packing algorithm, kinda. Was made for one of my lovers
import Data.List
infixl ///
class LaxDivision a where
(///) :: a -> a -> a
instance LaxDivision Int where
(///) = div
@lovely-error
lovely-error / selfreflections.md
Created November 5, 2022 10:22
Those which have many names, but only a single essence

Statement

Somehow, it is not possible to lie. These things are with the definiteviness of a combinatorial object. They are not fractals.

I heard one man once said that homological algebra is the most remarkable thing that has been discovered. In most unlike places I noticed glimpses of its presense.

@lovely-error
lovely-error / more_types!.swift
Created October 2, 2021 21:50
Typelevelisation
import Foundation
func fix <A>(_ f : (A) -> A) -> A { f (fix (f)) }
// _ = fix { _ in }
indirect enum N {
case s(N), z
@lovely-error
lovely-error / IP.md
Last active February 27, 2021 04:47
Oh, wow! Is that a paradigm shift ?!

It's time to move on

Dislcaimer: you can click this, then watch this, then find on net lanugage Terra to grasp a bit of what I am talking bout. Multistage metaprogramming is a big, unrealised area of research. I want a thing kinda like that, but better; with deeper integration with os/linker

All I have seen so far have hurt me deeply

During all my past, as long as I remember myslef, I noted that despite all major languages have had settled and now peacfylly stagnating, many newcomers represented by those like rust, haxe, zig, v, eta, and whatever few hundred other I missed, they inevitably will disappear without leaving a trace, because they all are mediocre. If you have been thinking along these lines that I am going to humiliate them, you gessed it right, I will. The all pieces of shit that came from people who either got so old it cut their ability to innovate, or total poseur, who cannot see world beyound their curriculum. It app