Skip to content

Instantly share code, notes, and snippets.

@esmooov
esmooov / checkout.md
Created May 31, 2012 15:54
The Secret Passions of Git Checkout

The Secret Passions of Git Checkout


The Hand of God

Master Hand

Git checkout can do almost anything ... or, at least, many things. It can switch branches. It can mix and match branches. It can resolve merge conflicts. It can give you a scratchpad to test things. It can even be used to interactively patch files. It's so powerful because it's so abstract. But much like numinous mystics, abstraction makes it confusing.

Basically git checkout does two things:

@rygorous
rygorous / gist:4172889
Created November 30, 2012 00:28
SSE/AVX matrix multiply
#include <immintrin.h>
#include <intrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
union Mat44 {
float m[4][4];
__m128 row[4];
};
@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@jlblancoc
jlblancoc / delete_build_temps.bat
Created November 28, 2013 21:54
Batch (.BAT) script (Windows) to delete all temporary files after compiling a project with Microsoft Visual Studio (Visual C++) or GCC. It finds and removes (recursively in the given directory trees), all files that match any of: *.obj, *.o, *.pch, *.pdb, *.ilk, *.idb, *.gch
REM =======================================================================
REM Batch (.BAT) script (Windows) to delete all temporary files after
REM compiling a project with Microsoft Visual Studio (Visual C++) or GCC.
REM
REM Warning: It also deletes the debug databases, needed to "step into"
REM from a debugger. These files may be really *large*, but if you think
REM you will need them, remove the file for "*.pdb" below.
REM
REM Usage:
REM - Open a terminal (Windows-key + R , type "cmd", press ENTER)
@selfshadow
selfshadow / gist:8048308
Last active March 19, 2023 06:44
Reoriented Normal Mapping (http://blog.selfshadow.com/publications/blending-in-detail/) for unpacked, normalised vectors
// Blending when n1 and n2 are already 'unpacked' and normalised
float3 blend_rnm_unpacked(float3 n1, float3 n2)
{
float3 t = n1.xyz + float3( 0, 0, 1);
float3 u = n2.xyz * float3(-1, -1, 1);
float3 r = (t/t.z)*dot(t, u) - u;
return r;
}
@rygorous
rygorous / vr_urgh.txt
Last active September 6, 2022 21:35
What I mean when I say "I think VR is bad news".
This just got linked to by the Y combinator news account, without proper context,
so a brief introduction: A month ago (end of May / early June 2014) I had a
Twitter conversation with a bunch of acquaintances. One tweet in the middle
of that thread, with obligatory hyperbole, was me saying that I think VR is
bad news.
Well, that part of the thread (but not the rest that provides context) recently
got retweeted, and then someone asked me if I could explain what I mean by that,
and because Twitter is a great platform for delivering 140 character slogans and
not so great for lengthy explanations, I wrote this. So, obligatory disclaimer:
@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
@nlguillemot
nlguillemot / main.cpp
Created August 30, 2015 02:22
BasicGL
#include <Windows.h>
#include <GL/gl.h>
#pragma comment(lib, "OpenGL32.lib")
LRESULT CALLBACK MyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CLOSE:
@n3dst4
n3dst4 / renaming.markdown
Last active February 21, 2024 13:56
How to rename Visual Studio solutions and projects

How to rename solutions and projects in Visual Studio

  1. Don't.

How to rename solutions and projects that were created in Visual Studio

  1. Close Visual Studio and don't open it again until I tell you. Visual Studio is not competent at renaming things.
  2. Assuming you're using git, clean the working folder to remove anything that's not in version control (this will help the search-and-replace step because it won't have to go through a bunch of generated files)

git clean -fdx