Skip to content

Instantly share code, notes, and snippets.

View adamhotep's full-sized avatar

Adam Katz adamhotep

View GitHub Profile
@adamhotep
adamhotep / DOM3D-1line.js
Last active March 27, 2024 16:34 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
(()=>{const SHOW_SIDES=false;const COLOR_SURFACE=false;const COLOR_RANDOM=false;const COLOR_HUE=190;const MAX_ROTATION=180;const THICKNESS=20;const DISTANCE=10000;function getRandomColor(){const hue=Math.floor(Math.random()*360);const saturation=50+Math.floor(Math.random()*30);const lightness=40+Math.floor(Math.random()*30);return`hsl(${hue},${saturation}%,${lightness}%)`;}const getDOMDepth=element=>[...element.children].reduce((max,child)=>Math.max(max,getDOMDepth(child)),0)+1;const domDepthCache=getDOMDepth(document.body);const getColorByDepth=(depth,hue=0,lighten=0)=>`hsl(${hue},75%,${Math.min(10+depth*(1+60/domDepthCache),90)+lighten}%)`;const body=document.body;body.style.overflow="visible";body.style.transformStyle="preserve-3d";body.style.perspective=DISTANCE;const perspectiveOriginX=(window.innerWidth/2);const perspectiveOriginY=(window.innerHeight/2);body.style.perspectiveOrigin=body.style.transformOrigin=`${perspectiveOriginX}px${perspectiveOriginY}px`;traverseDOM(body,0,0,0);document.addEventListen
#!/bin/bash
# This is a wrapper that adds one option to rgain3's replaygain script
# replaygain-wrapper version 0.1, Copyright (C) 2020+ by Adam Katz <@adamhotep>
#
# 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 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@adamhotep
adamhotep / xcf2jpg.sh
Created December 2, 2017 20:25
xcf2jpg
# make a "jpg" directory
# loop on each file ending in ".xcf" calling each iteration "$image"
# convert (an ImageMagick tool, `apt install imagemagick`) the image
# the second argument removes the trailing ".xcf" and adds ".jpg"
# which tells `convert` that we want to change the format
# (the second argument also places the converted file into the "jpg" dir)
mkdir jpg
for image in *.xcf; do convert "$image" "jpg/${image%.xcf}.jpg"; done
@adamhotep
adamhotep / waitForKeyElements.js
Last active March 18, 2024 06:00 — forked from BrockA/waitForKeyElements.js
A utility function, for userscripts including Greasemonkey, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Original: https://gist.github.com/BrockA/2625891
Non-jQuery version by: Adam Katz,
https://gist.github.com/adamhotep/7c9068f2196326ab79145ae308b68f9e
License: CC BY-NC-SA 4.0 (*not* GPL-compatible)
changes made by Adam Katz (tracked by adamhotep's github gist) are
also licensed GPL v2+ (but note the CC BY-NC-SA prevents commercial use)
License via https://gist.github.com/BrockA/2625891#gistcomment-1617026
@adamhotep
adamhotep / ubuntu-xenial.list
Created February 18, 2017 23:56
ubuntu xenial sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
# ... it's just a matter of apt full-upgrade then do-release-upgrade
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
@adamhotep
adamhotep / disrpm
Created July 7, 2016 01:46
disrpm / undeb, a small script to extract/unzip/unpack/unarchive *.rpm or *.deb packages
#!/bin/bash
# disrpm / undeb
# small (bourne) shell script to extract/unzip/unpack/unarchive *.rpm or *.deb packages.
# uses sh, sed, hexdump|od, gzip|bzip2, dd, cpio.
# released under the Gnu General Public License (GPL)
# (c) bjdouma@xs4all.nl
######################
VER="v1.5, october 2004"
ME="${0##*/}"
@adamhotep
adamhotep / longopts2getopts.sh
Last active November 29, 2023 23:22
POSIX shell: support long options by converting them to short options
# a refinement of https://stackoverflow.com/a/5255468/519360
# see also my non-translating version at https://stackoverflow.com/a/28466267/519360
# translate long options to short
reset=true stopped=""
for opt in "$@"; do
if [ -n "$reset" ]; then
unset reset
set -- # reset the "$@" array so we can rebuild it
fi
@adamhotep
adamhotep / conf.hexdump
Last active August 29, 2015 14:14 — forked from sygo/conf.hexdump
Generic Colouriser tweaks
# offset
regexp=^[0-9a-fA-F]{1,8}\b
colours=bold red
======
# Hex Bytes %_p
regexp=\|.+\|\s*$
colours=cyan
======
# Hex bytes
#regexp=([0-9a-fA-F]{1,2 })+
@adamhotep
adamhotep / gnome-keyring-query.c
Last active March 5, 2019 03:58
Simple command-line interface to GNOME keyring
/*
* gnome-keyring-query, for simple command-line interactions with gnome-keyring.
*
* To compile and install:
*
* sudo apt-get install libgnome-keyring-dev libglib2.0-dev
* gcc `pkg-config --cflags --libs gnome-keyring-1 glib-2.0` -o gnome-keyring-query gnome-keyring-query.c
* chmod +x gnome-keyring-query
* sudo cp -p gnome-keyring-query /usr/local/bin/
*
@adamhotep
adamhotep / keybase.md
Last active August 29, 2015 13:59
Keybase ID

Keybase proof

I hereby claim:

  • I am adamhotep on github.
  • I am khopesh (https://keybase.io/khopesh) on keybase.
  • I have a public key whose fingerprint is F8EC 5C50 92BA 06CA 8DCA 8BA1 8EBA 15BA F4AD 9292

To claim this, I am signing this object: