Skip to content

Instantly share code, notes, and snippets.

View Cloudef's full-sized avatar

Jari Vetoniemi Cloudef

View GitHub Profile
@Cloudef
Cloudef / zig-stdenv.nix
Last active February 19, 2024 18:36
Zig based cross-compiling toolchain
{ pkgs ? import <nixpkgs> {}, lib ? pkgs.lib, stdenv ? pkgs.stdenv, zig ? pkgs.zig, static ? true, target }:
with lib;
with builtins;
# Zig based cross-compiling toolchain
#
# Major known issues:
# - Zig seems to randomly fail with parallel builds with 'error: unable to build ... CRT file: BuildingLibCObjectFailed'
# This seems like race condition with the cache?
@Cloudef
Cloudef / config.py
Last active November 29, 2023 06:18
limnoria discord bridge
###
# Copyright (c) 2014, Jari Vetoniemi
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
@Cloudef
Cloudef / git-archive-all
Created June 15, 2017 13:38
wlc release scripts
#!/bin/bash
# Archive git project including all submodules
# Usage: git archive-all <name> <ref>
set -eEuo pipefail
current="$(git rev-parse --abbrev-ref HEAD)"
toplevel="$(git rev-parse --show-toplevel)"
toplevel="${toplevel##*/}"
name="${1:-$toplevel}"
@Cloudef
Cloudef / glvsync.c
Last active November 23, 2022 10:00
Force glXSwapInterval* to whatever you want
/* gcc -std=c99 -fPIC -shared -Wl,-soname,glvsync.so glvsync.c -o glvsync.so
* gcc -m32 -std=c99 -fPIC -shared -Wl,-soname,glvsync.so glvsync.c -o glvsync.so (for 32bit)
*
* Force VSYNC interval on OpenGL applications
* Alternatively can also try FPS locking a OpenGL program
* Usage: LD_PRELOAD="/path/to/glvsync.so" ./program
*/
#define _GNU_SOURCE
#include <dlfcn.h>
@Cloudef
Cloudef / default.nix
Last active October 29, 2022 01:07 — forked from nmattia/default.nix
Report for runtime dependencies of a derivation
# MIT License, see below
#
# These are some helpers for figuring out the derivations attributes of runtime
# dependencies of a derivation, in particular the function `runtimeReport`. At
# the bottom of the file you can see it used on `hello`. Spoiler: glibc is a
# runtime dependency.
# For more info see
#
# https://nmattia.com/posts/2019-10-08-runtime-dependencies.html
@Cloudef
Cloudef / invokeai.nix
Last active October 18, 2022 15:45
Nix file for InvokeAI for M1 mac
{ pkgs ? import <nixpkgs> {}
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, fetchurl ? pkgs.fetchurl
, runCommand ? pkgs.runCommand
, makeWrapper ? pkgs.makeWrapper
, mkShell ? pkgs.mkShell
, installationPath ? (builtins.toString ./.) + "/.conda"
, frameworks ? pkgs.darwin.apple_sdk.frameworks
}:
@Cloudef
Cloudef / packet.h
Last active July 2, 2018 18:12
poc uinputd and vita client, TL;DR it sucks
#pragma once
enum packet_type {
PACKET_IOCTL,
PACKET_WRITE,
};
enum ioctl_dir {
IOCTL_NONE,
IOCTL_IOR,
@Cloudef
Cloudef / xic.c
Last active March 4, 2017 21:52
FFXI message compression/decompression
/**
* tcc -std=c99 xic.c -o xic
*
* Tool to compress/decompress FFXI server messages.
*
* I'm not sure what the algorithm is, but it seems to work on separate encoding and
* decoding tables. (It seems to be some sort of cumulative substitution coder)
*
* At most encoding outputs 8 times bigger buffer than original for decoding.
* However this buffer is mostly zeros and needs to be only expanded during decoding,
@Cloudef
Cloudef / bams.c
Last active October 22, 2016 14:42
Find shortest rotation without branches.
#include <stdint.h>
// you can use any precision you want
typedef uint32_t ubams;
typedef int32_t bams;
static const uint32_t erro = (sizeof(ubams) < sizeof(uint32_t));
static const uint32_t most = (ubams)~0;
static inline ubams
@Cloudef
Cloudef / fakepkg.bash
Created September 6, 2016 09:53
Fake makepkg enough to build and install android-protobuf from PKGBUILD
#!/bin/bash
# Fake makepkg enough to build and install android-protobuf PKGBUILD
# Go into sanity mode
set -eEuo pipefail
# Heuristics, do your job if not true.
PROTOC="$(which protoc)"
MAKEFLAGS="$@"