Skip to content

Instantly share code, notes, and snippets.

View timotgl's full-sized avatar

Timo Taglieber timotgl

View GitHub Profile
@timotgl
timotgl / uninstall-logitech-ghub.sh
Created April 4, 2022 12:15
How to fully uninstall Logitech G HUB on macOS via terminal/command line
# How to fully uninstall Logitech G HUB on macOS via terminal/command line
# Tested on macOS version 12.3.1 (21E258) Monterey in April 2022
# with Logitech G HUB version 2022.3.242300 (released on 2022-03-22) installed.
# 1. Make sure "Logitech G HUB" itself is not running. If it is, quit it.
# 2. Open "Activity Monitor" and force-quit all processes named "lghub*".
# 3. Delete system-wide files
sudo rm -rf /Applications/lghub.app
@timotgl
timotgl / sparer-pauschbetrag-ausnutzen.js
Created December 25, 2021 14:24
Calculate optimal amount of ETF shares to sell to take advantage of the german "Sparer-Pauschbetrag" (Node.js)
// Optimal amount of profit (in EUR) to be gained from ETF sale
const optimalProfit = 1144.29
// Sale price (bid) of one share of the ETF in EUR
const bidPrice = 103.74;
// Amount of shares I own in chronologically ascending order.
// (first element = oldest shares)
const shares = [
// amount, share price at the time in EUR
@timotgl
timotgl / compareArrays.js
Created November 13, 2019 08:43
Compare two arrays (intersection, difference)
const arr1 = ["100730651975","100727767835","100731535949","100734119022","100731395492","100730978223","100723043671","100729513754","100731428590","100730087084","100731202777","100730337035","100731122761","100730787720","100730178609","100734126093","100731453507","100730654591","100730236974","100734127056"];
const arr2 = ["100730178609", "100730654591", "100730651975", "100730087084", "100727767835", "100731535949", "100731395492", "100723043671", "100730978223", "100729513754", "100731202777", "100731428590", "100731122761", "100730787720", "100731453507", "100730236974", "100734127056"];
const compareArrays = (a, b) => {
const setOfA = new Set(a);
const setOfB = new Set(b);
const intersection = new Set(); // elements in both A and B
const differenceB = new Set(); // elements in B but not in A
@timotgl
timotgl / hapiAmbiguousBearerTokenAuthScheme.js
Created May 29, 2017 16:19
How to combine two hapi.js authentication strategies which both use a bearer token from the authorization request header (hapi auth scheme for ambiguous token). ES6 with async/await.
const Boom = require('boom');
const headerPattern = /^Bearer (.+)/;
const testAuth = (request, strategy) => new Promise((resolve, reject) => {
request.server.auth.test(strategy, request, (error, credentials) => {
if (error === null) {
resolve(credentials);
} else {
reject(error);
@timotgl
timotgl / uninstall-razer-synapse.sh
Last active April 24, 2024 15:20
How to fully uninstall Razer Synapse 2 on OS X (10.11-10.13) (El Capitan, Sierra, High Sierra) without using Razer's official uninstall tool
# How to uninstall Razer Synapse 2 ( https://www.razerzone.com/synapse-2 )
# on OS X (10.11-10.13) (El Capitan, Sierra, High Sierra)
# without using Razer's official uninstall tool.
# Tested on OS X 10.11.5 in July 2016.
# Edited with additional steps for later OS X versions,
# contributed by commenters on this gist.
# Step 1: In your terminal: stop and remove launch agents
launchctl remove com.razer.rzupdater
@timotgl
timotgl / curryandcall.js
Created March 7, 2016 18:45
curryAndCall as a prototype method for Functions
Function.prototype.curryAndCall = function () {
var args = Array.prototype.slice.call(arguments);
var curry = function (originalFunc, collectedArgs) {
return function () {
var args = Array.prototype.slice.call(arguments);
if (args.length + collectedArgs.length >= originalFunc.length) {
return originalFunc.apply(originalFunc, collectedArgs.concat(args));
} else {
return curry(originalFunc, collectedArgs.concat(args));
@timotgl
timotgl / log_pointer_events.js
Last active September 1, 2015 11:45
Log all pointer events (mouse and touch gestures)
(function () {
var span, eventTypes = [
'click', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout',
'touchstart', 'touchend', 'touchmove', 'touchcancel', 'touchleave'
];
var header = document.querySelector('#header .header-wrap');
// Log a single gesture to the console and show it at the top of the page.
function logEvent (event) {