Skip to content

Instantly share code, notes, and snippets.

Add a new zig build scripts -- inspect ... subcommand for inspecting a data file.

Principles:

  • inspect never modifies the data file.
  • When the data file is corrupt, decode as much as possible. (This is somewhat aspirational).
  • Outside of the "summary" commands, don't discard potentially useful information.

Since there are a bunch of (sub-)subcommands and flags, there is now help text for zig build scripts:

@sentientwaffle
sentientwaffle / scrub3.py
Created June 5, 2024 17:39
Scrubber cycle interval model/calculator
import math
from fractions import Fraction
# Model the probability that the cluster experiences data loss due to bitrot.
# Specifically, that every copy of any grid block is corrupted before the scrubber repairs them.
#
# Optimistic assumptions (see below):
# - Faults are independent (i.e. uncorrelated) in space and time. ¹
# - Faults are independent between replicas. ²
#
diff --git a/index.js b/src/index.ts
index 2df5b31..d7c016a 100644
--- a/index.js
+++ b/src/index.ts
@@ -1,28 +1,80 @@
-'use strict'
-
-const crypto = require('crypto')
+import * as crypto from 'crypto'
const BtpPacket = require('btp-packet')
test("rogue socket.close, then flush", function(t) {
var mc, done
dgramServer(function(pool, _done) {
mc = new MetricsAgent(pool)
var socket = mc.socket
, _close = mc.socket.close
mc.socket.close = function() {
console.trace()
_close.apply(socket, arguments)
};
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<!-- General Settings -->
<match target="font" >
<edit mode="assign" name="rgba" >
<const>rgb</const>
function color(n) {
return '\u001b[38;5;' + n + 'm'
}
var clear_color = '\u001b[39m'
var str = ""
for (var i = 0; i < 256; i++) {
if (i && i % 32 === 0) str += "\n"
str += color(i) + "X" + clear_color
@sentientwaffle
sentientwaffle / stream-test.js
Created November 20, 2013 18:03
This is a (failing) test for node-spdy@1.16.7. The push streams arrive after the "foo" write, even though the "foo" write occured after the push stream was closed.
test('push stream compression race', function(done) {
var ops = [];
var remaining = 2;
pair.client.res.on('data', function(data) {
ops.push(['req data', data.toString()]);
doneish();
});
agent.once('push', function(req) {
req.once('data', function(chunk) { ops.push(['push data', chunk.toString()]); });
req.once('end', function() {
@sentientwaffle
sentientwaffle / open-in-new-tab.js
Created November 18, 2012 17:20
Open link in new tab
// Source: http://jsfiddle.net/3ZmvS/5/
function openNewTab(url) {
var a = document.createElement("a")
, ev = document.createEvent("MouseEvents")
a.href = url
ev.initMouseEvent( "click", true, true, window
, 0, 0, 0, 0, 0, true, false
, false, false, 0, null )
@sentientwaffle
sentientwaffle / llq-out.txt
Created June 19, 2012 20:03
Benchmark: llquantize vs metrics.Histogram
$ time node llq.js
{ '1': 104,
'2': 95,
'3': 112,
'4': 104,
'5': 95,
'6': 103,
'7': 96,
'8': 106,
'9': 100,
@sentientwaffle
sentientwaffle / README.md
Created March 24, 2012 19:08
linux text-to-mp3

Convert a text file into a directory of MP3 files. Perfect for do-it-yourself robot audiobooks!

Installation

You will need the following dependencies from apt-get:

  • espeak
  • lame

Install them with: