Skip to content

Instantly share code, notes, and snippets.

View den-mentiei's full-sized avatar
⌨️
pressing buttons for a living

Denys Mentiei den-mentiei

⌨️
pressing buttons for a living
View GitHub Profile
@den-mentiei
den-mentiei / wintypes.h
Created June 3, 2024 17:52 — forked from SamantazFox/wintypes.h
Header containing all C types used by the Microsoft Win32 API
/*
* wintypes.h
*
* Windows Data Types
* Copyright 2020 (c) Samantaz Fox
*
* This file is in the public domain.
* Feel free to copy, modify, redistribute it!
*

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@den-mentiei
den-mentiei / !README.md
Created February 19, 2024 20:20 — forked from mmozeiko/!README.md
Download MSVC compiler/linker & Windows SDK without installing full Visual Studio

This downloads standalone 64-bit MSVC compiler, linker & other tools, also headers/libraries from Windows SDK into portable folder, without installing Visual Studio. Has bare minimum components - no UWP/Store/WindowsRT stuff, just files & tools for 64-bit native desktop app development.

Run python.exe portable-msvc.py and it will download output into msvc folder. By default it will download latest available MSVC & Windows SDK - currently v14.32.17.2 and v10.0.22621.0.

You can list available versions with python.exe portable-msvc.py --show-versions and then pass versions you want with --msvc-version and --sdk-version arguments.

To use cl.exe/link.exe from output folder, first run setup.bat - after that PATH/INCLUDE/LIB env variables will be setup to use all the tools as usual. You can also use clang-cl.exe with these includes & libraries.

To use clang-cl.exe without running setup.bat, pass extra /winsysroot msvc argument (msvc is folder name where output is stored).

@den-mentiei
den-mentiei / armv8_tsc.h
Created February 19, 2024 20:20 — forked from mmozeiko/armv8_tsc.h
armv8 timer & cycle counter
#pragma once
#define _GNU_SOURCE
#include <stdint.h>
#include <stdbool.h>
#include <sched.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/perf_event.h>
@den-mentiei
den-mentiei / proj.py
Created December 21, 2023 17:19
Projection matrix from quadliteral
import numpy as np
# 'f'rom is a set of (x, y)
# 't'to is a set of (u, v)
# H * (x, y, 1) = k*(u, v, 1) for every point
# combine all equtaions and solve: Ah = b
# h is (h0, .., h7), add h8 = 1, zeros for z
# and make a 4x4 projection matrix
if __name__ == '__main__':
f = [(0.0, 0.0), (0.0, 100.0), (100.0, 100.0), (100.0, 0.0)]
@den-mentiei
den-mentiei / Makefile
Created July 17, 2023 10:56 — forked from ddevault/Makefile
Tiny Wayland compositor
WAYLAND_PROTOCOLS=/usr/share/wayland-protocols
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
xdg-shell-protocol.h:
wayland-scanner server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.c: xdg-shell-protocol.h

FWIW: I (@Rondy) am not the author of the content presented here, which is an outline from Edmond Lau's book. I've just copy-pasted it from somewhere and saved as a personal gist, before it got popular on newsnews.ycombinator.com. I don't remember where exactly the original source is from and neither could find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

@den-mentiei
den-mentiei / 0README.md
Created July 17, 2023 10:32 — forked from chrisdone/0README.md
Various type inference designs/sketches

Type Inference: Various Designs

I'm exploring the right data types for writing a type inference with higher kinds and poly types.

Putting more things in the type system can force you to think about more things, but it also can make it harder and more verbose to write and read algorithms.

@den-mentiei
den-mentiei / typing.md
Created July 17, 2023 10:31 — forked from chrisdone/typing.md
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

@den-mentiei
den-mentiei / clojure-match.clj
Created July 17, 2023 10:29 — forked from ckirkendall/clojure-match.clj
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})