Skip to content

Instantly share code, notes, and snippets.

View sempostma's full-sized avatar

Sem Postma sempostma

View GitHub Profile
@sempostma
sempostma / MoveWorkshopItemsToGameFolder.bat
Created October 15, 2023 20:11
Move RailWorks Steam workshop items to the RailWorks folder.
@ECHO off
SETLOCAL EnableDelayedExpansion
pushd %CD%
FOR /F "tokens=2* skip=2" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 24010" /v "InstallLocation"') DO set RW_INSTALL_LOCATION=%%b
ECHO.
ECHO Make sure you have 7zip installed!
ECHO Run this script as administrator, otherwise files may not be created/moved.
ECHO.
@sempostma
sempostma / filesystem-treemap.js
Created March 23, 2023 15:13
Create a treemap of largest files in a folder recursively
const { exec } = require('child_process')
const fs = require('fs')
const path = require('path')
let lastDir = ''
let currDir
const recurse = async (dir, filenames, writeStream) => {
currDir = dir
const stats = filenames.map(async filename => {
@sempostma
sempostma / migrate_hikashop_cli.php
Created November 19, 2022 22:59
This script is provides without any guarantees. Create a backup of your site first! Most likely you will need to make manual changes for everything to work. This is just a start so you can get the bulk of all the data moved to your new site.
<?php
$counter = 0;
$flags = array();
$db1;
$db2;
$db1_table_prefix = '';
$db2_table_prefix = '';
$truncate = false;
$truncate_user_groups = false;
$batch_size = 1000;
[
{
"key": "No Event",
"hidUsagePage": 7,
"hidUsageID": 0,
"ps2Set1Make": [
null
],
"ps2Set1Break": [
null
@sempostma
sempostma / windows-terminal-with-powerline.md
Last active April 13, 2024 01:48
Windows Terminal with Powerline

Windows Terminal with Powerline

Result

Install the Windows Terminal App

Install the Windows Terminal from the Microsoft Store. This allows you to always be on the latest version.

Powerline setup

var gradient = ["#11a7b6", "#29b827", "#f8bf00", "#f66d31", "#ef66a0"]
var parts = gradient.map((x, i, self) => `${x} ${i / self.length * 100}%, ${x} ${(i + 1) / self.length * 100}%`)
var result = `linear-gradient(90deg, ${parts.join(', ')})`
@sempostma
sempostma / inline-styles.js
Created June 28, 2020 15:36
Convert external styles to inline styles
var proto = Element.prototype;
var slice = Function.call.bind(Array.prototype.slice);
var matches = Function.call.bind(
proto.matchesSelector ||
proto.mozMatchesSelector ||
proto.webkitMatchesSelector ||
proto.msMatchesSelector ||
proto.oMatchesSelector
);
ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012
gcc -print-search-dirs | sed '/^lib/b 1;d;:1;s,/[^/.][^/]*/\.\./,/,;t 1;s,:[^=]*=,:;,;s,;,; ,g' | tr \; \\012
@sempostma
sempostma / invert_pdf.sh
Last active June 10, 2020 12:52
PDF Contrast
magick mogrify -resize 3000 -density 300 -background white -channel RGB -negate -flatten -path output *.pdf
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Programmer Benchmark</title>
</head>
<body>