Skip to content

Instantly share code, notes, and snippets.

@markjamesm
markjamesm / node-typescript-esm.md
Created November 22, 2023 02:07 — forked from khalidx/node-typescript-esm.md
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@markjamesm
markjamesm / FunctionalSlotMachine.py
Last active August 6, 2021 15:11
Functional Programming with Python — Building a Simple Slot Machine
# Copyright 2021 Mark-James McDougall and licensed under the MIT License.
# This is an example of a single reel slot machine written with a functional
# programming paradigm using python.
# Once started, the machine will keep running until a jackpot condition is
# hit (three matching numbers), and it will also keep track of the number
# of times two matching numbers come up.
# Example output:
@markjamesm
markjamesm / FunctionalCSharpNotebook.cs
Last active July 31, 2021 20:39
Functional C# for Beginners
// Instead of
public static int Add(int x, int y) {
return x + y;
}
// Use a lambda to add two sums
public static int Add(int x, int y) => x + y;
// Func is a delegate that can reference anything with that param signature.
@markjamesm
markjamesm / CardDeck.Swift
Last active September 18, 2023 21:05
Deck of cards model in Swift 5
// Deck of cards model in Swift 5.
// Run in Swift playgrounds
// Value of AKQJ needs to be changed.
import Foundation
enum CardSuits: String, CaseIterable {
case Hearts = "Hearts"
case Spades = "Spades"