Skip to content

Instantly share code, notes, and snippets.

@lrewega
lrewega / docker-list-parts.sh
Created April 22, 2020 21:52
spelunking for files in a docker image
REPO=whatever/youwant; curl -sSL -H "Authorization: Bearer $(curl -sSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${REPO}:pull" | jq -r .token)" -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' "https://registry-1.docker.io/v2/${REPO}/manifests/latest" | jq -r '.layers[].digest' | while read digest; do curl -sSL -H "Authorization: Bearer $(curl -sSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${REPO}:pull" | jq -r .token)" "https://registry-1.docker.io/v2/${REPO}/blobs/${digest}" | tar -tz | sed "s/^/${digest##*:}\t/"; done
@lrewega
lrewega / manifest.json
Created January 25, 2019 22:45
chrome theme
{
"manifest_version": 3,
"version": "1",
"name": "theme",
"description": "a theme for chrome",
"theme": {
"colors": {
"frame": [ 151, 210, 92 ],
"frame_inactive": [ 204, 233, 175 ]
}
@lrewega
lrewega / disable-slack-ligatures-osx.sh
Created November 30, 2018 00:17
Disable Slack ligatures on OS X
#!/bin/sh
cat >>/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js <<"EOF"
document.addEventListener('DOMContentLoaded', function() {
$(`<style>* { font-variant-ligatures: none;}</style>`).appendTo("head");
});
EOF
@lrewega
lrewega / hubble-icons.sh
Created October 4, 2018 20:07
image to trimmed transparent png and favicon
curl https://upload.wikimedia.org/wikipedia/commons/3/3f/HST-SM4.jpeg |
convert - -alpha set -bordercolor black -border 1 -fill none -fuzz 8% -draw "color 0,0 floodfill" -shave 1x1 -trim -write hst.png \
-background none -gravity center -resize 64x64 -extent 64x64 -define icon:auto-resize=64,48,32,16 favicon.ico
package main
import (
"database/sql"
"flag"
"fmt"
"math/rand"
"os"
"os/exec"
"time"
#!/bin/bash
# html-to-pdf.sh wraps Chrome's headless PDF printing, mostly to enable WSL to use Chrome on
# Windows. I'm sorry.
WINDOWS_USER=${WINUSER:-Luke}
WSL_DRIVE=${WSL_DRIVE:-c}
WINDOWS_DRIVE=${WINDOWS_DRIVE:-C}
WSL_WORKSPACE=${WSL_WORKSPACE:-/mnt/${WSL_DRIVE}/Users/${WINDOWS_USER}/}
WINDOWS_WORKSPACE=${WINDOWS_WORKSPACE:-${WINDOWS_DRIVE}:\\Users\\${WINDOWS_USER}}
WINDOWS_CHROMEBIN=${WINDOWS_CHROMEBIN:-/mnt/${WSL_DRIVE}/Program Files (x86)/Google/Chrome/Application/chrome.exe}
@lrewega
lrewega / osx_wallpaper_eg.sh
Created March 26, 2016 00:06
Change wallpaper on OS X
$ sqlite3 /Users/$USER/Library/Application\ Support/Dock/desktoppicture.db 'SELECT * FROM data;'
/Library/Desktop Pictures/x-2560px.jpg
0.0
5.0
Yosemite.jpg
$ sqlite3 /Users/$USER/Library/Application\ Support/Dock/desktoppicture.db 'UPDATE data SET value ="/Library/Desktop Pictures/y-2560px.jpg";'
$ killall Dock
@lrewega
lrewega / examplebot.c
Created August 4, 2011 13:56
Sample 3D Tron bot
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int move( int * map, int w, int h, int d, int p [2][3] ) {
int x, y, z, i;
int moves[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
/* Move to the first available empty space that isn't a player */
for( i = 0; i < 6; ++i ) {
int j = i > 2 ? -1 : 1;
// Initially zero. When decremented to zero, fires callback
function semaphore( callback ) {
var fn = callback,
count = 0;
return {
increment: function() {
count++;
},
decrement: function() {
if( count > 0 ) {