Skip to content

Instantly share code, notes, and snippets.

@mjpitz
mjpitz / _README.md
Last active August 1, 2024 21:43
comparison of embedded databases for raft

As an exercise, I started to design and implement a database in some of my free time. As I started working through some of the details, there were a few things that I knew I wanted to work with and a few things I wanted to evaluate. Since I'm looking at more of a CP system, my mind immediately jumped to Raft. But which implemenation to use? And what storage mechanism? Since I had more familiarity with Hashicorps implemenation, I started there.

The first thing I wanted to do was consider the performance characteristics of the underlying data stores. One of the nice features of the hashicorp implementation is it allows callers to plugin in different stores for logs, stable, and snapshots. There's a whole slew of community implementations.

@sindresorhus
sindresorhus / esm-package.md
Last active April 21, 2025 02:29
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@Kestrer
Kestrer / how-to-write-hygienic-macros.md
Created October 17, 2020 05:35
A guide on how to write hygienic Rust macros

How to Write Hygienic Rust Macros

Macro hygiene is the concept of macros that work in all contexts; they don't affect and aren't affected by anything around them. Ideally all macros would be fully hygienic, but there are lots of pitfalls and traps that make it all too easy to accidentally write unhygienic macros. This guide attempts to provide a comprehensive resource for writing the most hygienic macros.

Understanding the Module System

First, a little aside on the details of Rust's module system, and specifically paths; it is

@ndimiduk
ndimiduk / demo.sh
Last active April 17, 2024 01:13
Demonstrating the effect of JVM arg -XX:-MaxFDLimit on OSX
$ cat /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
/**
* Export all data from an IndexedDB database
*
* @param {IDBDatabase} idbDatabase The database to export from
* @return {Promise<string>}
*/
export function exportToJson(idbDatabase) {
return new Promise((resolve, reject) => {
const exportObject = {}
if (idbDatabase.objectStoreNames.length === 0) {
@talarczykco
talarczykco / install-old-homebrew-formulas.md
Last active July 25, 2024 22:53
How to install old versions of Homebrew formulas and switch between them

This example uses istioctl as the formula, but this may come in handy for kubernetes-cli, kubernetes-helm, etc.

  1. Find the formula for your executable, e.g. istioctl, and click on the link to GitHub:
    brew info istioctl | grep Formula
    
  2. Click "Blame" button ("History" will be too large to display).
  3. Hopefully, you can find an earlier versioned commit message... click on it.
  4. Click ... in upper-right of next page, select "View File" from drop-down.
  5. Right-click "Raw" button, and Copy URL Address.
@aliesbelik
aliesbelik / benchmarking-tools.md
Last active April 2, 2025 00:58
Benchmarking & load testing tools
@jaymecd
jaymecd / amend-git-author.md
Created December 3, 2018 22:45
Amend GIT author within branch starting from COMMIT_ID

To reset commit author its required:

  1. to update default user name/email. (--global could added)
$ git config user.name example user
$ git config user.email [email protected]
  1. set checkpoint to keep orignal commit tree.
@alexbezhan
alexbezhan / gist:9bb140dc25c06cdfd56bc748c7fa9c19
Last active June 12, 2024 13:47
Scala Futures vs Kotlin Coroutines comparison

Scala with Futures:

import java.util.UUID
import scala.concurrent.Future

trait User {
    def isAdmin: Boolean
    def id: UUID
@swyxio
swyxio / 1.md
Last active March 23, 2025 07:07
Learn In Public - 7 opinions for your tech career

2019 update: this essay has been updated on my personal site, together with a followup on how to get started

2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!

1. Learn in public

If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.

You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos