Skip to content

Instantly share code, notes, and snippets.

@graste
graste / backup-starred.sh
Created June 25, 2022 20:45
Backup all starred repositories from github
# from https://www.commandlinefu.com/commands/view/26576/backup-all-starred-repositories-from-github
GITUSER=$(whoami); curl "https://api.github.com/users/${GITUSER}/starred?per_page=1000" | grep -o 'git@[^"]*' | xargs -L1 git clone
@graste
graste / gnupg_scdaemon.md
Created January 9, 2022 12:45 — forked from artizirk/gnupg_scdaemon.md
OpenPGP SSH access with Yubikey and GnuPG

OpenPGP SSH access with Yubikey and GnuPG

Yubikey, Smart Cards, OpenSC and GnuPG are pain in the ass to get working. Those snippets here sould help alleviate pain.

Yubikey Config under Ubuntu

To reset and disable not used modes on Yubikey you need the ykman program

You can install it using those commands

@graste
graste / intl-compare.php
Created August 6, 2021 19:35
PHP compare strings without diacritics
<?php
// https://twitter.com/derickr/status/1423682080085626885?s=19
$c = new Collator( 'en' );
$c->setStrength( Collator::PRIMARY );
if ( $c->compare( 'Séan', 'Sean' ) == 0 )
{
echo "The same\n";
}
@graste
graste / shrug.txt
Last active April 21, 2021 12:26
¯\_(ツ)_/¯ shrug
¯\_(ツ)_/¯

Aside from estimating it, you can also ask the eMMC itself to tell you how far it has degraded so far (assuming it supports EMMC 5.1 or above).

The JEDEC standard (JESD84-B51) specifies that in the ext_csd field (offset 268-269) bytes indicate the level of type A/B wear. (value 0x1-0xA reflects 10%-100%, 0x0B means lifetime exceeded)

For example, on a typical linux distro, you could run the following script in bash to tell you:

@graste
graste / helm.sh
Last active December 15, 2020 10:55
helm upgrade --install ……… --atomic --timeout 10m --cleanup-on-fail
helm upgrade --install ……… --atomic --timeout 10m --cleanup-on-fail
@graste
graste / install.md
Last active October 9, 2020 11:43
raspberry pi 3b+ w/ pi-hole on Fritzbox

Raspberry Pi 3B+ w/ Pi-Hole

Beware: After using this some time, I installed pi-hole directly on the host pi, as I didn't want to fiddle around to get the actual client IPs in the web UI of the dockerized Pi-Hole (all client IPs were the same because of the NAT/bridge networking). If you don't care about specific group/client rules for your pi-hole, docker setup might still be okay. If you know a solution, post it in the comments (DNSMASQ_LISTENING: all is not the solution).

base system

  • snap install rpi-imager and write Raspberry Pi OS image to sdcard
  • touch ssh in boot partition to enable ssh (see /mnt/)
  • put sdcard into raspberry pi and connect via lan cable to router and power the pi up
  • go to router web ui and make sure the raspberry host always gets the same ip
@graste
graste / rick-roll-content-scraper.js
Created August 19, 2020 20:59 — forked from troyhunt/rick-roll-content-scraper.js
A Cloudflare worker to redirect image requests from dickhead content scraper's site to a Rick Roll
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
async function fetchAndApply(request) {
let response = await fetch(request)
let referer = request.headers.get('Referer')
let contentType = response.headers.get('Content-Type') || ''
if (referer && contentType.startsWith('image/')) {
const fetch = require('node-fetch');
async function run() {
let username = "YOUR USERNAME HERE";
let password = "YOUR APP PASSWORD";
let authBasic = new Buffer(username + ':' + password).toString('base64');
let session = await (await fetch('https://jmap.fastmail.com/.well-known/jmap', {
headers: {
"Authorization": "Basic " + authBasic
}
})).json();
html {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}