Skip to content

Instantly share code, notes, and snippets.

View purpleidea's full-sized avatar

James purpleidea

View GitHub Profile
# ssh-keygen overwrites the .pub portion without asking
# i guess this is fine, but it surprised me
[root@fedora ~]# /usr/bin/ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''
Generating public/private rsa key pair.
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
@purpleidea
purpleidea / gzip.go
Created September 4, 2024 01:10
Simple golang gzip compression
// Thanks purpleidea for putting this together!
// Why isn't this the default example in the golang docs?
package main
import (
"compress/gzip"
"fmt"
"io"
"os"
)
@purpleidea
purpleidea / toggle_jobs.bash
Created July 3, 2024 01:06 — forked from sebastiancarlos/toggle_jobs.bash
Toggle between the last two jobs in Bash by pressing "Ctrl-Z Ctrl-Z" (Or toggle between the shell and your single job by pressing "Ctrl-Z")
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/shorts/0zx4uSBUt_k
# Add this somewhere in your ~/.bashrc
# Use bash-preexec.sh (https://github.com/rcaloras/bash-preexec) to:
# - disable the Ctrl-Z keybinding before printing the prompt
# - enable the Ctrl-Z keybinding before executing a command
#
@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