Skip to content

Instantly share code, notes, and snippets.

@matchu
matchu / 1-heroku-backups.mjs
Last active August 25, 2022 21:31
Download backups of all your Heroku apps
/**
* Run this in Node to download all your Heroku apps' databases as
* Postgres .dump files, in a new folder named `backups`!
*
* Automates the export process described here:
* https://devcenter.heroku.com/articles/heroku-postgres-import-export
*
* Requires the Heroku CLI, tested with v7.62.0.
*
* WARNING: NEVER run a script on your machine without understanding it!
// HACK: Use Node's testing APIs to be able to log custom trace
// events. I… genuinely didn't find a better way to do
// local nodejs custom tracing??
//
// To enable tracing, run this with:
// node --expose-internals --trace-event-categories app
//
// Without that, the require will throw an error, so the trace
// functions will be no-ops!
let trace;
@matchu
matchu / README.md
Last active July 7, 2021 10:29
Fork of Apollo Server's cache-control plugin, with stale-while-revalidate support

Hi! This is a plugin I hacked together, to add another field staleWhileRevalidate to Apollo Server's @cacheControl directive!

To use this, you'll need to disable the built-in plugin by setting cacheControl: false in your Apollo Server config.

Then, add this plugin, and initialize it with the option calculateHttpHeaders: true (which Apollo Server normally enables by default).

const server = new ApolloServer({
    // ...
 cacheControl: false,
@matchu
matchu / README.md
Last active August 4, 2020 21:53
Dress to Impress - Export lists to CSV

Warning: The procedure I'm about to describe is dangerous! Copy-pasting code into the browser console can let attackers steal your data. Make sure to only paste in code from people you trust, on websites where you are okay with them seeing all your data!

  1. Open your Dress to Impress items page.
  2. Follow these instructions to open the Javascript Console for the page.
  3. Paste in the code shown on this page. It's labeled console-script.js.
  4. This should pop open a new window. If your popups are blocked, enable them.
  5. The new window should trigger a download of your items CSV!
@matchu
matchu / has-bad-words.js
Last active January 22, 2019 21:44
"Has bad words?" script for Neopets textareas [needs word list!]
const ALL_BAD_WORDS = [
// Except, like, replace this with the actual list of words.
"uncle",
"grape"
];
/** Return a list of bad words that appear in the given text. */
function findBadWords(text) {
return ALL_BAD_WORDS.filter(badWord => text.includes(badWord));
}
#!/usr/bin/env python
import re
import subprocess
CHECKOUT_RE = re.compile(
r'[0-9a-f]+ HEAD@\{[0-9]+\}: checkout: moving from .+? to (.+)')
def main():
reflog = subprocess.check_output(['git', 'reflog', '-n', '1000'])
lines = reflog.splitlines()
@matchu
matchu / Greeter.elm
Created July 29, 2015 00:45
Prompt in Elm
module Greeter where
import Html exposing (Html, div, text, button)
import Html.Events exposing (onClick)
import Signal exposing (Address)
type alias Model =
{ name : String
, awaitingName : Bool }
// ==UserScript==
// @name Orange Neopet Health
// @namespace http://www.reddit.com/u/undergroundmonorail
// @version 0.1
// @description yellow is hard to read. make your neopet's worrying-but-not-critical health show up orange instead
// @author monorail
// @match http://www.neopets.com/*
// ==/UserScript==
$('.activePetInfo font[color=yellow]').attr('color', 'orange');
@matchu
matchu / README.md
Last active December 18, 2015 17:29
Get total video duration of a given topic from the Khan API.

Setup:

gem install httparty parallel

Usage: (get the ID from the topic page's URL; can be any level)

ruby khan_duration.rb solving-linear-equations-and-inequalities

@matchu
matchu / robot.js
Created December 4, 2012 00:58 — forked from fabiopimentel/robot.js
<deleted>
var Robot = function(robot) {
// Oh. So this is what the fork button does.
// I wish I had a delete button.
};