Skip to content

Instantly share code, notes, and snippets.

@carasuca
carasuca / ImRotateDemo.cpp
Last active August 14, 2023 04:51
Rotating text and icon demo for dear imgui
#include "imgui_internal.h"
int rotation_start_index;
void ImRotateStart()
{
rotation_start_index = ImGui::GetWindowDrawList()->VtxBuffer.Size;
}
ImVec2 ImRotationCenter()
{
@ijklr
ijklr / StackHash.cpp
Created January 14, 2016 15:56
A very rudimentary C++ implementation of hashmap, allocated on the stack.
//This program is a simple demonstration of the speed difference between standard hashmap from C++ STL library vs. my simple hashmap allocated on the stack. My version is severely limited in for general use, but it is faster and can be run on Arduino devices, whereas there's no STL available for the arduino.
//To compile: g++ -std=c++11 StackHash.cpp
#include <iostream>
#include <unordered_set>
#include <ctime>
using namespace std;
//This default hash assumes T can be converted to int implicitly.
//The user can define how to map T to int with template specializations.
@Perikles
Perikles / AwesomiumResolver.cs
Last active July 11, 2016 18:06
A utility service that allows loading Awesomium.NET assemblies and native binaries from a location other than the executable's folder or GAC.
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Globalization;
namespace Awesomium.Core
{
/// <summary>
/// Utility class that allows loading of Awesomium.NET assemblies,
@galek
galek / pbr.glsl
Created November 4, 2015 11:10
PBR GLSL SHADER
in vec2 v_texcoord; // texture coords
in vec3 v_normal; // normal
in vec3 v_binormal; // binormal (for TBN basis calc)
in vec3 v_pos; // pixel view space position
out vec4 color;
layout(std140) uniform Transforms
{
mat4x4 world_matrix; // object's world position
@julianwachholz
julianwachholz / inputhistory.js
Last active August 28, 2020 10:04
JavaScript <input> history with arrow buttons, a.k.a. poor man's readline
/**
* License: WTFPL - http://www.wtfpl.net/
*
* Usage: element.addEventListener('keydown', inputHistory());
*/
function inputHistory(max_history) {
var PREV = 38, NEXT = 40, ENTER = 13,
history = [''], current = 0;
if (!max_history) {
@marlun78
marlun78 / Number.isFinite.js
Last active February 10, 2017 08:39
Number.isFinite polyfill
/**
* Number.isFinite
* Copyright (c) 2014 marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Spec: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite
*/
if (typeof Number.isFinite !== 'function') {
Number.isFinite = function isFinite(value) {
// 1. If Type(number) is not Number, return false.