Skip to content

Instantly share code, notes, and snippets.

@TheRealMJP
TheRealMJP / Tex2DCatmullRom.hlsl
Last active May 26, 2024 22:43
An HLSL function for sampling a 2D texture with Catmull-Rom filtering, using 9 texture samples instead of 16
// The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae
// Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16.
// See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details
float4 SampleTextureCatmullRom(in Texture2D<float4> tex, in SamplerState linearSampler, in float2 uv, in float2 texSize)
{
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
// location [1, 1] in the grid, where [0, 0] is the top left corner.
float2 samplePos = uv * texSize;
#### Are there other single-file public-domain libraries out there?
Yes. Here are some:
- [nanoSVG](https://github.com/memononen/nanosvg): 1-file SVG parser; 1-file SVG rasterizer (zlib license)
- [DG_misc.h](https://github.com/DanielGibson/Snippets/): Daniel Gibson's stb.h-esque cross-platform helpers: path/file, strings (public domain)
- [jo_gif.cpp](http://www.jonolick.com/home/gif-writer): tiny GIF writer (public domain)
- [gif.h](https://github.com/ginsweater/gif-h): animated GIF writer (public domain)
- [MakeID.h](http://www.humus.name/3D/MakeID.h): allocate/deallocate small integer IDs efficiently (public domain)
@LearnCocos2D
LearnCocos2D / gist:77f0ced228292676689f
Last active February 12, 2024 20:47
Overview of Entity Component System (ECS) variations with pseudo-code

For background and further references see: Entity Component Systems on Wikipedia

ECS by Scott Bilas (GDC 2002)

Entity->Components->Update
  • entity = class: no logic + no data OR at most small set of frequently used data (ie position)
  • component = class: logic + data
foreach entity in allEntities do
    foreach component in entity.components do
@gafferongames
gafferongames / delta_compression.cpp
Last active May 13, 2024 06:38
Delta Compression
/*
Delta Compression by Glenn Fiedler.
This source code is placed in the public domain.
http://gafferongames.com/2015/03/14/the-networked-physics-data-compression-challenge/
*/
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
@adamgreig
adamgreig / 00-README.md
Last active August 12, 2022 08:37
Run embedded Rust code on your STM32F4

Embedded Rust on STM32F4

My notes from implementing Job Vranish's excellent guide.

Follow along with the guide above, getting rustc from rustup or similar:

rustc 1.0.0-nightly (dcaeb6aa2 2015-01-18 11:28:53 +0000)
binary: rustc
commit-hash: dcaeb6aa23ecba2dc2af870668a9239136d20fa3

commit-date: 2015-01-18 11:28:53 +0000

@dobrokot
dobrokot / gccg.py
Last active August 29, 2015 14:04
import sys, re
# convert lispy-like language to 'lambda-man' ICFP2014 assembler.
# output is JavaScript, loaded in browser
def parse(s, i):
node = []
while 1:
while i < len(s) and (s[i] == ' ' or s[i] == '\n' or s[i] == '\r' or s[i] == '\t'):
i = i+1
@JanJakes
JanJakes / 00-readme.md
Last active July 27, 2023 11:32
Ubuntu server with Nginx, uWSGI and Node.js installation & deployment setup

Ubuntu with Nginx, uWSGI & Node.js and it's deployment

This Gist contains instructions to setup Ubuntu server with Nginx, uWSGI & Node.js with that can serve for any Python apps (Django for instance) and will allow it's automatized deployment.

The content is as follows:

  • 01-ubuntu.md – A basic Ubuntu server setup.
  • 02-nginx-uwsgi-nodejs.md – Nginx, uWSGI and Node.js installation and setup.
  • 03-deployment.md – A server setup for automatized deployment.
  • 04-mariadb.md – Mariadb installation and setup.
@yihuang
yihuang / uwsgi-gevent-benchmark.rst
Last active July 17, 2019 10:20
uwsgi gevent benchmark
CPU:Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz (X8)
OS:debian7
PYTHON:python2.7.3
GEVENT:gevent-1.0rc1
UWSGI:1.9.15-dev

hello world

@3noch
3noch / Either.h
Last active July 9, 2020 15:27
An implementation of Haskell's "Either" type C++
#pragma once
#include <boost/optional.hpp>
/**
* Wraps any value with a context of Left for the Either class.
*
* By convention, Left represents some sort of less-desired condition.
*/
@sigman78
sigman78 / l15decode.py
Last active December 19, 2015 18:09
Convert L15 raw to 8 bit pgm
#!/usr/bin/env python
"""l15decode.py: L15 image format decoder."""
import os, sys
from time import time
import array
NUMPY = False
try: