Skip to content

Instantly share code, notes, and snippets.

View birjj's full-sized avatar

Johan Fagerberg birjj

View GitHub Profile
@birjj
birjj / calendar.svg
Last active November 12, 2023 13:59
Laser cut models
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@birjj
birjj / merge-kubeconfigs
Last active March 5, 2023 19:44
Merge Windows kubectl config into WSL config
#!/usr/bin/env zsh
# Written for ZSH - if you use another shell, adapt as needed
# Copies the kubectl config from the default Windows location, converts it to a Unix-compatible format,
# merges it with existing configs and saves it to the default Unix location
# copy over the kubeconfig from Windows, replacing Windows paths with WSL paths
WindowsUser='johan'
WindowsConfig=$(cat "/mnt/c/Users/$WindowsUser/.kube/config")
re='(.*?)([A-Z]:\\[a-zA-Z\\ \.]+)(.*)'
@birjj
birjj / _ipv4-cidr.js
Last active February 2, 2023 16:25
CIDR helpers for our Azure DevOps wiki
/** Class that represents an IPv4 CIDR range (or a single IP, i.e. a CIDR range with /32 mask) */
class IPv4CIDR {
ip = 0n;
mask = 0n;
constructor(ip, mask = 32) {
this.mask = ~BigInt("0b"+([...new Array(32 - mask)].fill("1").join("") || "0"));
this.ip = BigInt("0b"+(ip.split(".").map((v,i) => (+v).toString(2).padStart(8, "0")).join("")));
}
get start() { return this.ip & this.mask; }
// ==UserScript==
// @name /r/EU4 styles
// @namespace https://github.com/birjolaxew/r-EU4-styles
// @version 1.0
// @description Add custom CSS style to /r/EU4
// @author birjolaxew
// @match https://www.reddit.com/r/eu4/*
// @run-at document-body
// @grant none
// ==/UserScript==
@birjj
birjj / source_engine_ropes.md
Last active September 27, 2018 17:41
How the Source engine simulates rope

How the Source engine simulates rope

approximate measurements of rope in the Source engine are available here
this will look at non-solid ropes that aren't affected by wind
a JS implementation is available

Ropes in the Source engine span from a move_rope to a keyframe_rope (or from a keyframe_rope to a keyframe_rope). In both cases two values are relevant for the rope simulation: slack and subdivision.

Slack indicates how low the rope hangs. It is simply a scalar value (usually in the range of a few hundred) that is added to the length of the rope when it is initialized [1].

@birjj
birjj / DataGenerator.java
Created April 4, 2018 09:25
Data generator
package data_generator;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
INSERT INTO Tournaments (name, prize, date) VALUES
('Intel Extreme Masters XII - World Championship', 250000, '2018-02-27'),
('StarLadder & i-League StarSeries Season 4', 130000, '2018-02-17'),
('ELEAGUE Major: Boston 2018', 500000, '2018-01-12'),
('Esports Championship Series Season 4 - Finals', 250000, '2017-12-15'),
('ESL Pro League Season 6 - Finals', 225000, '2017-12-05');
INSERT INTO Teams (name, country) VALUES
('Astralis', 'DK'),
('mousesports', 'EU'),
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@birjj
birjj / colored.png
Last active February 8, 2018 21:43
Simple Icons contribution guidelines images
colored.png
class CNF:
def __init__(self, filename):
self.file = open(filename, "w")
self.clauses = []
self.variables = 0
def add(self, clause):
# takes a list of variables, adds it as a clause to our output
#print("Adding clause", clause)
self.clauses.append(" ".join([str(x) for x in clause])+" 0\n")