Skip to content

Instantly share code, notes, and snippets.

View Cloudef's full-sized avatar

Jari Vetoniemi Cloudef

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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="$@"
@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,
#include <stdio.h>
#include <stdint.h>
void main(void)
{
char num[4];
const char *lut[] = { num, "Fizz\n", "Buff\n", "FizzBuff\n" };
for (uint32_t i = 1; i <= 100; ++i) {
const uint8_t n = !(i % 3) + (2 * !(i % 5));
snprintf(num, sizeof(num), "%d\n", i);
@Cloudef
Cloudef / bitrot.c
Last active August 29, 2015 14:27
Bitwise rotation with mask
#include <stdint.h>
#include <stdio.h>
#include <limits.h>
#include <assert.h>
static void
print_bits(uint32_t v)
{
for (uint32_t i = 0; i < sizeof(v) * CHAR_BIT; ++i)
printf("%u", !!(v & (1<<i)));