Skip to content

Instantly share code, notes, and snippets.

View PaulLeCam's full-sized avatar

Paul Le Cam PaulLeCam

View GitHub Profile
@Jaid
Jaid / migratingRules.md
Last active February 21, 2024 10:48
ESLint rules for migrating projects from CommonJS to ESM

ESLint rules

The ESM standard is considered stable in NodeJS and well supported by a lot of modern JavaScript tools.

ESLint does a good job validating and fixing ESM code (as long as you don't use top-level await, coming in ESLint v8). Make sure to enable the latest ECMA features in the ESLint config.

  • .eslint.json
{
- name: Restore yarn workspaces
id: yarn-cache
uses: actions/cache@master
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
const log = (tag: string) => tap(
next => console.log(`%c[${tag}: Next]`, 'color: #4CAF50;', next),
error => console.log(`%c${tag}: Error]`, 'color: #F44336;', error),
() => console.log(`%c[${tag}: Complete]`, 'color: #2196F3;')
);
@dominictarr
dominictarr / readme.md
Created November 26, 2018 22:39
statement on event-stream compromise

Hey everyone - this is not just a one off thing, there are likely to be many other modules in your dependency trees that are now a burden to their authors. I didn't create this code for altruistic motivations, I created it for fun. I was learning, and learning is fun. I gave it away because it was easy to do so, and because sharing helps learning too. I think most of the small modules on npm were created for reasons like this. However, that was a long time ago. I've since moved on from this module and moved on from that thing too and in the process of moving on from that as well. I've written way better modules than this, the internet just hasn't fully caught up.

@broros

otherwise why would he hand over a popular package to a stranger?

If it's not fun anymore, you get literally nothing from maintaining a popular package.

One time, I was working as a dishwasher in a restu

@Xowap
Xowap / gdpr.yml
Last active December 27, 2018 11:28
---
# List here all data controllers
controllers:
- name: Control Corporation
address: 42 control road, 75000 Paris, France
organisational_part: Control Part
contact_person: Jean-Claude Control
# That's all recipients for this data, wether internal database or an
@lilactown
lilactown / promises.re
Last active August 20, 2022 07:56
Notes on using JavaScript Promises in ReasonML/BuckleScript
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
@busypeoples
busypeoples / UIPattern.re
Last active January 28, 2019 15:31
Slaying a UI Anti Pattern in ReasonML
/*
Slaying a UI Anti Pattern in ReasonML
Based on Kris Jenkins original writing.
http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html
*/
type remoteData 'e 'a =
| NotAsked
| Loading
| Failure 'e
| Success 'a;
@koistya
koistya / declarative-routes.md
Last active September 1, 2016 13:39
Declarative routes with React and Relay

Custom Routing solution with React and Relay

Start by checking You might not need React Router article by Konstantin Tarkus

It shows how to implement Router.resolve(routes, context) method with just a few lines of code, which in combination with history npm module (handles client-side navigation) can be a good routing solution for many React applications.

This article demonstrates imperative (functional) routes. But if you're planning to use Relay, it might be a better idea to use declarative routes instead. For example, you can declare all routes

@Rich-Harris
Rich-Harris / service-workers.md
Last active July 10, 2024 17:04
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@tianjianchn
tianjianchn / error-report.js
Last active July 17, 2023 10:15
Error report util with fabric/crashlytics in react-native
/*global __DEV__*/
import StackTrace from 'stacktrace-js';
const Fabric = require('react-native-fabric');
const { Crashlytics } = Fabric;
//call this to start capturing any no-handled errors
exports.init = function(captrueOnDebugMode){
if (__DEV__ && !captrueOnDebugMode) {
return;