Skip to content

Instantly share code, notes, and snippets.


Ryan Castellucci ryancdotorg

View GitHub Profile
ryancdotorg / default.conf
Created Feb 7, 2021
An opinionated nginx default server configuration block
View default.conf
# An opinionated nginx default server configuration block
# Author: Ryan Castellucci @ryancdotorg
# Revision: 2021-02-07
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
# Send ACME (LetsEncrypt) requests to a special directory
ryancdotorg / setImmediate.js
Created Jan 3, 2021
A setImmediate polyfill optimized for size.
View setImmediate.js
(function(global, name, mc, counter, slice){
if (!(name in global)) {
if (mc = mc in global && new global[mc]) {
mc.port1.onmessage = function(evt) {
slice[evt =]();
delete slice[evt];
global[name] = function(cb) {
var args =, 1);
ryancdotorg / Makefile
Created Nov 12, 2020
A Makefile for bundling javascript
View Makefile
all: javascript
javascript: bundle_js min_js
bundle_js: $(patsubst %/,%.bundle.js,$(foreach js,$(sort $(dir $(wildcard src/js/*/*.js))),$(subst src/,static/,$(js))))
min_js: $(patsubst %.js,%.min.js,$(foreach js,$(wildcard src/js/*.js),$(subst src/,static/,$(js))))
static/js/%.min.js: src/js/%.js
terser $< --safari10 --ecma 5 -c passes=2 -m --mangle-props regex=/^_/ -o $@
ryancdotorg / fnode.js
Last active Jan 11, 2021
A nodejs REPL that'll autoload code
View fnode.js
#!/usr/bin/env node
// save somewhere in $PATH as fnode, remember to chmod +x
const vm = require('vm');
const fs = require('fs');
const tty = require('tty');
const path = require('path');
const repl = require('repl');
ryancdotorg / sw.js
Last active Oct 14, 2020
Self-extracting Service Worker Cache PoC code. The resulting file *MUST* be served with content-type: application/javascript; charset=x-user-defined
View sw.js
var ArchiveReader = function(ab) {
if (!(this instanceof ArchiveReader)) {
throw new Error('ArchiveReader must be instantiated with `new`!');
this.ab = ab;
this.dv = new DataView(ab);
this.offset = 0; = typeof TextDecoder === 'function' ? new TextDecoder() : null;
ryancdotorg /
Created Jun 27, 2020
Python script that constructs tar archives from newline delimited JSON input.
#!/usr/bin/env python3
import os, sys
import json
import tarfile
# apply attributes
def modify(attrib, stat, info):
if 'mtime' in attrib:
info.mtime = attrib['mtime']
View tasker-randomize-ad-id.xml
<TaskerData sr="" dvi="1" tv="5.9.2">
<Profile sr="prof22" ve="2">
<nme>Rotate Ad ID</nme>
<Time sr="con0">
ryancdotorg / web-crypto-scrypt.js
Last active Apr 6, 2020
An async JavaScript Scrypt implementation using Web Cryptography APIs for PBKDF2.
View web-crypto-scrypt.js
// Based on
"use strict";
(function(root) {
const MAX_VALUE = 0x7fffffff;
// Returns a Promise that resolves to an ArrayBuffer.
async function PBKDF2_HMAC_SHA256(password, salt, iterations, dkLen) {
return crypto.subtle.importKey('raw', password, {name: 'PBKDF2'}, false, ["deriveBits"]).then(
ryancdotorg /
Created Mar 14, 2020
Sets up routing when you don't have an on-subnet IP configured.
MAC=`/usr/sbin/arping -r -C1 -w10 -i "$IFACE" -S "$SRCIP" "$DSTIP"`
if [ $? -eq 0 ]
/sbin/ip neigh replace "$DSTIP" lladdr "$MAC" dev "$IFACE" nud permanent || exit $?
/sbin/ip route replace default via "$DSTIP" dev "$IFACE" || exit $?