Skip to content

Instantly share code, notes, and snippets.

@libcg
libcg / vulkan-rgb.c
Created December 19, 2024 08:05
Minimal Vulkan clear example
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_video.h>
#include <SDL2/SDL_vulkan.h>
#define VK_NO_PROTOTYPES
#include <vulkan/vulkan.h>
#define COUNT_OF(array) (sizeof(array) / sizeof((array)[0]))
@libcg
libcg / PKGBUILD
Last active August 15, 2020 19:00
js78 PKGBUILD
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
pkgname=js78
pkgver=78.1.0
pkgrel=1
pkgdesc="JavaScript interpreter and libraries - Version 78"
arch=(x86_64)
url="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey"
license=(MPL)
depends=(gcc-libs readline zlib sh)
@libcg
libcg / div.c
Created June 14, 2017 18:34
Floor and ceil integer division
// C99 rounds x/y towards zero
int ceildiv(int x, int y)
{
return x / y + (x % y > 0);
}
int floordiv(int x, int y)
{
return x / y - (x % y < 0);
@libcg
libcg / beep2.py
Created November 17, 2016 06:37
pc speaker sine tone demo
import os
import math
import time
from fcntl import ioctl
MAGIC = 1193180
KDMKTONE = 0x4B2F
def beep(fd, freq=200, ms=4):
period = (int)(MAGIC // freq)
@libcg
libcg / beep.py
Last active December 11, 2016 23:20
pc speaker multitone demo
import os
import math
import time
from fcntl import ioctl
MAGIC = 1193180
KDMKTONE = 0x4B30
def beep(fd, freq=200, ms=3):
period = (int)(MAGIC // freq)