Skip to content

Instantly share code, notes, and snippets.

View photex's full-sized avatar
🎸
I may be slow to respond.

Chip Collier photex

🎸
I may be slow to respond.
View GitHub Profile
@BeRo1985
BeRo1985 / tangentspace_in_four_bytes.glsl
Last active June 25, 2024 06:36
Tangent Space just in four bytes (RGBA10_SNORM)
// Copyright 2024, Benjamin 'BeRo' Rosseaux - zlib licensed
////////////////////////////
// QTangent based variant //
////////////////////////////
// The qtangent based variant has a better precision than the octahedron/diamond based variant below.
// 10bit 10bit 9bit for the 3 smaller components of the quaternion and 1bit for the sign of the bitangent and 2bit for the
// largest component index for the reconstruction of the largest component of the quaternion.
@kinjalkishor
kinjalkishor / game_loops.cpp
Created February 11, 2023 03:07
Game Loops
//----------------------
// Gaffer On Games
// https://gafferongames.com/post/fix_your_timestep/
//----------------------
// Fixed delta time
// If delta time match the display refresh rate, and you can ensure that your update loop takes less than one frame worth of real time.
double t = 0.0;
double dt = 1.0 / 60.0;
while (!quit) {
@T1T4N
T1T4N / generate-xcode-compilation-database.md
Last active June 20, 2024 13:53
Generate a JSON Compilation Database from an Xcode project

Introduction

A JSON compilation database is a very handy output format which is parsed and used by many development tools. Unfortunately for us Apple Developers, it is not straightforward to generate one from within Xcode, as it is (probably) not Apple's priority and therefore there is no toggle/switch/setting that can be easily enabled to get this information.

There is however a solution, thanks to Apple using Clang/LLVM as their main toolchain.

Implementation

The standard way to generate this with clang would be to use the -MJ flag and give it a file name that typically corresponds to the input file. Using this flag indirectly through Xcode is hard, given that we're not aware of all the other arguments when a compiler call is executed.

However, there is a second hidden/badly documented LLVM flag: -gen-cdb-fragment-path - it is implemented in terms of -MJ and has the same functionality, but it's argument in contrast is an output directory.

@mgbckr
mgbckr / switch_bluetooth_profile.sh
Last active November 22, 2023 09:03
Method to make audio quality better for bluetooth headsets on linux (Fedora 34) using mSBC
#!/bin/bash
# source: https://bbs.archlinux.org/viewtopic.php?pid=1973004
# prepare via enabling mSBC codec for HSP/HFP:
# https://wiki.archlinux.org/title/PipeWire#Low_audio_quality_on_Bluetooth
# the `bluez-monitor.conf` is located at:
# `/usr/share/pipewire/media-session.d/bluez-monitor.conf`
# note that the settings gui needs to be restarted after editing the file and calling
# `systemctl --user restart pipewire.service`
#msbc=`pactl list | grep Active | grep msbc`
// Derived from this Gist by Richard Gale:
// https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
// ImGui BFFX binding
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture
// identifier. Read the FAQ about ImTextureID in imgui.cpp.
// You can copy and use unmodified imgui_impl_* files in your project. See
// main.cpp for an example of using this. If you use this binding you'll need to
// call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(),
@aras-p
aras-p / package_builds_vs2017.cmd
Created April 9, 2019 19:36
Packaging up Visual Studio & Windows 10 SDK for in-repository usage
@echo off
@rem Packages up VS2017 toolchain into builds.7z archive
@set TOOLS_VERSION=14.13.26128
@cd "%~dp0"
@set VC_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\VC\
@if not exist "%VC_PATH%" goto error_no_vs
@if not exist "%VC_PATH%"Tools\MSVC\%TOOLS_VERSION% goto error_no_vs
@jojonas
jojonas / love2d-unpacker.py
Last active July 8, 2024 14:22
Love2d executable unpacker.
import argparse
import os, os.path
import zipfile
import io
def readui32(file):
bytes = file.read(4)
number = bytes[0]
number += bytes[1] << 8
number += bytes[2] << 16
Clone and compile the Linux kernel
==================================
# Use some extra directory for all the components needed
cd c2c/
# Clone the repository (this will take a *few minutes*)
c2c$ git clone https://github.com/CTU-IIG/802.11p-linux.git
c2c$ cd 802.11p-linux
# Checkout particular branch
@redboltz
redboltz / variant.cpp
Created June 28, 2014 16:14
msgpack-c boost::variant example
#include <boost/variant.hpp>
#include <msgpack.hpp>
// Definition of the variant type.
// The types appear the following example are supported.
// {'metadata': {'date': '2014-06-25', 'user_id': 501},
// 'values': [3.1, 4.1, 5.1],
// 'version': 1}
@munificent
munificent / gist:9749671
Last active June 23, 2022 04:04
You appear to be creating a new IDE...
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs: