Skip to content

Instantly share code, notes, and snippets.

View OutdatedVersion's full-sized avatar
🐄

Ben Watkins OutdatedVersion

🐄
View GitHub Profile

Note This is a note

Warning This is a warning

Important

Crucial information necessary for users to succeed.

version: "3.8"
services:
service:
build: .
environment:
# Node.js does not respect the system's CA store
NODE_EXTRA_CA_CERTS: "/usr/local/share/ca-certificates/mitmproxy/mitmproxy-ca-cert.pem"
volumes:
- .mitmproxy:/usr/local/share/ca-certificates/mitmproxy
ports:
alias ..='cd ..'
alias dev='cd /Users/user/dev'
## compression/decompression
alias tarc='tar -cvfz'
alias tard='tar -xvfc'
## directory
alias mkdir='mkdir -p'
## docker
const fs = require("fs");
const file = fs.readFileSync(0, { encoding: "utf8" });
const metrics = file
.split("\n")
// remove empty lines (i.e. EOL) and comments
.filter((l) => !!l && !l.startsWith("#"))
// only the metric name
.map((l) => l.substring(0, l.search(/[^0-9a-z_]/gi)))
.filter((metric) => metric.startsWith("nats_"))

Legos of distributed systems

Two classes of handling;

  • Syncronous, requests and responses
  • Asynronous, eventing

The blocks and their problem statements

  • 🧱 Discovery

shell

ctrl + k: clear content to end of line
ctrl + r: (reverse) search through ~/.$SHELL_history
ctrl + a: go to beginning of line
ctrl + e: go to end of line
cd $PWD: refreshes referenced inode
!$: expands to last segment of previous command

signals:

type Line = readonly [Vector, Vector];
class Vector {
public constructor(
public readonly x: number,
public readonly y: number,
public readonly z: number
) {}
public subtract(other: Vector): void {
const Scarcity = {
Common: 'common',
Rare: 'rare',
OneInAMillion: 'one_in_a_million',
};
class Item {
constructor(key, weight, scarcity) {
this.key = key;
this.weight = weight;
import { ExtractJwt, Strategy } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import { passportJwtSecret } from 'jwks-rsa';
import { AppleJwtPayload } from './types';
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor() {
super({
const assert = require('assert');
function clampedAlphabeticAdd(num, amt) {
const result = num + amt;
if (result > 'z'.charCodeAt(0)) {
return 'a'.charCodeAt(0) + (result - ('z'.charCodeAt(0) + 1)); // off by one from char codes starting at 0
} else {
return result;
}
}