Skip to content

Instantly share code, notes, and snippets.

View nezvers's full-sized avatar

Agnis Aldiņš "NeZvērs" nezvers

View GitHub Profile
@Ravarcheon
Ravarcheon / spectralRotation.py
Last active June 7, 2024 14:48
rotates an audio file by 90 degrees in the spectrum while being a reversible process with minimal loss (only floating point errors which are like -150 dB but thats literally silence ahaha~)
import numpy as np
import soundfile as sf
from scipy.fftpack import fft, ifft
def rotateSignal(signal,flip):
if flip:
signal = signal[::-1]
x = np.concatenate((signal, signal[1:][::-1])) # concatenating the array with a reverse of itself makes it such that the fourier transform doesn't layer over a reversed version of itself in the inverse fft
rotSig = ifft(x)
#include <stdio.h>
#include <stdlib.h>
// -----------------------------------------------------------------------------
// Cross platform high resolution timer
// From https://gist.github.com/ForeverZer0/0a4f80fc02b96e19380ebb7a3debbee5
#include <stdint.h>
#include <stdbool.h>
#if defined(__linux)
@terickson001
terickson001 / main.odin
Last active May 26, 2024 17:08
vulkan-tutorial example in Odin
import "shared:shaderc"
import "vendor:glfw"
import vk "vendor:vulkan"
MAX_FRAMES_IN_FLIGHT :: 2
Context :: struct
{
instance: vk.Instance,
@mattiasgustavsson
mattiasgustavsson / gist:b97e9e59e5e1742dcabff60179fcda67
Created April 7, 2022 14:13
Simple string allocation system, allowing for freeing all allocated strings in one go
#define STR_NEW( pool, str ) ( pool = memcpy( (char*) memcpy( malloc( ( str ? strlen( str ) : 0 ) + 1 + \
sizeof( char* ) ), &pool, sizeof( char* ) ) + sizeof( char*), str ? str : "", ( str ? strlen( str ) : 0 ) + 1 ) )
#define STR_FREE( pool ) while( pool ) { char* STR_FREE_TMP = ( pool - sizeof( char* ) ); \
pool = ( *(char**)STR_FREE_TMP ); free( STR_FREE_TMP ); }
//---------------------------
char* strpool = NULL;
@trikko
trikko / raylib-video.c
Last active November 5, 2023 00:34
How to render a video with raylib and gstreamer
#include "raylib.h"
#include <gst/gst.h>
#include <gst/app/gstappsink.h>
GstElement* createPipeline(const char* filename)
{
GError *error;
gchar *pipelineString = g_strdup_printf ("filesrc location=%s ! tee name=t ! queue ! decodebin ! videoconvert ! appsink name=output caps=video/x-raw,format=RGBA,pixel-aspect-ratio=1/1 t. ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink", filename);
GstElement *pipeline = gst_parse_launch (pipelineString, &error);
@mrhelmut
mrhelmut / style.md
Last active December 26, 2022 10:06
Coding style for pure C# game development projects

Coding style

Over the years of porting pure C# games to consoles, we defined a set of coding guidelines which ensures that porting and performances go smooth on every possible platforms and C# runtimes.

The main reason for these guidelines is that C# runtimes on exotic platforms might be very outdated and/or limited in language features due to the very nature of using Ahead-of-Time (AOT) compilation, or even sometime going as far as transpiling IL Code to C++. Some runtimes are also extremely sensitive to garbage collections, which can produce very visible micro freezes during gameplay, hence our guidelines also target the limitation of garbage.

These guidelines will be very counter-intuitive to enterprise C# developers. Bear in mind that C# is a language that wasn't designed for games and performance in the first place, that using it in this context isn't effecient, and that pretty old C# runtimes mean that we have to bend the language to make it fit our needs. Also keep in mind that we can't count on

@sjvnnings
sjvnnings / better_jumping_character_example.gd
Last active June 19, 2024 12:22
An easy to work with jump in Godot
extends KinematicBody2D
export var move_speed = 200.0
var velocity := Vector2.ZERO
export var jump_height : float
export var jump_time_to_peak : float
export var jump_time_to_descent : float
@beesandbombs
beesandbombs / hexagon tickers
Created August 12, 2020 17:01
hexTickers.pde
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@Dan-Piker
Dan-Piker / Moebius3d
Last active March 27, 2024 08:06
Moebius transformations in 3d
//Moebius transformations in 3d, by reverse stereographic projection to the 3-sphere,
//rotation in 4d space, and projection back.
//by Daniel Piker 09/08/20
//Feel free to use, adapt and reshare. I'd appreciate a mention if you post something using this.
//You can also now find this transformation as a component in Grasshopper/Rhino
//I first wrote about these transformations here:
//https://spacesymmetrystructure.wordpress.com/2008/12/11/4-dimensional-rotations/
//If you want to transform about a given circle. Points on the circle and its axis stay on those curves.
//You can skip these 2 lines if you want to always use the origin centred unit circle.
@SteelPh0enix
SteelPh0enix / wave.c
Last active June 15, 2024 20:46
Simple parser for WAV files, written in C
#include "wave.h"
#include <stdio.h>
#include <string.h>
// Convert 32-bit unsigned little-endian value to big-endian from byte array
static inline uint32_t little2big_u32(uint8_t const* data) {
return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
}
// Convert 16-bit unsigned little-endian value to big-endian from byte array