Skip to content

Instantly share code, notes, and snippets.

View jzfgo's full-sized avatar
🤓

Javier Zapata jzfgo

🤓
View GitHub Profile
import { User } from 'payload/dist/auth';
import { Access, AccessArgs, FieldAccess } from 'payload/types';
type CheckerArgs = {
user?: User;
id?: string | number;
};
type Checker = (args: CheckerArgs) => boolean;
const isAdmin: Checker = ({ user }) => user?.role && user?.role === 'admin';
@wescpy
wescpy / google-apis.txt
Last active October 1, 2024 07:36
Google APIs service names/endpoints (Sep 2024)
$ gcloud services list --available --filter="name:googleapis.com"
NAME TITLE
abusiveexperiencereport.googleapis.com Abusive Experience Report API
acceleratedmobilepageurl.googleapis.com Accelerated Mobile Pages (AMP) URL API
accessapproval.googleapis.com Access Approval API
accesscontextmanager.googleapis.com Access Context Manager API
actions.googleapis.com Actions API
addressvalidation.googleapis.com Address Validation API
adexchangebuyer.googleapis.com Ad Exchange Buyer API II
@rmtuckerphx
rmtuckerphx / direnv-win.md
Last active September 6, 2024 18:46
Steps to install direnv on Windows

direnv on Windows

Overview

In JavaScript projects, I used to use dotenv so that I could put local environment variables in a .env file for local development. But dotenv requires you to add code to your project. With direnv, you can put local env vars in a .envrc file and those env vars are loaded automatically in the shell.

Steps to install

For these steps, it is assummed that you have installed Git Bash on Windows. I also use VSCode as my editor.

  1. Create a folder such as c:\tools to put the direnv.exe file and add it to the Windows PATH
@bengry
bengry / app.module.ts
Created December 26, 2019 07:32
Nest.js request context workaround
import { MiddlewareConsumer, Module, NestModule } from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { RequestContextMiddleware } from "./request-context/request-context.middleware";
import { RequestContextModule } from "./request-context/request-context.module";
@Module({
imports: [
ConfigModule.load(path.resolve(__dirname, "config", "**/!(*.d).{ts,js}")),
WebappUsersModule,
RequestContextModule,
@zarv1k
zarv1k / abstract-unique-validator.ts
Last active August 28, 2024 08:26
Unique Validator Example for NestJS
import { ValidationArguments, ValidatorConstraintInterface } from 'class-validator';
import { Connection, EntitySchema, FindConditions, ObjectType } from 'typeorm';
interface UniqueValidationArguments<E> extends ValidationArguments {
constraints: [
ObjectType<E> | EntitySchema<E> | string,
((validationArguments: ValidationArguments) => FindConditions<E>) | keyof E,
];
}
@loganvolkers
loganvolkers / Byte Formatting for Google Sheets.md
Last active November 18, 2024 19:08
Byte formatting for Google Sheets
@swyxio
swyxio / Gatsby-bootstrap-lifecycle.md
Last active April 1, 2022 11:19
Gatsby bootstrap lifecycle

Sequence of Gatsby's bootstrap lifecycle with links to source code as of v2.0.0

  1. open and validate gatsby-config (get-config-file.js) 1.5 load themes (swyx added this note July 2019)
  2. load plugins (load-plugins/index.js) from the list given in gatsby-config.js
  3. onPreBootstrap: runs onPreBootstrap if it is implemented in any plugins, for example gatsby-plugin-typography. Receives handy [apiCallArgs](https://github.com/gatsbyjs/gatsby/blob/ffd8b2d691c9

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@wassname
wassname / .eslintrc.js
Last active September 14, 2023 23:57
eslint.recommended (annotated)
/**
* eslint.recommended (annotated)
* ================
* Annotated defaults based on eslint.recommended
*
* @author: wassname
* @license: MIT
* @website https://gist.github.com/wassname/4693303388396c5f074b10865a969b43
* @date 2017-11-13T23:08
* @eslint-version: 4.11.0
#/usr/bin/env bash
# Install some pacakages we'll need to compile the driver below.
sudo dnf install gcc kernel-devel -y
# Create working dir for Broadcom driver files and patches.
mkdir hybrid_wl_f23
# Change to working dir.
cd hybrid_wl_f23