Skip to content

Instantly share code, notes, and snippets.

@apfelchips
apfelchips / aliexpress_en.js
Last active May 17, 2024 23:40
userscript that forces aliexpress.com to be in english
// ==UserScript==
// @name aliexpress_en
// @version 0.1
// @description always redirect to aliexpress.com and reset the location/language/currency settings. This script pins locale settings cookie. Please clear cookies on all "aliexpress" domains before using this userscript.
// @author @attero@mastodon.social
// @match *://www.aliexpress.com
// @match *://www.aliexpress.com/*
// @match *://*.aliexpress.com/*
// @match *://www.aliexpress.ru
// @match *://www.aliexpress.ru/*
@apfelchips
apfelchips / choco_install.ps1
Last active April 18, 2024 18:01
chocolatey package install script
# allow running: Set-ExecutionPolicy Bypass -Scope Process -Force
# src: https://gist.github.com/apfelchips/792f7708d0adff7785004e9855794bc0
# goal: install all basic tools / pin software with working autoupdate mechanism / specialized stuff is commented out
# misc: Windows Store .appx downloader https://store.rg-adguard.net/
# Check Permissions
if ( -Not( (New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) ){
Write-Error -Message "Script needs Administrator permissions"
@apfelchips
apfelchips / macOS-shortcuts.ahk
Last active April 18, 2024 14:39
First remap modifier keys with sharpkeys; AHK script has to run as Administrator to work on System Windows / Apps running as Administrator; see Watchdog ScheduledTask below, when you do this make sure to remove the inherited file permissions from C:/tools and only allow administrators write access.
;#NoTrayIcon
TraySetIcon("accessibilitycpl.dll","6") ; Keyboard Icon
;#Persistent https://www.autohotkey.com/docs/commands/_Persistent.htm
; legacy? SendMode("Input") ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir(A_ScriptDir) ; Ensures a consistent starting directory.
#SingleInstance force
;#InstallKeybdHook ; see: https://www.autohotkey.com/docs/v1/lib/_HotkeyModifierTimeout.htm
@apfelchips
apfelchips / _bash_script_template.sh
Last active April 16, 2024 15:06
BASH helpers / backports / shims
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
SCRIPT_DIR="$(realpath -- $(dirname -- $0))"
target_user="user"
# Check if the script is already running as the target user
if [ "$(id -u)" -eq "$(id -u "$target_user")" ]; then
echo "Running as $target_user. Continuing with the script." >&2
@apfelchips
apfelchips / user.js
Last active February 26, 2024 04:21
~ 🥖.config🥖firefox🥖Profiles🥖profile.default🥖user.js
// src: https://gist.github.com/apfelchips/f129c8316055e524774d757365267e26
// goal: disable all annoying stuff from firefox and tighten security, but still retain all modern web features
// configure as little as possible to benefit from changeing/hardened defaults by Mozilla
// inspired by:
// https://github.com/pyllyukko/user.js/blob/master/user.js
// https://github.com/ghacksuserjs/ghacks-user.js/blob/master/user.js
// http://kb.mozillazine.org/About:config_entries
// https://gist.github.com/ruilapa/3207798
#!/usr/bin/env python3
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.pem with the following command:
# openssl req -new -x509 -keyout key.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:8443
import http.server
@apfelchips
apfelchips / url-open.sh
Last active February 11, 2024 11:32
url-open.sh - open links contained in .URL and .webloc files in your default browser
#!/bin/bash
# src: https://gist.github.com/apfelchips/001b4ffb22c0578220595623f5546107
# mkdir -p "$HOME/bin" && curl -L "https://git.io/JKGha" -o "$HOME/bin/url-open.sh" && chmod +x "$HOME/bin/url-open.sh" && url-open.sh
install_desktop_file(){
# MimeSpec: https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/data/freedesktop.org.xml.in
# Desktop Entry Spec: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html
echo "creating .desktop entry"
@apfelchips
apfelchips / ~ 🥖bin🥖init_osx.sh
Last active February 10, 2024 16:25
initialize macOS.
#!/bin/bash
# https://www.defaults-write.com
# https://github.com/joeyhoer/starter/tree/master/system
# https://github.com/atweiden/macfiles/blob/master/macos.sh
# https://gist.github.com/ryanpcmcquen/b2e608311f286a4ab3e1
# https://github.com/herrbischoff/awesome-macos-command-line
#
# discover filesystem changes: sudo filemon -c
#
@apfelchips
apfelchips / cdm_fio.sh
Last active February 5, 2024 23:48 — forked from snizovtsev/cdm_fio.sh
Reproducing CrystalDiskMark tests with fio - fixes for https://unix.stackexchange.com/revisions/480191/9
#!/usr/bin/env bash
## This script is based on https://unix.stackexchange.com/revisions/480191/9 and https://gist.github.com/snizovtsev/1e57da4bf1cdae16599d59619600ee07
LOOPS=1 #How many times to run each test
SIZE=32 #Size of each test, multiples of 32 recommended for Q32 tests to give the most accurate results.
WRITEZERO=0 #Set whether to write zeroes or randoms to testfile (random is the default for both fio and crystaldiskmark); dd benchmarks typically only write zeroes which is why there can be a speed difference.
QSIZE=$(($SIZE / 32)) #Size of Q32Seq tests
SIZE+=m
@apfelchips
apfelchips / defaults.duti
Last active December 23, 2023 03:53
set file-associations on macOS: ~ 🥖.config 🥖duti 🥖defaults.duti
# duti settings file
# src: https://gist.github.com/apfelchips/0073cb3e8d186115f590d318998c1025
# mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/duti/" && curl -L "https://git.io/JRtzH" -o "${XDG_CONFIG_HOME:-$HOME/.config}/duti/default.duti"
# duti-apply wrapper: alias duti-apply='duti -v "${XDG_CONFIG_HOME:-$HOME/.config}/duti"'
## duti documentation http://duti.org/documentation.html
## see also: https://github.com/Lord-Kamina/SwiftDefaultApps#readme
# List of MIME Types: