Skip to content

Instantly share code, notes, and snippets.

View sham1's full-sized avatar

Jani Juhani Sinervo sham1

View GitHub Profile
@sham1
sham1 / alpha-blend.c
Created May 8, 2023 20:54
Alpha blending (over) with pre-multiplied ARGB pixels
/*
* Copyright (c) 2023 Jani Juhani Sinervo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@sham1
sham1 / destructuring-bind.scm
Created March 18, 2022 16:19
destructuring-bind in R7RS
(import (scheme base)
(scheme write))
(define-syntax destructuring-bind
(syntax-rules ()
((_ (name1 names ...) var body1 bodys ...)
(apply
(lambda (name1 names ...)
body1 bodys ...)
var))))
(defun matrix-* (a b)
(let ((ret (make-array '(3 3))))
(loop for i from 0 to 2 do
(loop for j from 0 to 2 do
(setf (aref ret i j)
(loop for k from 0 to 2
summing (* (aref a i k) (aref b k j))))))
ret))
(defconstant +identity+ (make-array
@sham1
sham1 / configure-template.sh
Last active August 9, 2021 20:45
Template for ./configure-scripts in (hopefully) POSIX shell
#!/bin/sh
usage() {
printf "Usage: %s [options]\n" "${0}"
echo ""
echo "Options: "
printf " --help or -h "
echo "Display this help message"
printf " --prefix=PREFIX "
echo "Top level install directory is PREFIX [default /usr/local]"
#!/usr/bin/env bash
output_file="${HOME}/found_empty.txt"
# For user convenience. If the user runs this using `sudo`,
# the file shall be within their own home directory, instead
# of the root's.
#
# We shall also create the file and make its ownership make sense
# for the user.

Running X11 applications using Podman

This is a short tutorial on using podman to run X11 applications. This need often arises when one has to run X11 applications on distros such as Silverblue, when the application for instance has no Flatpak and one doesn't want to install the particular app on their host OS (for instance for Silverblue this process would result in the need to layer a package and then reboot, something which understandably would get quite irritating after a while).

#include <inttypes.h>
#include <stdio.h>
void main(void)
{
uint16_t low_short = (union{uint16_t shorts[2];uint32_t i;})
{.i = 0xDEADBEEF}.shorts[0];
printf("0x%"PRIX16"\n", low_short);
}
const uint16_t val_1 = (1 << 0);
const uint16_t val_2 = (1 << 8);
const uint16_t val_3 = (1 << 1);
const uint16_t val_4 = (1 << 9);
const uint16_t val_5 = (1 << 2);
const uint16_t val_6 = (1 << 10);
const uint16_t val_7 = (1 << 3);
const uint16_t val_8 = (1 << 11);
const uint16_t val_9 = (1 << 4);
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles.Lookup;
public class MethodHandleExample {
private static final MethodHandle barGetter;
private static final MethodHandle barSetter;
static {
Field barField = null;
[18:10:12] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue
[18:10:12] [Client thread/ERROR] [FML]:
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1758.jar)
UCH Forge{11.15.1.1758} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1758.jar)
UCH fluidcraft{1.0} [fluidcraft] (bin)
UCH Waila{1.6.0} [Waila] (Waila-1.6.0-B3_1.8.8.jar)
UCH JEI{2.8.3.39} [Just Enough Items] (jei_1.8.8-2.8.3.39.jar)
UCE rftools{4.22beta25} [RFTools] (rftools-1.8.9-4.22beta25.jar)