Skip to content

Instantly share code, notes, and snippets.

View patio11's full-sized avatar

Patrick McKenzie patio11

View GitHub Profile
@patio11
patio11 / annual-prepay.md
Last active February 23, 2024 11:16
Appointment Reminder Annual Pre-pay copy (2014)

Notes

This is the latest version of an email which I send periodically, offering customers the opportunity to pre-pay for SaaS in return for a discount. The benefits to the SaaS company are better cash flow and reduced churn rate. The benefits to the customer are, well, in the email. This genre of email has produced hundreds of thousands of dollars in pre-pays for some companies I work with, and it rarely requires any more work than this example.

I've put $79 is as a placeholder for the cost of the user's plan. We calculate that for each account, naturally, along with the billing contact's name.

Subject: Save $79 on Appointment Reminder (and get a tax write-off) Formatting: 100% plain text. Gmail automatically links up the central link. From: Patrick McKenzie (Appointment Reminder) patrick@appointmentreminder.org

@patio11
patio11 / nixie-console-copypasta.lua
Created February 13, 2024 15:43
Monkeypatching Factorio mods for compatibility
-- Thanks to ChatGPT for improving my lua ability
local player = game.player
local surface = player.surface
local sprite_names = {'SNTD-nixie-tube-small-sprite', 'SNTD-nixie-tube-sprite'}
local all_nixie_sprites = surface.find_entities_filtered{name=sprite_names}
local known_sprites = {}
require 'rubygems'
require 'httparty'
require 'fileutils'
require 'json'
USERNAME = ARGV[0] || "patio11"
MAX_TO_FETCH = ARGV[1]
puts "Username: #{USERNAME} max to fetch: #{MAX_TO_FETCH || "all"}"
@patio11
patio11 / ansible-snippet.yaml
Created July 9, 2015 02:44
Create an account on every box using the list of employees; initialize with their Github SSH keys
vars:
starfighters:
- username: patrick
github: patio11
name: "Patrick McKenzie"
- username: thomas
github: tqbf
name: "Thomas Ptacek"
- username: erin
github: boboTjones
@patio11
patio11 / monte-carlo-that-perl.rb
Created October 28, 2019 07:55
monte carlo simulation for perl random line generator
NUMBER_OF_BUCKETS = 100
EXPECTED_BUCKET_SIZE = 100
file = "1-to-#{NUMBER_OF_BUCKETS}.txt"
f = File.open(file, "w")
contents = (1..NUMBER_OF_BUCKETS).to_a.map(&:to_s).join("\n")
f.write(contents)
f.close()
command = "cat #{file} | perl -e 'while(<>){$x=$_ if rand()<=(1/$.)}print $x'"
@patio11
patio11 / bitfinex-03152019.md
Created April 26, 2019 00:29
`shasum bitfinex-03152019.md` is 938d939059a23aa84ce493db0c4d542748f849a7

Prediction as of 3/15/2019 JST:

  • Bitfinex is insolvent, for the Bitcoin economy's usual quixotic definition of insolvent.
  • This happened as a result of collateralizing Tether with BTC and other cryptocurrencies during the run-up.
  • Bitfinex / Tether treat whether Bitfinex held the collateral or Tether held the collateral as a material distinction, but that's ridiculous due to common control. The important fact: in 2018, ground truth diverged from "There is $1 in a bank account for every tether outstanding" to "There is $1 in a bank account and/or $1 worth of Bitcoin at prevailing prices available to Bitfinex for every tether outstanding."
  • This makes Tether synthetically long Bitcoin, via a receivable from Bitfinex. Bitfinex took the newly issued Tether and then, since this accounting shellgame appears to balance its books and leave it with surplus Bitcoin, either sold or lent the Bitcoin to short sellers during the run-up.
  • If Bitfinex simply sold the Bitcoin, they're doing relatively well for themselve
@patio11
patio11 / app_controllers_slack_controller.rb
Created November 26, 2015 09:01
Implementing a /healthcheck endpoint in Slack to read out consul status in a human-readable fashion
class SlackController < ApplicationController
skip_before_action :verify_authenticity_token
@@slack_security_tokens =
["copy-paste-the-token-you-get-from-Slack-when-configuring-the-integration-here"]
before_filter :bounce_access_not_from_slack
def healthcheck
services = SystemStatus.list_services
@patio11
patio11 / borked.html
Created November 23, 2015 15:56
Minimal repro case of stylesheets not loading on Firefox with wrong MIME specified
<!DOCTYPE html>
<html lang='en'>
<head>
<link rel="stylesheet" type="css/text" href="https://dwpnibhogf8y5.cloudfront.net/static/css/bootstrap.min-f04b517b.css" />
<body>
<div class="alert alert-danger">This text should be styled.</div>
</body>
</html>
@patio11
patio11 / samples.js
Last active October 30, 2015 20:14
Starfighter REST API request and response JSON samples
//JSON to POST to /venues/FOOEX/stocks/BAR/orders
{
“symbol”: “BAR”,
“venue”: “FOOEX”,
“direction”: “buy”,
“qty”: 20,
“price”: 5100,
“type”: “limit”,
“account” : “OGB12345”, // your trading account (game gives you this)
@patio11
patio11 / SchoolClass.java
Created September 21, 2012 08:33
Java can be fun!
List<Student> studentsWhoHaveNotTakenAtLeastOneTest() {
List<Student> allStudents = this.getStudents().clone(); /* shallow copy to avoid mutation */
Iterator<Student> studentIt = allStudents.iterator();
/* select down to students missing at least one test */
List<Student> studentsMissingAtLeastOneTest = new ArrayList<Student>();