Skip to content

Instantly share code, notes, and snippets.

@Hirrolot
Hirrolot / CoC.ml
Last active April 5, 2024 15:34
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active April 26, 2024 13:33
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

@YBogomolov
YBogomolov / 0_README.md
Created June 7, 2020 13:34
Idris 2 DevContainer

How to use Idris 2 in devcontainer

Step 1: build executable and libraries

Use the Dockerfile below to build the Idris 2 executable and standard library:

docker build --tag=idris2 .
// [dependencies]
// serde = "1.0"
// serde_derive = "1.0"
// serde_json = { version = "1.0", features = ["raw_value"] }
// fnv = "1.0.5"
// memmap = "0.7"
// smallvec = { version = "0.6", features = ["serde"] }
// jemallocator = "0.3"
use fnv::{FnvHashSet as HashSet, FnvHashMap as HashMap};
@giraldeau
giraldeau / CMakeLists.txt
Created November 3, 2017 21:48
The missing example to use cmake qt5_create_translation
cmake_minimum_required(VERSION 3.8)
project(tsProject)
# Managing translations require LinguistTools module
# The cmake function is defined in the Qt installation tree:
# i.e. Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5LinguistTools/Qt5LinguistToolsMacros.cmake
# Reference: https://doc.qt.io/qt-5/cmake-manual.html#qt5linguisttools-macros
find_package(Qt5 COMPONENTS Widgets LinguistTools)
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ihincks
ihincks / lighten_color.py
Last active August 30, 2023 21:49
Function to lighten any color in matplotlib
def lighten_color(color, amount=0.5):
"""
Lightens the given color by multiplying (1-luminosity) by the given amount.
Input can be matplotlib color string, hex string, or RGB tuple.
Examples:
>> lighten_color('g', 0.3)
>> lighten_color('#F034A3', 0.6)
>> lighten_color((.3,.55,.1), 0.5)
"""
@jfbercher
jfbercher / collapsed_outputs.tpl
Created May 10, 2016 12:41
Template for nbconvert/html for collapsed outputs
{%- extends 'full.tpl' -%}
{# This template preserves collapsed outputs after conversion to html.
Put it in your templates directory, see template_path in jupyter_nbconvert_config.json
Usage: jupyter nbconvert --template collapsed_outputs FILE.ipynb #}
{%- block header -%}
{{ super() }}
<script>
@parente
parente / code_toggle.js
Last active August 6, 2022 21:03
Code toggle for notebooks on nbviewer
// Builds on http://chris-said.io/2016/02/13/how-to-make-polished-jupyter-presentations-with-optional-code-visibility/
// to inject a navbar button in the nbviewer UI and to make the snippet easily reusable across notebooks, i.e.:
// %%html
// <script src="https://cdn.rawgit.com/parente/4c3e6936d0d7a46fd071/raw/2af9515fbe8b776bf8e1c41d8dc662146993bd0d/code_toggle.js"></script>
$(document).ready(function(){
function onShow() {
$('div.input').show(100, function() {
$('div.cell').css({padding: '5px', border: '1px'});
});
}
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 8, 2024 07:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname