Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
tlrobinson / docker-pull.sh
Last active October 18, 2023 21:59
Quick and dirty "docker pull"-like shell script.
#!/usr/bin/env bash
set -eu
name="library/redis"
tag="latest"
registry="https://registry-1.docker.io"
blobs="blobs"
data="images/$name/$tag"
@tlrobinson
tlrobinson / firebase-utils.coffee
Last active January 14, 2023 23:11
Higher-level classes for synchronizing a nested Firebase ref, FirebaseEventEmitter and FirebaseImmutable. Work in progress.
Firebase = require "firebase"
Immutable = require "immutable"
{ EventEmitter } = require "events"
# Recursively listens to Firebase ref for modifications and emits "add",
# "change", and "remove" events with a path and value (except for "remove")
class FirebaseEventEmitter extends EventEmitter
constructor: (url) ->
EventEmitter.call(@)
@tlrobinson
tlrobinson / post-receive
Last active December 7, 2022 08:15
Super simple git post-receive hook for Node.js + nvm + npm + node-foreman + init (Ubuntu) deployment
#!/usr/bin/env bash
set -u
set -e
export GIT_WORK_TREE="/var/www/example.com"
export NODE_VERSION="0.10"
echo "--> Checking out..."
git checkout -f
@tlrobinson
tlrobinson / gist:1073865
Created July 9, 2011 19:34
Autocomplete Makefile targets. Add this to your shell config file.
complete -W "\`grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'\`" make
@tlrobinson
tlrobinson / visualize-stacking-contexts.js
Last active January 7, 2022 03:14 — forked from eoinkelly/visualize-stacking-contexts.js
Some console output to help you visualise stacking contexts on a page (no jquery)
/*
Usage:
* Paste this into your dev tools console (or even better as a snippet)
* It will parse the page and find all the things that create a new stacking context
and dump some info about them to the console. It will also outline them on the page.
* This is pretty rough and probably misses heaps of bugs and edge cases.
*/
function highlight(el) {
@tlrobinson
tlrobinson / gist:4342352
Created December 20, 2012 01:49
yourworldoftext paste script
(function() {
var text = prompt("Enter some text.");
var width = $(".active-cursor").width();
var height = $(".active-cursor").height();
var start = $(".active-cursor").offset();
var current = {
top: Math.round(start.top + height / 2),
left: Math.round(start.left + width / 2)
};
var i = 0;
@tlrobinson
tlrobinson / prettier-branch.sh
Last active December 13, 2021 00:00
Steps for merging an old branch into a newly prettier-ified codebase. Use at your own risk, verify everything was correctly merged.
# Assumes 3 sequential commits:
#
# 1. commit tagged "prettier-before" that added `prettier` depedency and `prettier` script your package.json
# 2. commit that actually ran `prettier` on your entire codebase for the first time
# 3. commit tagged "prettier-after" that fixes any minor issues caused by prettier (e.x. moving eslint-ignore or $FlowFixMe comments around), or just the next commit if there were none
#
# I recommend running these as individual commands, not as a script, in case of merge conflicts
#
# Checkout the non-pretty branch you want to merge
# (or optionally make a new branch with `git checkout -b $YOUR_BRANCH-prettier $YOUR_BRANCH`)
@tlrobinson
tlrobinson / ttgo_oled_example.ino
Last active November 22, 2021 18:30
Using the OLED display on TTGO LoRa32 development boards and "ESP8266 and ESP32 OLED driver for SSD1306 displays" library
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306Wire.h" // legacy: #include "SSD1306.h"
// TTGO LoRa32-OLED V1
//
// #define OLED_SDA 4
// #define OLED_SCL 15
// #define OLED_RST 16
// TTGO LoRa32-OLED v2.0 and V2.1
@tlrobinson
tlrobinson / LICENSE.txt
Created October 2, 2011 08:56
Extremely simple lexer, parser, compiler, and interpreter for a prefix notation calculator.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Tom Robinson <http://tlrobinson.net/>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE