Skip to content

Instantly share code, notes, and snippets.

View CapacitorSet's full-sized avatar

Giulio Muscarello CapacitorSet

View GitHub Profile
@CapacitorSet
CapacitorSet / scheduler.py
Created August 17, 2024 19:21
Logica di scheduling per Markov News
import itertools
from ortools.sat.python import cp_model
settimana = ("lun", "mar", "mer", "gio", "ven", "sab", "dom")
slots = ("7:00", "9:00", "12:00", "16:00", "19:30")
categorie = (
"news",
"trucchi",
"accadde",
"proverbi",
@CapacitorSet
CapacitorSet / README.md
Created August 5, 2024 07:54
Listing credentials used in Jenkins

If you need an overview of what credentials Jenkins uses to clone repositories, you'll find that the Jenkins API is a bit convoluted. This is what I did instead:

  1. From a Windows machine, access Jenkins as a UNC share and dump its contents:
Get-ChildItem -Path \\my-jenkins-instance\*\config.xml | ForEach-Object { $targetPath = "C:\Users\me\Desktop\jenkins\" + $_.Directory.Name + "_" + $_.Name;  $_ | Copy-Item -Destination $targetPath -Force }

The output will be a zip file with XML files containing job configurations. The filename contains the project name (as that information is not otherwise contained in the XML file).

@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.