Skip to content

Instantly share code, notes, and snippets.

View danew's full-sized avatar

Dane Wilson danew

View GitHub Profile
@khalidx
khalidx / node-typescript-esm.md
Last active May 30, 2024 15:05
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

@Mulugruntz
Mulugruntz / .env
Created April 9, 2021 09:22
EdgeDB backup/restore scripts (working with docker-compose)
###### .env ######
EDGEDB_USER="my_user"
EDGEDB_PASSWORD="my_password"
@kentcdodds
kentcdodds / package.json
Last active February 6, 2023 14:57
Remove TS from EpicReact.dev workshops
{
"name": "remove-ts",
"version": "1.0.0",
"description": "I use this to automatically fix feedback links in my workshops",
"bin": "./remove-ts.js",
"dependencies": {
"@babel/core": "7.13.8",
"@babel/preset-typescript": "7.13.0",
"glob": "7.1.6"
}
@robertgonzales
robertgonzales / Frame.js
Created December 12, 2017 03:03
Use React portals to render inside shadow dom and iframes
class Frame extends Component {
componentDidMount() {
this.iframeHead = this.node.contentDocument.head
this.iframeRoot = this.node.contentDocument.body
this.forceUpdate()
}
render() {
const { children, head, ...rest } = this.props
return (
@stephen-peck
stephen-peck / README.md
Created September 7, 2017 15:58
Forking and patching npm modules from a monorepo

Forking and patching npm modules from a monorepo

Commonly, npm modules are source controlled using a single dedicated repo for each module. When forking and patching such an existing npm module, typical approaches are either:

  • reference a specific git commit in your forked repo
    "dependencies": {
        "patchedmodule": "git+https://github.com/myuser/patchedmodule.git#mypatch"
    }

Important: At the time of writing (2019-11-11) Immutable.js is effectively abandonware, so I can no longer recommend anyone to follow the advice given here. I'll leave the article here for posterity, since it's still getting some traffic.

Understanding Immutable.Record

Functional programming principles and with it immutable data are changing the way we write frontend applications. If the recent de-facto frontend stack of React and Redux feels like it goes perfectly together with immutable data, that's because it's specifically designed for that.

There's several interesting implementations of immutable data for JavaScript, but here I'll be focusing on Facebook's own Immutable.js, and specifically on one of i

@DenisIzmaylov
DenisIzmaylov / i18n-data.json
Last active May 3, 2021 21:12
Easy i18n translation in your ES6 apps
{
"ru": {
"Your original english text": "Твой оригинальный русский текст"
}
}
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
# I've always disliked the "./configure" incantation - it's right here! I
# shouldn't need to tell the shell where to look for it. But of course,
# putting '.' in your $PATH is terrible -- it's insecure and throws permission
# errors if you try to 'execute' regular files. Bash 4's `shopt -s autocd`
# solves half the problem; and the ability to override
# command_not_found_handle() solves the other.
#
# This is an OS X-oriented script that attempts to do the most intelligent
# thing possible when you enter the name of a file in your $PWD into the bash
# prompt. It will:
@fuzzyfox
fuzzyfox / markdown.js
Created June 22, 2013 23:57
JavaScript: Simple Markdown Parser
/* jshint browser: true, devel: true */
/**
* preg_replace (from PHP) in JavaScript!
*
* This is basically a pattern replace. You can use a regex pattern to search and
* another for the replace. For more information see the PHP docs on the original
* function (http://php.net/manual/en/function.preg-replace.php), and for more on
* JavaScript flavour regex visit http://www.regular-expressions.info/javascript.html
*