Skip to content

Instantly share code, notes, and snippets.

View freem's full-sized avatar
⛏️
work continues

AJ Kelly freem

⛏️
work continues
View GitHub Profile
@markandgo
markandgo / utf8.lua
Last active March 30, 2025 08:44
Kyle Smith's utf8.lua with some extra functions
-- $Id: utf8.lua 179 2009-04-03 18:10:03Z pasta $
--
-- Provides UTF-8 aware string functions implemented in pure lua:
-- * string.utf8len(s)
-- * string.utf8sub(s, i, j)
-- * string.utf8reverse(s)
-- * string.utf8char(unicode)
-- * string.utf8unicode(s, i, j)
-- * string.utf8gensub(s, sub_len)
--
@urkle
urkle / joypad.cpp
Created September 25, 2013 15:21
SDL2 Joystick hot-plugging example
#define MAX_CONTROLLERS 4
class JoypadController {
public:
JoypadController() : m_is_connected(false), m_gamepad(0), m_instance_id(-1), m_haptic(0) {}
int JoypadController::processEvent(const SDL_Event& event);
private:
SDL_GameController *m_gamepad;
SDL_Haptic *m_haptic;
@shakesoda
shakesoda / timer.h
Last active October 25, 2015 21:16
simple high resolution timer w/SDL2
/* USAGE:
* Timer foo; // Start the timer
* const TimeData &time = foo.touch(); // Update and return TimeData (delta being the time since last touch)
* const TimeData &time_peek = foo.peek(); // returns current TimeData only updating the current time (does not reset!)
* SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION
*
* I haven't actually tested peek, but it looks right... */
#pragma once
#include <SDL.h>
@castano
castano / hemicube.cpp
Created June 20, 2014 09:46
Hemicube Integrator
#include "hemicube.h"
#define PACK_HEMICUBES 1
static void get_hemicube_face_normal(int index, Vector3 *forward, Vector3 *left, Vector3 *up) {
// Unwrapped hemicube with positive-Z in the middle.
switch (index) {
case 0: *forward = Vector3(+1, 0, 0); *left = Vector3( 0, 1, 0); break;
@shakesoda
shakesoda / chord.lua
Created September 11, 2014 04:18
axis + face button -> letters. the guts of a controller keyboard.
function gate(axis, num)
local function wrap(x)
return math.fmod(x, math.pi * 2)
end
if math.abs(axis.x) < 0.1 and math.abs(axis.y) < 0.1 then
return num + 1
end
local angle = math.atan2(axis.y, axis.x) -- in radians
@Midiman
Midiman / Main.cpp
Last active August 29, 2015 14:07
Naive Pango Font Renderer
#include <iostream>
#include <vector>
#include <string>
#include <stdexcept>
#include <clocale>
#include <cstring>
#include <cwchar>
#include <cmath>
#include <cstdio>
@axefrog
axefrog / cube.cs
Last active June 20, 2018 16:04
A textured cube using SharpDX
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Windows;
@ocornut
ocornut / (Archived) imgui_memory_editor.h
Last active August 28, 2024 05:01
Mini memory editor for dear imgui (to embed in your game/tools)
// Mini memory editor for Dear ImGui (to embed in your game/tools)
// Animated GIF: https://twitter.com/ocornut/status/894242704317530112
// THE MEMORY EDITOR CODE HAS MOVED TO GIT:
// https://github.com/ocornut/imgui_club/tree/master/imgui_memory_editor
// Click "Revisions" on the Gist to see old version.
@Citillara
Citillara / kb-uninstall.bat
Last active January 17, 2024 12:26
Windows 7 updates to remove to prevent telemetry collection. Disables automatic upgrade to Windows 10
:: Removes most telemetry/data collection/potentially unwanted behavior from Windows 7
:: Disables the automatic download of Windows 10
:: Note : be careful to keep KB in descending order
:: Comment that line to restore prompts for uninstall/reboot
:: Thanks to https://gist.github.com/geoffroyjabouley
set WUSA_OPTIONS=/quiet /norestart
:: Removes Windows 7-8.1 telemetry (part 1)
wusa %WUSA_OPTIONS% /uninstall /kb:3080149
@fo-fo
fo-fo / nes-hardware-sprite-visualizer.lua
Created September 15, 2015 14:44
Lua script for NES hardware sprite visualization in BizHawk
-- NES Hardware Sprite Visualizer (for BizHawk)
-- v01
-- by thefox <[email protected]> 2015-09-15
-- NOTE: Requires NesHawk core
-------------------------------------------------------------------------------
-- Memory domains on NES:
-- WRAM, CHR, CIRAM (nametables), PRG ROM, PALRAM, OAM, System Bus, RAM