Skip to content

Instantly share code, notes, and snippets.

@iwconfig
iwconfig / README.md
Created May 3, 2024 20:38
Replace text, e.g. secrets, in all files in all git commits using `git filter-branch` and `sed`.

Replace text, e.g. secrets, in all files in all git commits using git filter-branch and sed.

a. Download replace-text.sh

b. Clone the gist repo in the same directory as replace-text.sh

  • using SSH url:

    1. git clone git@gist.github.com:<reponame (hash)>
  • using HTTPS url:

# Normalizes filenames and folders !!
# because fuck you HFS+
# I hate you so
# so much
# Very WIP and probably abandoned because
# I dont feel like fixing the bugs and i'll just
# consider all this as wasted time and redo my
# rsync command with `--iconv=utf-8-mac,utf-8`,
@iwconfig
iwconfig / blocket-bostad-google-maps.user.js
Last active May 2, 2022 11:41
Lägger till en knapp vid kartan, den som visas i Blockets bostadsannonser, för att öppna annonsens address i Google Maps istället
// ==UserScript==
// @name Blocket bostad Google Maps
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author You
// @downloadURL https://gist.github.com/iwconfig/69c74cf7fa57ef9034c0b0dee7fa20e5/raw/blocket-bostad-google-maps.user.js
// @updateURL https://gist.github.com/iwconfig/69c74cf7fa57ef9034c0b0dee7fa20e5/raw/blocket-bostad-google-maps.user.js
// @supportURL https://gist.github.com/iwconfig/69c74cf7fa57ef9034c0b0dee7fa20e5
// @match https://bostad.blocket.se/*
@iwconfig
iwconfig / parse-yaml.sh
Last active December 7, 2021 17:31
parse yaml in pure bash
#!/usr/bin/env bash
ryml () { local IFS=': ' ; read E C ;}
while ryml; do # alternatively: while IFS=': ' read E C; do
case $E in
parent)
parent=${E} ;;
child)
echo ${parent}.${E}: ${C} ;;
@iwconfig
iwconfig / parse-xml.sh
Last active December 7, 2021 17:32
parse xml in pure bash
#!/usr/bin/env bash
rdom () { local IFS=\> ; read -d \< E C ;}
while rdom; do # alternatively: while IFS=\> read -d \< E C; do
case $E in
tvshow|episodedetails)
parent=${E} ;;
title|showtitle|season|episode|plot|aired|thumb)
echo ${parent}.${E}: ${C} ;;
@iwconfig
iwconfig / vafan-biltema-exakt-lagerstatus.user.js
Last active November 17, 2021 12:42
Detta userscript ändrar lagerstatusen på biltemas produktsidor från "(1+)" till "4 st". En jävla skillnad jöh! Biltema visar endast grovt rundade lagersiffror som (1+), (5+), (25+) osv. Det är inte så att den exakta kvantiteten inte finns tillgängligt för användaren, de visar den inte bara. KOM Å KÖP!!!!!!
// ==UserScript==
// @name för helvete biltema ge mig exakt lagerstatus
// @namespace https://github.com/iwconfig
// @version 0.3
// @description 1337 st på lagret istället för (13+)
// @author iwconfig
// @updateURL https://gist.github.com/iwconfig/da9d124977802230732cac0679a3ecfa/raw/vafan-biltema-exakt-lagerstatus.user.js
// @match https://www.biltema.se/*
// @icon https://www.google.com/s2/favicons?domain=biltema.se
// @grant none
@iwconfig
iwconfig / clip_magic.py
Last active November 9, 2019 17:46 — forked from bwagner/clip_magic.py
copy to clipboard ipython magic -- linux only
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%clip hello world
# will store "hello world"
@iwconfig
iwconfig / xdg-open-organized-path.py
Last active February 25, 2019 10:46
Using transmission-remote-gtk, visit the file or folder in your organized library. If item is not (yet?) organized, visit the origin instead (i.e. the 'Downloads' folder).
#!/usr/bin/env python3
# This script is supposed to be used with a remote torrent client,
# such as transmission-remote-gtk. Add this script as a local command
# and it will check if the file/dir has been sorted by filebot and if
# so, open the sorted file path. If not, open the path to the unsorted
# path (i.e. file/dir in 'Downloads' folder). It translates the path
# to correspond to the local mount point (samba share).To parse the
# xml file from filebot I use the untangle package because I'm lazy
# and because it's so easy to use. Install it with pip.
@iwconfig
iwconfig / run-filebot.py
Last active April 2, 2019 15:56
script for transmission to pass downloaded file(s) to filebot and make sure the ownership and permissions are correct
#!/usr/bin/env python3
# Note: on synology, make sure your user is added to transmission
# group so you can have read and write access to the destination
# without sudo.
import subprocess, sys, pwd, grp, os
processed_path = '/tmp/filebot-output-dir'
@iwconfig
iwconfig / callback_server.py
Created January 17, 2019 11:31
simple callback server for oauth2. quits itself once code is retrieved
import threading, webbrowser
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse, parse_qs
class S(BaseHTTPRequestHandler):
def do_GET(self):
code = parse_qs(urlparse(self.path).query)['code'][0]
threading.Thread(target=httpd.shutdown, daemon=True).start()
def callback_server(server_class=HTTPServer, handler_class=S, port=8080):