Skip to content

Instantly share code, notes, and snippets.

View ademidoff's full-sized avatar
🎯
Focusing

Alex Demidoff ademidoff

🎯
Focusing
View GitHub Profile
### Keybase proof
I hereby claim:
* I am ademidoff on github.
* I am ademidoff (https://keybase.io/ademidoff) on keybase.
* I have a public key whose fingerprint is 30AB 3CC3 F763 49F7 E109 0A2F 5490 45C1 8579 B0EE
To claim this, I am signing this object:
@ademidoff
ademidoff / check-pmm-agent-setup.sh
Created March 15, 2024 17:10
check-pmm-agent-setup.sh
#!/bin/bash
if ! timeout 30 bash -c "until supervisorctl status pmm-update-perform-init | grep -q EXITED; do sleep 2; done"; then
echo "FATAL: failed to set up pmm-agent."
exit 1
fi
@ademidoff
ademidoff / docker-tags.sh
Created December 14, 2023 15:43
List Docker Image Tags
#!/usr/bin/env bash
# Gets all tags for a given docker image.
# Examples:
# retrieve all tags for a single library
# docker-tags "library/redis"
@ademidoff
ademidoff / purge-ami-images
Created December 26, 2022 12:59
Purge AMI images and their snapshots
# get a list of AMI Images in a region
aws ec2 describe-images --owners self --filters "Name=tag:name,Values=PMM2 Server*" --region us-east-1 --output json | jq '.Images' > ~/IMAGES.json
# save just AMI IDs and their snapshot IDs
jq -r '.[] | .ImageId + " " + .BlockDeviceMappings[1].Ebs.SnapshotId' IMAGES.json > IMAGES_AND_SNAPSHOTS.txt
# first deregister the image
for AMI_ID in $(cat IMAGES_AND_SNAPSHOTS.txt); do
if [[ "$AMI_ID" =~ snap-* ]]; then
continue
@ademidoff
ademidoff / index.html
Created April 29, 2022 00:45
Minimalist Thermostat
<div class="t">
<div class="t__inner">
<div class="t__value">
<span class="t__digit" data-temp>-</span><span class="t__digit" data-temp>-</span><span class="t__degree">°</span>
</div>
<button class="t__drag" type="button" data-drag>
<span class="t__sr" data-temp-sr>--</span>
</button>
<svg class="t__arrows" width="256px" height="256px" viewBox="0 0 256 256">
<g fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" opacity="0.2">
@ademidoff
ademidoff / .bash_aliases
Last active August 2, 2021 11:08
My bash aliases
alias ..="cd .."
alias ...="cd ../.."
alias ll="ls -lah"
alias cls="clear"
# docker aliases
alias dps="docker ps -a"
alias dstop="docker stop"
alias dstart="docker start"
alias dpull='docker pull'
@ademidoff
ademidoff / pmm2-install.sh
Created April 1, 2021 12:38
PMM2 install script
#!/bin/sh
# ###############################
# Script to run PMM2
# curl -fsSL https://gist.githubusercontent.com/rnovikovP/91be10dec6bae1111cf104f85fffd5cf/raw/get-pmm2.sh -o get-pmm2.sh ; chmod +x get-pmm2.sh ; ./get-pmm2.sh
#
#################################
set -o errexit
set -o xtrace
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
function drawMouseSpeedDemo() {
var mrefreshinterval = 500; // update display every 500ms
var lastmousex=-1;
var lastmousey=-1;
var lastmousetime;
var mousetravel = 0;
var mpoints = [];
var mpoints_max = 30;
$('html').mousemove(function(e) {
var mousex = e.pageX;
@ademidoff
ademidoff / png.inject.js
Created April 16, 2018 13:19 — forked from lahmatiy/png.inject.js
Solution to inject/fetch a custom data to/from a PNG image
const pngSignature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
const hashKey = 'react-snapshot-hash';
const crcTable = [];
const initialCrc = 0xffffffff;
for (let n = 0; n < 256; n++) {
let c = n;
for (let k = 0; k < 8; k++) {
if (c & 1) {