Skip to content

Instantly share code, notes, and snippets.

View niklas-ourmachinery's full-sized avatar

Niklas Gray niklas-ourmachinery

View GitHub Profile
@niklas-ourmachinery
niklas-ourmachinery / upload.rb
Last active September 18, 2019 14:27
Ruby four-liner for uploading web site from Hugo to FTP
# 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. ftp://USER:[email protected]/public_html/)
#
# SINCE upload files changed since this git revision
# if not specified, HEAD^ is used, i.e. the latest changes are uploaded
#
@niklas-ourmachinery
niklas-ourmachinery / repro.c
Created April 8, 2019 16:42
Comma operator initialization bug in MSVC compiler
#include <inttypes.h>
#include <stdio.h>
typedef struct
{
uint64_t a;
uint64_t b;
} s_t;
s_t s = {
@niklas-ourmachinery
niklas-ourmachinery / reducing-build-times.md
Created January 24, 2019 16:30
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
#!/bin/bash
# This file should be installed in .git/hooks/pre-commit
EXITCODE=0
format_file() {
clang-format -style=file ${1} | diff ${1} - > /dev/null
if [ $? -ne 0 ]
then
@niklas-ourmachinery
niklas-ourmachinery / hash.c
Last active October 23, 2024 14:11
Tool for patching static hash macros in source code
// 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
niklas-ourmachinery / random-pdb-name.md
Created August 15, 2017 05:55
Using a random file name for Program Database File

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

Visual Studio Option:

/Fd$(IntDir)$(TargetName)-$([System.DateTime]::Now.ToString("HH_mm_ss_fff")).pdb

Premake5 configuration (at top of premake5.lua):

local function programDataBaseFileName(prj)

premake.w('$(IntDir)$(TargetName)-$([System.DateTime]::Now.ToString("HH_mm_ss_fff")).pdb')

@niklas-ourmachinery
niklas-ourmachinery / identifying-controls-in-an-imgui.md
Last active January 24, 2023 06:09
Identifying controls in an IMGUI

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.