Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / esm-package.md
Last active June 1, 2024 19:35
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>
@loilo
loilo / idb-backup-and-restore.md
Last active April 29, 2024 06:40
Back up and restore an IndexedDB database

Back up and restore an IndexedDB database

This gist is an ES module which provides functions to import and export data from an IndexedDB database as JSON. It's based on Justin Emery's indexeddb-export-import package, but applies some adjustments that reflect better on the current browser landscape (i.e. better developer ergonomics but no support for Internet Explorer).

Usage

For each of the provided functionalities, you need a connected IDBDatabase instance.

Export Data

import { idb } from 'some-database'
@talarczykco
talarczykco / install-old-homebrew-formulas.md
Last active March 13, 2023 12:44
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 May 21, 2024 10:25
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 example@email.com
  1. set checkpoint to keep orignal commit tree.
@alexbezhan
alexbezhan / gist:9bb140dc25c06cdfd56bc748c7fa9c19
Last active October 19, 2021 23:22
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 February 8, 2024 22:30
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

@gousiosg
gousiosg / README.md
Last active November 8, 2023 05:20
Restoring the GHTorrent MongoDB database

This is a collection of scripts to restore a full GHTorrent MongoDB database from the dumps available at http://ghtorrent-downloads.ewi.tudelft.nl.

To do the restore:

  1. Open a MongoDB terminal and run the createCollections.js script to create the necessary collections. You can block_compressor to either snappy or zlib to make your databases compressed. I am using none here, as I am using compression at the filesystem level.

  2. Run restore-cummulative-dumps.sh to restore the cummulative dumps. Wait 3-4 days.