Skip to content

Instantly share code, notes, and snippets.

View yonycalsin's full-sized avatar

Yony yonycalsin

View GitHub Profile
import debug from 'debug'
import _ from 'lodash'
const logger = debug('api:temp')
interface DynamicCustomField {
name: string
path: string
}
```ts
set-alias nano C:\Progra~1\Git\usr\bin\nano.exe
```
@sindresorhus
sindresorhus / esm-package.md
Last active March 11, 2026 01:59
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@rauschma
rauschma / impatient-js-es2021.md
Last active August 31, 2023 07:02
ES2021 edition of “JavaScript for impatient programmers”

What is new in the ES2021 edition of “JavaScript for impatient programmers”?

Free to read online: exploringjs.com/impatient-js/

  • The exercises now run as native ESM modules on Node.js. Previously, they were run via the esm package.
  • Material on new ES2021 features:
    • String.prototype.replaceAll()
    • Promise.any()
    • Logical assignment operators
  • Underscores (_) as separators in number literals and bigint literals
@taniarascia
taniarascia / auth.md
Last active March 23, 2025 14:27
JavaScript Authentication & Authorization Book/Course

Authentication in Real-World Web Apps with JavaScript

Outline of ideas, concepts to cover, potential projects to write.

Setup Idea

  • Book with a video for each chapter.

Prerequisites/Overview

@agmm
agmm / nextjs-file-upload-api.js
Created January 31, 2020 23:03
Simple Nextjs File Upload — Backend API
// Backend
import formidable from 'formidable';
export const config = {
api: {
bodyParser: false,
},
};
export default async (req, res) => {
@yonycalsin
yonycalsin / string-utils.js
Created January 9, 2020 01:32 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@yonycalsin
yonycalsin / dynamicMethods.rs
Created December 20, 2019 22:55 — forked from emaxerrno/dynamicMethods.rs
dynamicMethodDispatch.rs
fn main() {
trait AlexTraitOnStr {
fn foo(&self);
}
impl AlexTraitOnStr for ~str {
fn foo(&self) {
println!("{}", *self);
println!("added foo to ~str dynamically in this scope only");
const request = require('request-promise');
const cheerio = require('cheerio');
const fs = require('fs-extra');
const writeStream = fs.createWriteStream('quotes.csv');
async function init() {
try {
// const response = await request('http://quotes.toscrape.com/');
const $ = await request({
@gaearon
gaearon / uselayouteffect-ssr.md
Last active November 26, 2025 07:31
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {