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
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. ftp://USER:PASSWORD@site.com/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 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
niklas-ourmachinery / reducing-build-times.md
Created Jan 24, 2019
Reducing build times by 20 % with a one line change
View reducing-build-times.md

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
#!/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 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
niklas-ourmachinery / random-pdb-name.md
Created Aug 15, 2017
Using a random file name for Program Database File
View random-pdb-name.md

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('<ProgramDataBaseFileName>$(IntDir)$(TargetName)-$([System.DateTime]::Now.ToString("HH_mm_ss_fff")).pdb</ProgramDataBaseFileName>')
View identifying-controls-in-an-imgui.md

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.