Skip to content

Instantly share code, notes, and snippets.

View LucaColonnello's full-sized avatar
Come say hello on Twitter!

Luca Colonnello LucaColonnello

Come say hello on Twitter!
View GitHub Profile
LucaColonnello / memo.js
Last active March 17, 2022 10:27
Memo higher order function that works with any number and type of params.
Create a memo higher order function that works with any number and type of params.
This solution uses hashmaps to achieve fast performance.
cache = Map {
[[ValueSymbol]] => value,
arg1 => Map {
LucaColonnello / tinyTpl.js
Created May 25, 2021 09:24
Tiny template - using ES6 native tiny template implementation
const propSelector = (prop, ctx) => (typeof prop === 'function' ? prop(ctx) : (prop ?? ''));
const tinyTpl = (parts, ...props) =>
(ctx) =>, i) => v.concat(propSelector(props[i], ctx))).join('');
const get = (prop) => (ctx) => ctx[prop];
const template = tinyTpl`hello ${get('name')} ${'yay'}!`
console.log(template({ name: 'Luca' }))
LucaColonnello /
Created September 10, 2020 18:11 — forked from wonderbeyond/
script to export vsc settings
#!/usr/bin/env python3
from os import path
import tempfile
import subprocess
import datetime as dt
import click
def cli():
LucaColonnello / example.js
Created September 10, 2020 09:33
Custom Express like middleware system
const task = (data) => {
console.log('perform task with', data);
const middlewares = [];
middlewares.push((data, next) => {
console.log('add custom data', data);
next({, type: 'humanoid', power: 'pizza tasting' });
LucaColonnello / index.html
Last active August 7, 2020 11:11
Redux like store with per slice subscription - using bit masks to propagate changes
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script id="jsbin-javascript">

How Fast if Git?

The web is full of benchmarks showing the supernatural speed of Git even with very big repositories, but unfortunately they use the wrong variable. Size is not important, but the number of files in the repository really is!

Why is that? Well, that's because Git works in a very different way compared to Synergy. You don't have to checkout a file in order to edit it; Git will do that for you automatically. But at what price?

The price is that for every Git operation that requires to know which files changed (git status, git commmit, etc etc) an lstat() call will be executed for every single file

Wow! So how does that perform on a fairly large repository? Let's find out! For this example I will use an example project, which has 19384 files in 1326 folders.

LucaColonnello / .zshrc
Created February 1, 2020 14:40
Automatically switch Node version with nvm
# Past at the end of .zshrc file
# nvm
export NVM_DIR="/Users/lucacolonnello/.nvm"
[ -s "$NVM_DIR/" ] && . "$NVM_DIR/" # This loads nvm
autoload -U add-zsh-hook
load-nvmrc() {
LucaColonnello / projects.graphql
Created January 10, 2020 12:26 — forked from dahlbyk/projects.graphql
GraphQL to fetch GitHub Projects+Columns+Cards with issue/PR detail for a specific repo.
search(type: REPOSITORY, query: "org:huboard-testing spooky-octo-pug", first: 1) {
edges {
node {
... on Repository {
owner {
LucaColonnello /
Created November 12, 2018 13:48 — forked from canhnt/
Delete local tags that do not exist in remote
git fetch --prune origin "+refs/tags/*:refs/tags/*"
LucaColonnello / babel-named-exports-plugin.js
Last active May 27, 2019 10:31
Babel named default export React plugin
const itReturnsJSX = () => true;
const createNamedComponentVisitor = {
ArrowFunctionExpression(path) {
const { functionName, types: t } = this;
if (itReturnsJSX(path)) {
t.variableDeclaration('const', [