Skip to content

Instantly share code, notes, and snippets.

View purpleidea's full-sized avatar

James purpleidea

View GitHub Profile
@purpleidea
purpleidea / killbutmakeitlooklikeanaccident.sh
Created July 18, 2022 15:17 — forked from moyix/killbutmakeitlooklikeanaccident.sh
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@purpleidea
purpleidea / install-old-firefox.sh
Created June 20, 2022 04:17 — forked from bmaupin/install-old-firefox.sh
Temporarily install old version of Firefox for testing
# Firefox 33 was the last version to support SSLv3 (https://blog.mozilla.org/security/2014/10/14/the-poodle-attack-and-the-end-of-ssl-3-0/)
#firefox_version=33.0
# Firefox 51 was the last version to support NPAPI plugins (e.g. Java) (https://support.mozilla.org/en-US/kb/npapi-plugins)
#firefox_version=51.0
# Firefox 56 was the last version to support XPCOM- and XUL-based add-ons (https://blog.mozilla.org/addons/2016/11/23/add-ons-in-2017/)
#firefox_version=56.0
wget https://ftp.mozilla.org/pub/firefox/releases/$firefox_version/linux-x86_64/en-US/firefox-$firefox_version.tar.bz2
tar -xvf firefox-$firefox_version.tar.bz2
mv firefox firefox-$firefox_version
@purpleidea
purpleidea / falsehoods-programming-time-list.md
Created October 28, 2021 21:14 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@purpleidea
purpleidea / output.md
Created October 18, 2021 05:46 — forked from jordansissel/output.md
Climate controllers with local network access, according to Home Assistant
% git clone --depth 1 https://github.com/home-assistant/core

Find "climate" support, then look for components with iot_class matching "local"

% grep -l climate */const.py | awk -F/ '{print $1}' | xargs -n1 sh -c 'jq .iot_class $1/manifest.json | grep -q local && echo "* https://www.home-assistant.io/integrations/$1"' -
@purpleidea
purpleidea / unifi_wifi.sh
Created October 18, 2021 03:14 — forked from jcconnell/unifi_wifi.sh
A bash script to enable, disable or check the status of a UniFi WiFi network.
#!/bin/bash
unifi_username=USERNAME
unifi_password='PASSWORD'
unifi_controller=https://EXAMPLE.COM:8443
wifi_id=YOUR_WIFI_ID
cookie=/tmp/cookie
curl_cmd="curl -s -S --cookie ${cookie} --cookie-jar ${cookie} --insecure "
@purpleidea
purpleidea / gist:74354dd7fa5afd5005e2525618cea47e
Created August 26, 2021 03:47
horrible-gnome-alt-tab-off-by-one-regression
Finally reproduced a horrible GNOME shell regression that's been plaguing me and a bunch of friends for a while now.
Step 1)
Open up gedit. Put it on workspace 1 (for example, doesn't matter)
Step 2)
Open up firefox or some other app and put it on workspace 2. Also open up calculator on the same workspace.
Step 3)
Hit some shortcut to open up a new gedit window.
@purpleidea
purpleidea / README.md
Created March 5, 2021 01:30 — forked from danbst/README.md
[Linux] [Firefox] Open link in browser, which is in current workspace

I use separate Firefox profiles for work and personal stuff. To distinguish those I place them on different workspaces.

  • Workspace 0: firefox --no-remote -P MyJob
  • Workspace 1: firefox --no-remote -P default

I have also company Slack on Workspace 0. Which usually contains links to some work stuff.

The problem

@purpleidea
purpleidea / frebib.mcl
Created March 2, 2021 17:37
automatic grouping example
# this doesn't work of course...
docker:container "mgmt-nginx" {
volumes => {
"/steve" => struct{type => "volume", source => "steve",},
"/tmp" => struct{type => "tmpfs",},
},
}
# but these three *could* work!
docker:container "mgmt-nginx" {
@purpleidea
purpleidea / main.go
Created February 27, 2021 20:49 — forked from paulzhol/main.go
golang.org/x/sys/unix.Signalfd usage example (Linux)
// +build linux
package main
import (
"flag"
"log"
"os"
"runtime"
"time"
@purpleidea
purpleidea / find
Created February 24, 2021 23:09
ifind
# case insensitive find, eg: ifind <pattern>[ dir1[ dir2[ dirN...]]]
function ifind() {
pat="$1"
shift
if [ "$#" = "0" ]; then
set "."
fi
for d in "$@"; do
#find "$d" -iname "*$pat*" # normal
find "$d" -iname "*$pat*" 2> /dev/null # hide can't read errors