Skip to content

Instantly share code, notes, and snippets.

View skyrpex's full-sized avatar
👋

Cristian Pallarés skyrpex

👋
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
{
FROM bref/php-80-fpm
# Include any extension you want, for example:
#COPY --from=bref/extra-gd-php-73:0.9.5 /opt /opt
ADD . $LAMBDA_TASK_ROOT
CMD [ "index.php" ]
@sindresorhus
sindresorhus / esm-package.md
Last active April 24, 2024 09:47
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.
@jgerigmeyer
jgerigmeyer / click-outside.ts
Last active November 14, 2023 12:22
v-click-outside directive for Vue 3
/**
* Modified for Vue 3 from https://github.com/ndelvalle/v-click-outside
* Cf. https://github.com/ndelvalle/v-click-outside/issues/238
*/
import { DirectiveBinding, ObjectDirective } from 'vue';
const HANDLERS_PROPERTY = '__v-click-outside';
const HAS_WINDOWS = typeof window !== 'undefined';
const HAS_NAVIGATOR = typeof navigator !== 'undefined';
@reinink
reinink / query.sql
Last active November 14, 2023 11:08
Text search across multiple tables using MySQL
select
first_name,
last_name
from
users
left join
companies on companies.id = users.company_id
where (
companies.name like 'TERM%' or
first_name like 'TERM%' or
@KATT
KATT / favourite-ts-tricks.md
Last active July 26, 2023 06:16
🧙‍♂️ Favourite non-obvious TS tricks

Record<string, x | undefined>

Represent maps

// rather than 
const map: {[ key: string ]: string} = {
  foo: 'bar',
}
@themsaid
themsaid / AppServiceProvider.php
Created January 26, 2020 16:24
Re-encryption after APP_KEY rotation
<?php
namespace App\Providers;
use App\Encrypter;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@ServerlessBot
ServerlessBot / IAMCredentials.json
Last active December 20, 2023 16:50
Minimum credential set for Serverless Framework
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",
@branneman
branneman / salt-hash-password.js
Last active March 30, 2022 15:56
Node.js: Create salted hashed password
const crypto = require('crypto')
const { promisify } = require('util')
const pbkdf2 = promisify(crypto.pbkdf2)
module.exports = { createHashPasswordFn, isPasswordCorrect }
/**
* @typedef {Object} HashPassword
* @property {String} hash
* @property {String} salt
@leninalbertolp
leninalbertolp / settings.json
Last active April 23, 2023 17:40
Configuración para aplicar correctamente la fuente Operator Mono en VSCode
{
"editor.tokenColorCustomizations": {
"[El nombre del theme que estes usando]": {
"textMateRules": [
{
"scope": [
"comment",
"punctuation.definition.comment",
"comment.block",
"comment.line",