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 / 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 / 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 / config.org
Created December 23, 2019 18:41 — forked from dysinger/config.org
My important dotfiles as an org-mode document

Configuration

Setup

git clone \
    https://github.com/chriskempson/base16-shell.git \
// Mgmt
// Copyright (C) 2013-2018+ James Shubin and the project contributors
// Written by James Shubin <james@shubin.ca> and the project contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@purpleidea
purpleidea / exit_notify.go
Created February 20, 2019 11:02 — forked from pmalmgren/LICENSE
Go proc connector example, detects when a process exits
package main
import (
"bytes"
"encoding/binary"
"fmt"
"golang.org/x/sys/unix"
"os"
"syscall"
)