Skip to content

Instantly share code, notes, and snippets.

View zao's full-sized avatar

Lars Viklund zao

View GitHub Profile
@MaulingMonkey
MaulingMonkey / Cargo.toml
Last active June 12, 2019 07:28
rust_win32_gdi
[package]
name = "rust_win32_gdi"
edition = "2018"
[target.'cfg(windows)'.dependencies.winapi]
version = "0.3.7"
features = [
"d3d11",
"debugapi",
"libloaderapi",
# module load StdEnv
# module swap compilers/intel compilers/gcc
# module load apps/cmake libs/fftw libs/gsl libs/boost libs/ftgl libs/hdf5 apps/python/2.7.5 libs/mkl libs/qt/.4.8.5
# cd /software6/src
# NAME=eman2
# VERSION=2.07
# SRCDIR=EMAN2
# COMPILER=gcc
# PREFIX=/software6/apps/${NAME}/${VERSION}_${COMPILER}
@twoscomplement
twoscomplement / TransientFunction.h
Last active August 19, 2023 08:32
TransientFunction: A light-weight alternative to std::function [C++11]
// TransientFuction: A light-weight alternative to std::function [C++11]
// Pass any callback - including capturing lambdas - cheaply and quickly as a
// function argument
//
// Based on:
// https://deplinenoise.wordpress.com/2014/02/23/using-c11-capturing-lambdas-w-vanilla-c-api-functions/
//
// - No instantiation of called function at each call site
// - Simple to use - use TransientFunction<> as the function argument
// - Low cost: cheap setup, one indirect function call to invoke
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <gl/gl.h>
#pragma comment(lib, "opengl32.lib")
@xem
xem / readme.md
Last active May 11, 2024 23:57
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@pervognsen
pervognsen / mu.cpp
Last active December 15, 2023 14:43
Mu as of the second stream
#include "mu.h"
#define _CRT_SECURE_NO_WARNINGS
#include <malloc.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define _NO_CRT_STDIO_INLINE
#include <stdio.h>
#include <stdarg.h>
#define NO_STRICT
@dwilliamson
dwilliamson / SphereIndexing.hlsl
Created July 30, 2015 23:50
Faster Sphere Indexing
float3 PositionToOctahedron(float3 position)
{
// Normalize input position to unit sphere to simplify required ops
float3 P = normalize(position);
// Get octant index
float3 side = P >= 0 ? 1 : 0;
float octant_index = side.x + side.y * 2 + side.z * 4;
// Project onto octahedron face, then onto each x/y plane
@eevee
eevee / fonts.conf.xml
Last active September 5, 2022 03:42
my fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.fonts</dir>
<alias>
<family>serif</family>
<prefer>
<family>Source Serif Pro</family>
<family>IPAMincho</family>
</prefer>
@dwilliamson
dwilliamson / FileWatcher.cpp
Created January 22, 2015 21:39
Single-threaded file watcher with overlapped I/O and filtering of multiple notifications
class FileWatcher
{
public:
FileWatcher(const Path& path)
: m_Path(path)
, m_DirHandle(INVALID_HANDLE_VALUE)
, m_BufferSize(CORE_KB(100))
, m_Buffer(nullptr)
, m_ChangedFiles(1024)
{
@Zoxc
Zoxc / ggpk_defragment.rb
Last active January 4, 2024 02:50
GGPK Defragmenter
require 'bindata'
require 'benchmark'
require 'win32/registry'
require 'io/console'
class GGPK
class UTF16String < BinData::String
def snapshot
super.force_encoding('UTF-16LE')
end