Skip to content

Instantly share code, notes, and snippets.

View KTRosenberg's full-sized avatar

Karl Toby Rosenberg KTRosenberg

  • New York University
View GitHub Profile
@gvoze32
gvoze32 / ffmpeg GIF to MP4.MD
Last active March 18, 2025 15:44
Convert animated GIF to MP4 using ffmpeg in terminal.

To convert animation GIF to MP4 by ffmpeg, use the following command

ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4

Description

movflags – This option optimizes the structure of the MP4 file so the browser can load it as quickly as possible.

pix_fmt – MP4 videos store pixels in different formats. We include this option to specify a specific format which has maximum compatibility across all browsers.

@etscrivner
etscrivner / bulk_list.c
Created November 23, 2019 20:57
Bulk list data structure.
#include "bulk_list.h"
#include <stdio.h>
#include <stdlib.h>
bulk_list_t bulk_list_create(int32_t initial_capacity, bulk_list_item_id_t item_size)
{
bulk_list_t result = { NULL, item_size, initial_capacity, 1, 0, 0, 1 };
result.items = (uint8_t*)realloc(result.items, result.capacity * result.item_size);
((bulk_list_item_t*)&result.items[0])->next = 0;
@JoseEmilio-ARM
JoseEmilio-ARM / GPUOptimizationForGames.md
Last active January 3, 2025 11:50 — forked from silvesthu/GPUOptimizationForGameDev.md
GPU Optimization for Games
@983
983 / main.c
Created August 23, 2019 14:13
Draw concave polygon using OpenGL and stencil buffer
// Build on linux:
// sudo apt install freeglut3-dev
// gcc main.c -o main -lGL -lglut
#include <GL/glut.h>
void drawVertices(GLenum mode, const void *vertices, int n_vertices){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(mode, 0, n_vertices);
}
@notnullnotvoid
notnullnotvoid / List.hpp
Created June 27, 2019 06:54
Rounding polygon corners
#ifndef ARRAYLIST_HPP
#define ARRAYLIST_HPP
#include <stdlib.h>
#include <assert.h>
#include <string.h>
//NOTE: this struct zero-initializes to a valid state!
// List<T> list = {}; //this is valid
template <typename TYPE>
@notnullnotvoid
notnullnotvoid / LineRenderer.cpp
Last active January 31, 2023 19:36
Line rendering code
/*
IMPORTANT INFO:
This code is made to be renderer-agnostic.
You would complete the implementation by implementing the triangle() function for your particular renderer.
The code is not written to make use of an index buffer, so it is not perfectly efficient in terms of memory usage.
You can replace the vector / matrix math with types from your own math library if you want, or leave it as-is.
This implementation assumes coordinates are in screen pixel space (circleDetail() relies on that fact).
If you want to draw partially transparent lines, you will need render all triangles of a line at the same depth
and use the less-than or greater-than or not-equal depth test (e.g. glDepthFunc(GL_LESS) or GL_GREATER or GL_NOTEQUAL)
because some triangles overlap.
@dagronf
dagronf / ImageConversion.swift
Last active April 19, 2025 14:15
Extensions for converting NSImage <-> CGImage <-> CIImage
extension NSImage {
/// Create a CIImage using the best representation available
///
/// - Returns: Converted image, or nil
func asCIImage() -> CIImage? {
if let cgImage = self.asCGImage() {
return CIImage(cgImage: cgImage)
}
return nil
}
@d7samurai
d7samurai / .readme.md
Last active May 19, 2025 08:33
Minimal D3D11

Minimal D3D11

Minimal D3D11 reference implementation: An uncluttered Direct3D 11 setup + basic rendering primer and API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion that should be easy to follow from the code alone. ~200 LOC. No modern C++, OOP or (other) obscuring cruft. View on YouTube

hollowcube

Other gists in this series:

@zalo
zalo / WacomMultiTouchProvider.cs
Last active June 27, 2019 04:39
A simple Unity Wacom Multitouch Data Provider that uses the WacomMTDN.dll from the Wacom Feel Multitouch Samples (linked in the comments)
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using UnityEngine;
using WacomMTDN;
// Simple Wacom Multitouch Unity Integration built from the Wacom's DotNet Example:
// https://developer-docs.wacom.com/display/DevDocs/Feel+Multi-touch+Sample+Code+Downloads
// WacomMTDN.dll can be found at: https://drive.google.com/file/d/1fvoRfIev28fKMvTrfF9IBZkAaWow5UJ4/view?usp=sharing
public class WacomMultiTouchProvider : MonoBehaviour {
@yycking
yycking / JavaScriptCore+fetch.swift
Last active March 19, 2025 13:32
add fetch, console.log and Promise.then/catch to JavaScriptCore on iOS/Mac
import JavaScriptCore
extension JSContext {
subscript(key: String) -> Any {
get {
return self.objectForKeyedSubscript(key) as Any
}
set{
self.setObject(newValue, forKeyedSubscript: key as NSCopying & NSObjectProtocol)
}