Skip to content

Instantly share code, notes, and snippets.

@slavafomin
slavafomin / 00-typescript-esm.md
Last active May 5, 2024 16:36
Using TypeScript with native ESM

Using TypeScript Node.js with native ESM

This reference guide shows how to configure a TypeScript Node.js project to work and compile to to native ESM.

Rationale

CommonJS module system was introduced by the Node.js developers due to the lack of the notion of "modules" in the original JavaScript (ECMAScript) language specification at that time. However, nowadays, ECMAScript has a standard module system called ESM — ECMAScript Modules, which is a part of the accepted standard. This way CommonJS could be considered vendor-specific and obsolete/legacy. Hopefully, TypeScript ecosystem now supports the "new" standard.

So the key benefits are:

@matti
matti / add.sh
Created July 29, 2017 11:12
alpine docker add package from edge testing
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
x11vnc
@nadavwr
nadavwr / pthread.scala
Last active June 8, 2018 11:59
Scala Native pthread attempt
import scala.scalanative.native._
import scala.scalanative.runtime.GC
@extern
@link("pthread")
object pthread {
type pthread_t = Ptr[CStruct0]
type pthread_attr_t = CStruct0
def pthread_create(thread: Ptr[pthread_t], attr: Ptr[pthread_attr_t],
start_routine: CFunctionPtr1[Ptr[Byte], Ptr[Byte]], arg: Ptr[Byte]): CInt = extern
@eliasby
eliasby / override_git_tag.sh
Last active March 20, 2020 10:57
override git tag
# Delete the tag on any remote before you push
git push origin :refs/tags/<tagname>
# Replace the tag to reference the most recent commit
git tag -fa <tagname>
# Push the tag to the remote origin
git push origin master --tags
# source: http://stackoverflow.com/questions/8044583/how-can-i-move-a-tag-on-a-git-branch-to-a-different-commit

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@karpathy
karpathy / min-char-rnn.py
Last active May 4, 2024 17:44
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@matsu-chara
matsu-chara / OptionValueAccessor.scala
Last active November 20, 2015 10:00
ネストしたjsonのような構造(必須でない要素あり)に簡単にアクセスするための ?メソッド
package OptionValueAccessor
import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
object OptionValueAccessor {
implicit class OptValue[A, B](val self: Option[A])(implicit ev: A <:< {def value: B}) {
def ? : Option[B] = macro Impl.optValImpl[A, B]
}
@txels
txels / rebase-onto.md
Last active December 19, 2018 02:00
Rebase a git branch onto another

Change the base branch for your current branch

Some cases:

  • you started a bugfix out of develop, but it should be applied to a release branch
  • you started on a branch and want to rebase it on some colleague's changes

Command

@wdullaer
wdullaer / Monokai.colorscheme
Last active March 21, 2022 20:43
Monokai Konsole Colourscheme
[Background]
Color=40,40,40
[BackgroundIntense]
Color=40,40,40
[Color0]
Color=73,72,62
[Color0Intense]