Skip to content

Instantly share code, notes, and snippets.

Niklas Gray niklas-ourmachinery

Block or report user

Report or block niklas-ourmachinery

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
niklas-ourmachinery / upload.rb
Last active Sep 18, 2019
Ruby four-liner for uploading web site from Hugo to FTP
View upload.rb
# upload.rb URL [SINCE]
# Uploads website generated by Hugo (or other static web site generator) to the URL using wput.
# URL URL of ftp server, including user name and password
# (e.g.
# SINCE upload files changed since this git revision
# if not specified, HEAD^ is used, i.e. the latest changes are uploaded
niklas-ourmachinery / repro.c
Created Apr 8, 2019
Comma operator initialization bug in MSVC compiler
View repro.c
#include <inttypes.h>
#include <stdio.h>
typedef struct
uint64_t a;
uint64_t b;
} s_t;
s_t s = {
niklas-ourmachinery /
Created Jan 24, 2019
Reducing build times by 20 % with a one line change

Reducing build times by 20 % with a one line change

Experimenting a bit with the /d2cgsummary and /d1reportTime flags described by Aras here and here I noticed that one of our functions was consistently showing up in the Anomalistic Compile Times section:

1>	Anomalistic Compile Times: 2
1>		create_truth_types: 0.643 sec, 2565 instrs
1>		draw_nodes: 0.180 sec, 5348 instrs
View pre-commit.bash
# This file should be installed in .git/hooks/pre-commit
format_file() {
clang-format -style=file ${1} | diff ${1} - > /dev/null
if [ $? -ne 0 ]
niklas-ourmachinery / hash.c
Last active Oct 18, 2019
Tool for patching static hash macros in source code
View hash.c
// hash can generate static hashes of strings or patch TM_STATIC_HASH("...", v)
// macros in source code with the correct hash values.
#include <foundation/carray.inl>
#include <foundation/git_ignore.h>
#include <foundation/log.h>
#include <foundation/murmurhash64a.inl>
#include <foundation/os.h>
#include <foundation/temp_allocator.h>
niklas-ourmachinery /
Created Aug 15, 2017
Using a random file name for Program Database File

Use a "random" name for the PDB instead of vc141.pdb.

Visual Studio Option:


Premake5 configuration (at top of premake5.lua):

local function programDataBaseFileName(prj)

Identifying controls in an IMGUI

In an IMGUI we need a way to identify which control is active or hot. For example, when we press a key, which text box does the text go to.

Possible options:

  1. Sequential number (Unity)

    Each control drawn gets a sequentially increasing number.

You can’t perform that action at this time.