This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'premailer' | |
gem 'nokogiri' | |
gem 'base64' | |
gem 'mail' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
.outlinerounded { | |
width: 1px; height: 1px; overflow: hidden; border: 1px solid gray; | |
} | |
</style> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "openssl" | |
require "stringio" | |
class PassthruScheme | |
READ_OR_WRITE_CHUNK_SIZE = 1 << 16 | |
def streaming_encrypt(from_plaintext_io, into_ciphertext_io) | |
while (chunk = from_plaintext_io.read(READ_OR_WRITE_CHUNK_SIZE)) | |
into_ciphertext_io.write(chunk) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "test_helper" | |
class BlockwiseEncryptionTest < ActiveSupport::TestCase | |
class NonRandomAccessible | |
def initialize(encryption_key) | |
@algo = "aes-256-cfb" | |
@iv_and_key_length = 16 + 32 | |
@key_derivation_salt = "my desire" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# This script will build a Docker image from the current state of the working tree. | |
# It will tag it with the short Git sha, and then push it to Quay.io under our company | |
# account. Afterwards the image can be picked up from other hosts to deploy. | |
export DEPLOY_HOST=<someapp>.<my-domain> | |
export REV=`git log -1 --pretty=%h` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StreamingController < ApplicationController | |
class Writer | |
def initialize(&blk) | |
@blk = blk | |
end | |
def write(stuff) | |
@blk.call(stuff) | |
stuff.bytesize | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Pecobox is a Circuitbox-like class which uses Pecorino for | |
# measurement error rates. It is less resilient than Circuitbox | |
# because your error stats are stored in the database, but guess what: | |
# if your database is down your product is already down, so there is | |
# nothing to circuit-protect. And having a shared data store for | |
# the circuits allows us to track across machines and processes, so | |
# we do not have to have every worker hammer at an already failing | |
# resource right after start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE localities ( | |
id uuid DEFAULT gen_random_uuid() PRIMARY KEY, | |
source_updated_at TIMESTAMP, | |
name TEXT | |
); | |
INSERT INTO localities (name, source_updated_at) VALUES | |
('London', '2023-04-01'), | |
('London', '2023-03-15'), | |
('Paris', '2023-02-11'), | |
('Canberra', '2022-10-05'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This offers just the leaky bucket implementation with fill control, but without the timed lock. | |
# It does not raise any exceptions, it just tracks the state of a leaky bucket in Postgres. | |
# | |
# Leak rate is specified directly in tokens per second, instead of specifying the block period. | |
# The bucket level is stored and returned as a Float which allows for finer-grained measurement, | |
# but more importantly - makes testing from the outside easier. | |
# | |
# Note that this implementation has a peculiar property: the bucket is only "full" once it overflows. | |
# Due to a leak rate just a few microseconds after that moment the bucket is no longer going to be full | |
# anymore as it will have leaked some tokens by then. This means that the information about whether a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mft_gap_mm = 96 | |
offset_outer_mm = 70 # (mft_gap_mm / 2) | |
# Long side needs an odd number of gaps so that the center span of the | |
# workbench ends up between two rows of holes and never overlaps the holes | |
1.step(22,2) do |n_gaps_x| | |
1.upto(10) do |n_gaps_y| | |
width_mm = (offset_outer_mm * 2) + (mft_gap_mm * n_gaps_x) | |
height_mm = (offset_outer_mm * 2) + (mft_gap_mm * n_gaps_y) | |
puts "#{width_mm}x#{height_mm}mm with #{n_gaps_x + 1} holes along and #{n_gaps_y + 1} holes across" | |
end |
NewerOlder