Skip to content

Instantly share code, notes, and snippets.

View dt-rush's full-sized avatar
🌍
nothing human is alien to me

dt-rush dt-rush

🌍
nothing human is alien to me
  • protoss
  • ontario
View GitHub Profile
@dt-rush
dt-rush / main.go
Created May 19, 2018 17:08
[go] Demonstrating that indexing a map[uint32] takes longer with larger indexes
/* This was written to show that indexing a map with numbers
* formed by putting two uint16's into a single uint32 takes longer
* than indexing a map with uint16's in the range [0, 1023]
*/
package main
import (
"fmt"
"time"
@dt-rush
dt-rush / CPU and Compiler info
Created May 25, 2018 20:51
Profiling distance functions in go
Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
go version go1.8.3 linux/amd64
@dt-rush
dt-rush / main.go
Created June 8, 2018 14:01
Illustrating two benign race conditions in Go (stop flag and ABQL)
// illustrating benign data races in:
//
// a. one-time flag setting where missing the flag being set is benign (we simply
// loop one more time, but in the logic of the program, that's fine)
//
// b. implementing an array-based queueing lock in which lockers wait on the
// value at their array position to be set to 1
package main
@dt-rush
dt-rush / request-metrics-gatherer.js
Created April 18, 2020 03:41
Simple express HTTP API request metrics gathering, demonstrating how `req.connection.bytesRead` is weird
const express = require('express');
const bodyParser = require('body-parser');
const onFinished = require('on-finished');
// it may be necessary to modify the request object in various ways, this can
// be done in this function. For example, a `_metrics_gatherer` object is
// added to req and req.connection for the purposes of metrics observing functions
const modifyReq = (req) => {
req._metrics_gatherer = {};
if (!req.connection._metrics_gatherer) {
@dt-rush
dt-rush / delete-app.js
Last active May 8, 2020 23:13
Delete balena application resources via node SDK when app delete as a whole is timing out
const getSdk = require('balena-sdk');
const balena = getSdk({
apiUrl: "https://api.balena-cloud.com/",
dataDirectory: "/tmp"
});
const key = process.env.BALENA_KEY;
const appId = parseInt(process.env.APP, 10);
const countResource = (resource) => {
return balena.pine.get({
resource: resource + '/$count',
// MISSION: OPERATION TRANS LIBERATION
//
// USAGE:
// 1) Navigate to https://new.reddit.com/r/place/
// 2) Open the "Developer Tools" (CTRL+SHIFT+I)
// 3) Make sure the context dropdown is set to: "embed" (https://i.imgur.com/YfCY4WP.png)
// 4) Paste the code below in the console and hit enter. (https://i.imgur.com/YAHjJXP.png)
// 5) Leave window open and a pixel will be placed in the set
// range every time your timer goes down