Skip to content

Instantly share code, notes, and snippets.

View michael-nischt's full-sized avatar

Michael Nischt michael-nischt

View GitHub Profile
@vurtun
vurtun / kth.c
Last active May 23, 2024 18:34
print K largest(or smallest) elements in an array
/* Problem: Directory file view ui. Files can be sorted by different properties (name, size, ...). Ui itself only needs elements
that are currently in the visible section of the list view from x and count k. So I want to use a fixed size buffer with up to k elements
and walk through all files in the directory and only have the final elements in the end in the fixed size buffer.
Temp buffers are fine for me as long as they have a fixed at compile time size. For those familiar with SQL basically this is
a SORT BY LIMIT begin, count.
Idea: Use Floyd–Rivest algorithm with average O(n) to find the element at index x. Walk over list again and skip all elements smaller than x
then use heap to sort for the k smallest elements afterwards. So we have for Floyd–Rivest and heap combined O(n*log(k))
Problem: Find x is not directly possible since not all elements are in memory because we have only fixed size buffer.
@veekaybee
veekaybee / normcore-llm.md
Last active November 15, 2024 12:06
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@rygorous
rygorous / bc4u_interp_to_float.py
Last active October 25, 2024 16:47
BC4 interpolator results to float conversion attempt
# Computes the 32-bit IEEE float bit pattern for x/16320 (where x is given as an integer),
# with rounding slightly off from proper RN, matching observed behavior of AMD BC4_UNORM
# decoder HW
def hw_14bit_to_floatu_v2(x, trace=False):
if x <= 0:
return 0
elif x >= 255 * 64:
return 0x3f800000
else:
# 16320 = 255*64
@jix
jix / unitri.py
Last active September 3, 2024 13:22
# Copyright 2020 Jannis Harder
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
@munificent
munificent / generate.c
Last active September 15, 2024 03:16
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
//
// Author: Jonathan Blow
// Version: 1
// Date: 31 August, 2018
//
// This code is released under the MIT license, which you can find at
//
// https://opensource.org/licenses/MIT
//
//
@ManuelTS
ManuelTS / UninstallUnity.sh
Last active January 16, 2018 05:01
Uninstalls the Unity Editor on Ubuntu
#!/usr/bin/env bash
# Uninstalls the Unity Editor on Ubuntu.
#
# Tested for Unity 2017.30f1 downloaded from https://beta.unity3d.com/download/3c89f8d277f5/public_download.html
# and Ubuntu 17.10, but it should work with other version too.
#
# Unity is expected to be installed in your home folder, otherwise
# change the first remove command to your installation path.
#
# Execute this program as root, e.g. "sudo sh UninstallUnity.sh"
@teknoraver
teknoraver / unixhttpc.go
Last active November 7, 2024 14:29
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@StefanoBelli
StefanoBelli / disable_gpe6F.service
Last active October 29, 2024 07:21
Temporary fix for ACPI (GPE iinterrupts) failure , disable GPE6f interrupts, probably motherboard faulty ACPI implementation (reflash/update BIOS) [[!!You should take action!!]]. Install this in /usr/lib/systemd/system and run systemctl enable disable_gpe6F
[Unit]
Description=Disable GPE6F interrupts
[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo disable > /sys/firmware/acpi/interrupts/gpe6F"
[Install]
WantedBy=multi-user.target
@flibitijibibo
flibitijibibo / flibitPackaging.md
Created June 17, 2016 16:00
Hope you like reading ldd output!

A week ago I was CC'd in on a thread about Linux packaging, and how to avoid doing it the wrong way (i.e. RPM, Deb, etc.). I've always used MojoSetup and I've never forced distributions to do any additional work, but this is still a new concept to a lot of people. Additionally, Amos suggested that I expand on Itch's FNA appendix, so here's a guide on how I package my games.

This is a bit of an expansion on my MAGFest 2016 presentation, which you can find here:

http://www.flibitijibibo.com/magfest2016/

https://www.youtube.com/watch?v=B83CWUh0Log

I would recommend looking at that first! After that, read on...