Skip to content

Instantly share code, notes, and snippets.

@Azmisov
Azmisov / set_vs_array.mjs
Last active March 29, 2025 09:43
Benchmark javascript Set vs Array performance for inserting elements
import fs from "node:fs";
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
import { Worker, isMainThread, parentPort } from 'node:worker_threads';
import { performance } from "node:perf_hooks";
/** Output filename */
const output_fname = "./results.csv";
/** Use a wrapper around Set, to make the comparison more even for inlined array operations */
const COMPARE_INLINED = true;
@nathanielfernandes
nathanielfernandes / lisp-cps305-mac.md
Last active March 19, 2025 19:18
A basic tutorial on how to get started with lisp on OS X using vscode as your editor rather than slime or emacs.

Setting up lisp on Mac OS X

Note: this tutorial only outlines how to install and setup whats necessary to compile and run lisp on Mac OS X, it will not go over how to setup emacs or slime. Instead there will be instructions for how to get syntax highlighting on VsCode. If you don't have VsCode download and install it from here https://code.visualstudio.com/download

This tutorial is under the impression that you do not have Homebrew installed, if you do just skip the step.

1. Installation of Homebrew

Homebrew is a common installation tool on mac that will make the rest of this tutorial possible.

@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active February 25, 2025 06:17
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@Shrugsy
Shrugsy / rtkQueryCacheUtils.ts
Last active December 27, 2024 22:55
RTK Query cache utils. Useful abstractions for creating `provides`/`invalidates` cache data tags against endpoints.
import { FetchBaseQueryError } from '@rtk-incubator/rtk-query/dist';
/**
* Default tags used by the cacher helpers
*/
const defaultTags = ["UNAUTHORIZED", "UNKNOWN_ERROR"] as const;
type DefaultTags = typeof defaultTags[number];
function concatErrorCache<T, ID>(
existingCache: CacheList<T, ID>,
@d-t-w
d-t-w / gist:a239dfca4f57b7ff6f38c895b7f45405
Created February 27, 2021 22:21
Intellij Cursive+Cljfmt Editor CodeStyle
<code_scheme name="TW" version="173">
<ClojureCodeStyleSettings>{
:cljs.core/as-&gt; :only-indent
:cljs.core/assoc 0
:cljs.core/cond-&gt; :only-indent
:cljs.core/cond-&gt;&gt; :only-indent
:cljs.core/defonce :only-indent
:cljs.core/with-meta :only-indent
:cljs.core.async/go :only-indent
:cljs.core.async/go-loop :only-indent
@akovantsev
akovantsev / cursive-shadow-cljs-repl-setup.md
Last active February 26, 2025 06:42
Setting up shadow-cljs cljs REPL in Cursive

Interview Questions

Node.js

Q1: What do you mean by Asynchronous API? ☆☆

Answer: All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.

Source: tutorialspoint.com

@rmela
rmela / SQL query results as nodejs read stream
Last active March 24, 2025 13:12
SQLite query results as nodejs readable stream
/*
*
* Return SQLite3 query results as a Nodejs stream, sensitive to backpressure.
*
* Assumes a foo.db file with a lot of rows - I used 1000 with a number & a string
*/
const stream = require('stream');
const sqlite = require('sqlite3');
class DBStream extends stream.Readable {
@ibreathebsb
ibreathebsb / upload.js
Last active August 8, 2024 18:47
file upload from dataUrl with axios
// Note: only for modern browser
import axios from 'axios'
// helper function: generate a new file from base64 String
const dataURLtoFile = (dataurl, filename) => {
const arr = dataurl.split(',')
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)
@brauliodiez
brauliodiez / readme.md
Last active September 5, 2024 14:16
lodash/fp set and flow

lodash/fp - set / flow

In this gist we are going to learn about basic goodies that we get from the library lodash/fp (fp stands for functional programming, great for ensuring immutability).We'll learn just by doing (step by step guided sample + codepens).

We'll cover lodash set and flow functions

Steps

  • We'll use codepen as our playground, navigate to this page: