Skip to content

Instantly share code, notes, and snippets.

View theoparis's full-sized avatar

Theo Paris theoparis

View GitHub Profile
@misterabdul
misterabdul / main.c
Created June 18, 2021 03:55
Simple OpenGL program to open window.
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
int
main()
{
// Initialise GLFW
@inscapist
inscapist / flake-direnv.md
Last active May 18, 2026 01:40
Nix Flakes and Direnv on Mac OSX (Catalina)

Development environment with Nix Flakes and Direnv

This document is targeted at those who seek to build reproducible dev environment across machines, OS, and time.

It maybe easier for remote teams to work together and not spending hours each person setting up asdf/pyenv/rbenv, LSP servers, linters, runtime/libs. Nix is probably the closest thing to Docker in terms of development environment.

Flake is used here because it provides hermetic build, with absolutely no reliance on system environment (be it Arch/Catalina/Mojave). Also it freezes dependencies in flake.lock so builds are reproducible.

This gist provides the setup to develop Java/Clojure/Python applications on Nix. But it can be easily adapted to ruby, nodejs, haskell.

@zchee
zchee / nvram.c
Last active April 9, 2025 21:19
nvram list from xnu-8020.101.4 (`rg PE_parse_boot_ --sort=path --line-number --no-multiline --no-heading`)
bsd/crypto/entropy/entropy_sysctl.c:134: if (__improbable(PE_parse_boot_argn(ENTROPY_ANALYSIS_BOOTARG, &sample_count, sizeof(sample_count)))) {
bsd/dev/dtrace/dtrace.c:19237: if (!PE_parse_boot_argn("dtrace_kernel_symbol_mode", &dtrace_kernel_symbol_mode, sizeof (dtrace_kernel_symbol_mode))) {
bsd/dev/dtrace/dtrace.c:19348: if (!PE_parse_boot_argn("dtrace_dof_mode", &dtrace_dof_mode, sizeof (dtrace_dof_mode))) {
bsd/dev/dtrace/dtrace.c:19412: PE_parse_boot_argn("keepsyms", &keepsyms, sizeof(keepsyms));
bsd/dev/dtrace/fbt_blacklist.c:395: PE_parse_boot_argn("IgnoreFBTBlacklist", &ignore_fbt_blacklist, sizeof(ignore_fbt_blacklist));
bsd/dev/mem.c:89:#include <pexpert/pexpert.h> /* for PE_parse_boot_argn */
bsd/dev/mem.c:272: PE_parse_boot_argn("kmem", &kmem, sizeof(kmem))) {
bsd/dev/unix_startup.c:286: (void) PE_parse_boot_argn("ncl", &ncl, sizeof(ncl));
bsd/dev/unix_startup.c:287: (void) PE_parse_boot_argn("mbuf_pool", &mbuf_pool, sizeof(mbuf_pool));
bsd/kern/bsd_init.c:442: if (PE_parse_boot_argn("rd"
@nickdesaulniers
nickdesaulniers / build.sh
Last active August 21, 2024 18:45
linking hello world against musl built as LTO
# Building musl
$ ./configure CC=clang LD=lld
$ make -j72
# Building with musl (non-lto, no patch)
$ clang hello.c -nostdlib -fuse-ld=lld -L lib -lc -static lib/crt1.o
# Building against musl LTO
$ clang hello.c -nostdlib -fuse-ld=lld -static lib/crt1.o -Wl,--whole-archive lib/libc.a -Wl,--no-whole-archive -Wl,--gc-sections
@Sqvall
Sqvall / file-upload.tsx
Last active May 21, 2026 05:56
File Upload with Chakra UI and react-hook-form
import { ReactNode, useRef } from 'react'
import { Button, FormControl, FormErrorMessage, FormLabel, Icon, InputGroup } from '@chakra-ui/react'
import { useForm, UseFormRegisterReturn } from 'react-hook-form'
import { FiFile } from 'react-icons/fi'
type FileUploadProps = {
register: UseFormRegisterReturn
accept?: string
multiple?: boolean
children?: ReactNode
@itkrt2y
itkrt2y / file-base-routing-with-preact-vite-wouter.tsx
Last active November 8, 2024 21:10
File based routing for vite, preact and wouter
import { Route, Switch } from "wouter-preact";
const pageFiles = import.meta.globEager("./pages/**/*.tsx");
const pages = Object.keys(pageFiles)
.sort()
.reverse() // Ensure the order of page file names. Put `:<filename>` to the end of the array.
.map((filePath) => {
const path = filePath.slice(8, -4).replace(/\/?index$/, "");
const { Page } = pageFiles[filePath];
@halferty
halferty / main.c
Last active July 15, 2022 11:57
init process that draws to framebuffer
#include <errno.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <linux/kd.h>
#include <linux/limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
this video was created earlier in january from a stupid idea and was driven by sheer determination
despite lacking programming skill. here's a decent description of how it was made (because i am
too lazy to write a github readme):
1. the video
i downloaded the pv off youtube and used ffmpeg to resize it down to 70x54 dimensions (for easy
math calculations, i used 27 firefox windows, 7 tabs each, so it divided nicely). i then used
ffmpeg (again) to splice the source video into 15-second segments to reduce desyncing and cpu load.
2. the frames
@probonopd
probonopd / Wayland.md
Last active May 27, 2026 23:27
Think twice about Wayland. It breaks everything!

Think twice before abandoning X11. Wayland breaks everything!

tl;dr: Wayland is not "the future", it is merely an incompatible alternative to the established standard with a different set of priorities and goals.

Wayland breaks everything! It is binary incompatible, provides no clear transition path with 1:1 replacements for everything in X11, and is even philosophically incompatible with X11. Hence, if you are interested in existing applications to "just work" without the need for adjustments, then you may be better off avoiding Wayland.

Wayland solves no issues I have but breaks almost everything I need. Even the most basic, most simple things (like xkill) - in this case with no obvious replacement. And usually it stays broken, because the Wayland folks mostly seem to care about Automotive, Gnome, maybe KDE - and alienating e