Skip to content

Instantly share code, notes, and snippets.

@04116
04116 / cache.js
Last active October 9, 2024 07:49
thundering herd protect
const { LRUCache } = require('lru-cache')
const options = {
max: 500,
// for use with tracking overall storage size
maxSize: 5000,
sizeCalculation: (value, key) => {
// any key/value will be sized as 1
// this one is just dump
@04116
04116 / 01.rb
Created August 16, 2024 21:48 — forked from lukemorton/01.rb
# Example One: spec/unit/lib/space/flight/ship_gateway_spec.rb
RSpec.describe Space::Flight::ShipGateway do
let(:ship) { FactoryBot.create(:ship) }
let(:gateway) { described_class.new(ship_repository: Ship) }
context 'when finding a ship by id' do
subject { gateway.find_by_id(ship.id) }
it 'returns ship with correct id' do
Pulled: registry-1.docker.io/bitnamicharts/postgresql-ha:14.2.16
Digest: sha256:ef8126d9334d30fd22140b5b26cc6b454d81a0832ca9fc12344d036cc79aef57
NAME: postgresql-ha
LAST DEPLOYED: Fri Aug 9 17:57:00 2024
NAMESPACE: postgresql
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: postgresql-ha
@04116
04116 / channelPipe.go
Created September 28, 2022 14:01 — forked from mchirico/channelPipe.go
Go (Golang) Fan-out example
// Ref: https://blog.golang.org/pipelines
package main
import (
"fmt"
"sync"
)
func gen(done <-chan struct{}, nums ...int) <-chan int {
@04116
04116 / Documentation.md
Created April 13, 2021 02:42 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@04116
04116 / README.md
Created November 6, 2020 07:41 — forked from sebastianwebber/README.md
Compilation of the Uber Facts on PostgreSQL to MySQL Migration

Uber facts

Original posts/information

Key points

  • ~50GB MySQL Application
  • Main motivation: PostGis
  • Migration made with a custom tool(xml2pgcopy) and mysqldump on 45min
@04116
04116 / Include-in-Sequelize.md
Created November 21, 2019 08:54 — forked from zcaceres/Include-in-Sequelize.md
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query