Skip to content

Instantly share code, notes, and snippets.

{
"datasource": {
"type": "prometheus",
"uid": "l-jz8T47k"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
@andrew-d
andrew-d / resolve.sh
Created November 18, 2022 02:52
Extremely hacky set of scripts/instructions to fetch all user profiles from a Twitter archive
#!/bin/bash
set -euo pipefail
main() {
local url
url="$(jq -rc .response.data.url < "$1")"
if [[ -z "$url" ]]; then
echo "EMPTY: $1"
return
#include <stdio.h>
#include <stdint.h>
int rdrand(uint32_t *out) {
char rc;
unsigned int val;
__asm__ volatile(
"rdrand %0 ; setc %1"
: "=r" (val), "=qm" (rc)
@andrew-d
andrew-d / only-missing.nix
Created February 10, 2020 06:41
Completely untested Nix builder for icon theme with only "image-missing.png"
{ stdenv
, pkgs
, gnome3
, hicolor-icon-theme
}:
stdenv.mkDerivation {
pname = "only-missing";
version = "0.0.1";
@andrew-d
andrew-d / set-power-uuid.sh
Created May 27, 2019 21:42
Bash script to set INT3400 Thermal zone power profile
#!/bin/bash
set -eu
die() {
echo "$1" >&2
exit 1
}
@andrew-d
andrew-d / update-gvisor-deps.py
Created December 10, 2018 09:06
Very WIP script to update dependencies for gvisor in Nix
#!/usr/bin/env python
from __future__ import print_function
import re
import sys
import json
import random
import shutil
import tempfile
@andrew-d
andrew-d / cpp-file-macro.patch
Created October 28, 2018 08:02
Testing patch for `cpp` in Nixpkgs that removes store paths from the __FILE__ macro
diff --git i/libcpp/macro.c w/libcpp/macro.c
index c2515534504..ab593251def 100644
--- i/libcpp/macro.c
+++ w/libcpp/macro.c
@@ -288,8 +288,8 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node,
case BT_FILE:
case BT_BASE_FILE:
{
- unsigned int len;
- const char *name;
@andrew-d
andrew-d / int3400-more-uuids.patch
Created September 10, 2018 02:59
Thinkpad X1 Carbon thermal throttling patches for Linux
commit 0000000000000000000000000000000000000000
Author: Andrew Dunham <redacted>
Date: Mon Jan 01 00:00:00 2018 +0100
Apply https://patchwork.kernel.org/patch/8756801/
Original commit message:
Added AdaptivePerformance, EmergencyCallMode,
PassivePolicy2, PowerBoss, VirtualSensor
@andrew-d
andrew-d / nix2-arm-build.sh
Last active February 10, 2021 11:53
Helpful script to build a copy of Nix 2.0 for ARM (arm-linux-gnueabihf)
#!/bin/bash
# USAGE: docker run -t -i --rm -v $PWD:/out ubuntu:16.04 /out/build.sh
set -eu
# Install
install_packages() {
apt-get update && apt-get upgrade -yy
@andrew-d
andrew-d / freeotp-redisplay.py
Created September 21, 2016 07:35
Read a FreeOTP tokens.xml file and display the entries as QR codes
#!/usr/bin/env python
from __future__ import print_function
import base64
import ctypes
import json
import subprocess
import sys
import xml.etree.ElementTree as ET