Skip to content

Instantly share code, notes, and snippets.

@neacsum
neacsum / bresenham.cpp
Created March 27, 2023 01:37
Bresenham Algorithm
// a point
struct pt {
int x;
int y;
};
/*
Bresenham algorithm.
Finds successive points on the line (x0, y0) - (x1, y1).
@neacsum
neacsum / ipow.h
Created December 1, 2021 15:55
Integer exponentiation template function
#pragma once
/*
Integer exponentiation function.
In most cases, it is faster than standard pow function
*/
template <typename T>
T ipow (T base, int exp)
{
T result = 1;
@neacsum
neacsum / biosuuid.cpp
Created November 27, 2021 15:57
How to Get the BIOS UUID
#include <windows.h>
#include <sysinfoapi.h>
#include "biosuuid.h"
/*!
SMBIOS Structure header as described at
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.3.0.pdf
(para 6.1.2)
@neacsum
neacsum / style.md
Last active January 29, 2024 00:54
Coding Syle Rules

Elements of Style

…with apologies to Strunk, White, Plauger, and Kernighan

©Mircea Neacsu 2016-2023

”... programs must be written for people to read, and only incidentally for machines to execute.” — Structure and Interpretation of Computer Programs second edition; Harold Abelson and Gerald Jay Sussman with Julie Sussman, foreword by Alan J. Perlis

These rules will make programs easier to read and easier to understand. They have been designed with an eye on legibility and respect for typographic conventions.

Note: None of these rules are cast in stone; they can always be bent if need arises. Just be prepared to give some good arguments why you didn't follow them ;-) Some of them are softer than others, though.