Skip to content

Instantly share code, notes, and snippets.

View sempostma's full-sized avatar

Sem Postma sempostma

View GitHub Profile
@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

@sempostma
sempostma / get-urls-from-chrome-debugger.js
Created July 22, 2019 10:41
Get urls from chrome debugger
var URLs = UI.panels.network._networkLogView._dataGrid._rootNode._flatNodes.map(n => n._request._url).filter((v, i, a) => a.indexOf(v) === i)
copy(URLs.join('\n'));
@sempostma
sempostma / cordova-download.js
Last active December 26, 2023 15:12
Downloading/Saving/Opening files with Cordova in javascript and polyfill the achor's download attribute for android webview.
"use strict";
if (window.cordova && cordova.platformId !== "browser") {
document.addEventListener("deviceready", function () {
document.addEventListener("click", function (e) {
var elem = e.target;
while (elem != document) {
if (elem.tagName === "A" && elem.hasAttribute("download")) {
e.preventDefault();
@sempostma
sempostma / Final Export.jsx
Last active December 8, 2023 01:44
Export Illustrator document to a buch of different file formats and resolutions. File formats include: .ai, .pdf, .png, .jpg and .svg. Installation: Copy this file to your illustrator scripts folder (For windows: C:\Program Files\Adobe\Adobe Illustrator CC 2019\Presets\<your locale>\Scripts) (For Mac: Applications/Adobe Illustrator CC/Presets/<y…
/**
* Author: Sem Postma (sem@esstudio.site)
* Name: Final Export
* License: MIT
*
* Installation: Copy this file to your illustrator scripts folder:
* For windows: C:\Program Files\Adobe\Adobe Illustrator CC 2019\Presets\<your locale>\Scripts
* For Mac: Applications/Adobe Illustrator CC/Presets/<your locale>/Scripts
*
* Usage: File->Scripts->Final Export
@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;
// (c) 2018 Sem Postma
// This code is licensed under MIT license
(function () {
var endScopeObj = {};
window.obj2xml = function (obj, opt) {
if (!opt) opt = {};
var rootName = opt.rootName || 'root';
var declaration = opt.declaration === 'auto' ? '<?xml version="1.0" encoding="utf-8"?>' : opt.declaration;
var indentation = opt.indentation || 0;
[
{
"key": "No Event",
"hidUsagePage": 7,
"hidUsageID": 0,
"ps2Set1Make": [
null
],
"ps2Set1Break": [
null
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(', ')})`