Skip to content

Instantly share code, notes, and snippets.

View infojunkie's full-sized avatar
🎶

Karim Ratib infojunkie

🎶
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 11, 2024 11:39
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.
// funciona somente com v3.1.6, essa estrategia de end/continue
// era um backdoor para fazer recursao em types, recursao funcionava somente com interfaces
// antigamente pela resolucao de tipos ser lazyness e nao acabar fazendo o compiler cair
// potencialmente em um looping infinito na resolucao do tipo, por causa disto tem validacao
// no compiler agora e codigos nesse estilo sao barrados pelo compiler
type Init<T extends any[], TTail extends any[] = TailArray<T>> = CastArray<{
[K in keyof TTail]: T[keyof T & K];
}>
@maximecb
maximecb / music.csv
Created May 19, 2018 17:21
Python program to sequence MIDI music using a CSV spreadsheet
X kick snare
X
X
X
X kick
X
X
X
X kick snare clap
X
@bohoffi
bohoffi / getStringAndFretFromKeyAndTuning.ts
Created May 19, 2017 12:04
Shows how to calculate a note's position on a fretboard (e.g. guitar or bass) providing the note's key (e.g. 'e/4'), a string tuning and a maximum fret limit.
type Tuning = string[];
// provide the standard 6-string guitar tuning (high to low)
const standardTuning: Tuning = ['E4', 'B3', 'G3', 'D3', 'A2', 'E2'];
// provide a limit for the fretboard length (24 frets => 0 to 24)
const maxFretLimit: number = 24;
interface FretBoardNote {
string: number;
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@wchargin
wchargin / Vex.jsx
Created December 10, 2015 07:15
proof-of-concept: rendering musical notes in React
import Vex from 'vexflow';
import React, {Component} from 'react';
const {
Accidental,
Formatter,
Stave,
StaveNote,
Renderer,
@mattearnshaw
mattearnshaw / gist:ba3928a256d55341e288
Created July 20, 2015 12:49
kraehenbuehl harmonizing algorithm
(ns kraehenbuehl.core
(:require [leipzig.scale :as scale]
[leipzig.chord :refer [root triad inversion]]
[overtone.music.pitch :refer [find-note-name]]))
;eg. (kraehenbuehl (comp scale/G scale/major) [62 64 62 60 59])
;=> ((43 55 59 62) (52 55 59 64) (47 54 59 62) (38 54 57 60) (43 50 55 59))
(declare pitch-class)
(declare triad-with-top)
@ohanhi
ohanhi / frp.md
Last active May 6, 2024 05:17
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

@neuroticnerd
neuroticnerd / python-on-ubuntu.sh
Last active July 27, 2018 07:09
Python 2.7.9 on Ubuntu 14.04.2 (without overwriting original version)
#! /usr/bin/env bash
# http://smirnov-am.blogspot.com/2015/04/installation-of-python-279-in-ubuntu.html
# http://davebehnke.com/python-pyenv-ubuntu.html
# https://renoirboulanger.com/blog/2015/04/upgrade-python-2-7-9-ubuntu-14-04-lts-making-deb-package/
# install dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential