Skip to content

Instantly share code, notes, and snippets.

View icebreaker's full-sized avatar
👽
Code gardening!

Mihail Szabolcs icebreaker

👽
Code gardening!
View GitHub Profile
@martin31821
martin31821 / crc32.cs
Last active November 13, 2023 02:27
C# port of the crc32 algorithm
// inspired by http://opensource.apple.com//source/xnu/xnu-1456.1.26/bsd/libkern/crc32.c
// You may use this program, or
// code or tables extracted from it, as desired without restriction.
namespace CRC32
{
public static class CRC32
{
static readonly uint[] crc32_tab = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@unitycoder
unitycoder / if-branchless.shader
Last active April 3, 2024 11:20
Avoiding Branching / Conditionals in Shaders Fast No If
"The common wisdom of "don't use conditionals in shaders" is one of my biggest frustrations with how shaders are taught.
step(y, x) _is_ a conditional! It compiles to identical code as:
float val = (x >= y ? 1.0 : 0.0)
or
float val = 0.0;
if (x >= y) val = 1.0;"
https://twitter.com/bgolus/status/1235254923819802626
// Performing shader divisions without diving *rcp = approximation of 1/x
float myDividedVal = myValToDivide * rcp(myDivider);
@statico
statico / gpu.cpp
Last active May 5, 2025 13:07
Trick to tell AMD and Nvidia drivers to use the most powerful GPU instead of a lower-performance (such as integrated) GPU
#ifdef _WIN32
// Use discrete GPU by default.
extern "C" {
// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
// http://developer.amd.com/community/blog/2015/10/02/amd-enduro-system-for-developers/
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

@nitoyon
nitoyon / rgb.go
Created January 1, 2016 16:08
Generate Animation GIF with Golang
package main
import (
"fmt"
"image"
"image/color"
"image/gif"
"math"
"os"
)
@asmagill
asmagill / loopstop.lua
Last active March 12, 2019 12:34
prevent infinite loop in lua code from locking Hammerspoon up...
--
-- uses debug.sethook and a timer to break out of infinite loops in lua code within Hammerspoon
--
-- Haven't had any problems with it or false positives, but YMMV -- standard disclaimers, etc.
--
-- Updates 2015-12-21:
-- should play nicely with other hooks by storing info about it and chaining
-- you can force an "immediate" break by holding down CMD-CTRL-SHIFT-ALT-CAPSLOCK-FN all at once
-- you'll need to remove "and mods.fn" where noted below if your keyboard does not have this
-- modifier (non-laptops, I suspect)
@SchizoDuckie
SchizoDuckie / build_mac.sh
Created July 7, 2015 20:55
Build an OSX .pkg installer from Linux using mkbom and xar
#!/bin/bash
# change the values below to match your system.
# target the BUILD_DIR to output from an nw.io build process. nwjs-shell-builder recommended!
# https://github.com/Gisto/nwjs-shell-builder
# BASE_DIR is the target directory for this script, where files will be gathered and packaged to
BUILD_DIR=”/var/www/deploy/TMP/osx-ia32/latest-git”
BASE_DIR=”/var/www/deploy/osx” 
@sighingnow
sighingnow / Makefile
Last active March 8, 2025 17:56
Detect operating system in Makefile.
# Detect operating system in Makefile.
# Author: He Tao
# Date: 2015-05-30
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG += -D WIN32
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
OSFLAG += -D AMD64
endif
@ryanpcmcquen
ryanpcmcquen / torchlight-sdl-fix.sh
Last active October 8, 2018 05:54 — forked from PVince81/gist:63800bffd437f2175da9
torchlight-sdl-fix
#!/bin/sh
## curl https://gist.githubusercontent.com/ryanpcmcquen/687747c6de09693a6916/raw/torchlight-sdl-fix.sh | sh
# set this to your Torchlight directory
TORCHLIGHTDIR=/usr/local/games/Torchlight
## grab the SDL repo
hg clone http://hg.libsdl.org/SDL
## enter the directory
cd SDL
@PVince81
PVince81 / gist:63800bffd437f2175da9
Last active June 16, 2021 05:54
build-sdl2-for-torchlight.sh
# set this to your Torchlight directory
TORCHLIGHTDIR=$HOME/games/Torchlight
hg clone http://hg.libsdl.org/SDL
# check out the revision before the one that introduces the bug as advised here: http://forums.runicgames.com/viewtopic.php?f=24&t=33360&start=60#p474739
hg up 4de584a3a027 --clean
# Fix X11 compilation issues with another changeset
hg export 6caad66a4966 > patch
hg import patch