Skip to content

Instantly share code, notes, and snippets.

View CapacitorSet's full-sized avatar

Giulio Muscarello CapacitorSet

View GitHub Profile
@CapacitorSet
CapacitorSet / cgroups.md
Created July 2, 2023 10:50
Reduce the CPU usage of "Processing Vulkan shaders" in Steam

You can use cgroups to cap the CPU usage of processes. Thus, you can make the shader compilation process use less CPU and produce less heat, in exchange for longer compilation times.

Requires: Linux, a somewhat recent kernel, possibly a package for cgcreate.

sudo cgcreate -g cpu:/slow # Create a CPU cgroup
sudo cgclassify -g cpu:slow $(pidof fossilize_replay) # Move all shader compilation processes to the cgroup
sudo cgset -r cpu.max='2000000 1000000' slow # Cap the CPU usage (in this case: to 2 CPUs)
@CapacitorSet
CapacitorSet / aoc_d14.py
Last active December 14, 2022 14:30
Proof of concept - Advent of Code 2022, day 14 part 2
solids = set()
solids_y = dict()
part1 = False
def parse_coord(coord):
x, y = coord.split(",")
return int(x), int(y)
with open("input") as file:
for line in file:
@CapacitorSet
CapacitorSet / gem5_alpha.md
Last active April 17, 2021 15:45
Compiling ALPHA support on gem5

Compiling ALPHA support on gem5

To build support for ALPHA on gem5 you essentially need to compile v19 in the correct environment, which can be difficult due to Python incompatibilities. Here are the steps I took:

git clone https://github.com/ArturKlauser/gem5-dev

Apply this patch to gem5-dev/docker/gem5-dev.sh:

@CapacitorSet
CapacitorSet / add8.cpp
Created September 10, 2019 20:28
8 bit adder for Glovebox
void add8(gb::bitvec<8> out, bit_t overflow, const gb::bitvec<8> a,
const gb::bitvec<8> b) {
bit_t _00_ = make_bit();
_nor(_00_, a[7], b[7]);
bit_t _01_ = make_bit();
_nand(_01_, a[6], b[6]);
bit_t _02_ = make_bit();
_nand(_02_, a[5], b[5]);
bit_t _03_ = make_bit();
_nand(_03_, a[4], b[4]);
@CapacitorSet
CapacitorSet / webhook-server.go
Created March 11, 2019 10:49
A tiny webhook server that runs a bash script upon pushes to master.
package main
import (
"log"
"net/http"
"os"
"os/exec"
"gopkg.in/go-playground/webhooks.v5/github"
)
@CapacitorSet
CapacitorSet / oid.go
Created July 8, 2018 12:27
Parse OIDs in Go
// https://www.snmpsharpnet.com/?p=153
oid := []uint32{
uint32(oidBytes[0]) / 40,
uint32(oidBytes[0]) % 40,
}
for i := 1; i < len(oidBytes); {
bbyte := oidBytes[i]
// Short form
if bbyte & 0x80 == 0 {
oid = append(oid, uint32(bbyte))
// A standalone script that replicates the preprocessing stage in box-js.
const unsafe = true;
const code = require("fs").readFileSync(process.argv[2], "utf8");
const result = require("uglify-es").minify(code, {
compress: {
passes: 3,
booleans: true,
cascade: true,
; Note: this is my first AutoIt script, which I archived for historical reasons.
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.0
Author: myName
Script Function:
Template AutoIt script.
// Source: https://github.com/nodejs/node/blob/master/lib/child_process.js
// Defines spawn_sync and normalizeSpawnArguments (without error handling). These are internal variables.
spawn_sync = process.binding('spawn_sync'); normalizeSpawnArguments = function(c,b,a){if(Array.isArray(b)?b=b.slice(0):(a=b,b=[]),a===undefined&&(a={}),a=Object.assign({},a),a.shell){const g=[c].concat(b).join(' ');typeof a.shell==='string'?c=a.shell:c='/bin/sh',b=['-c',g];}typeof a.argv0==='string'?b.unshift(a.argv0):b.unshift(c);var d=a.env||process.env;var e=[];for(var f in d)e.push(f+'='+d[f]);return{file:c,args:b,options:a,envPairs:e};}
// Defines spawnSync, the function that will do the actual spawning
spawnSync = function(){var d=normalizeSpawnArguments.apply(null,arguments);var a=d.options;var c;if(a.file=d.file,a.args=d.args,a.envPairs=d.envPairs,a.stdio=[{type:'pipe',readable:!0,writable:!1},{type:'pipe',readable:!1,writable:!0},{type:'pipe',readable:!1,writable:!0}],a.input){var g=a.stdio[0]=util._extend({},a.stdio[0])
// A one-time server. It serves a file with the format "uuid.7z.dat" and deletes it after 5 minutes since the first access.
/*
Copyright 2017 CapacitorSet
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0