Skip to content

Instantly share code, notes, and snippets.

View lfades's full-sized avatar

Luis Alvarez D. lfades

View GitHub Profile
@lfades
lfades / atomo.tsx
Created July 26, 2024 20:21
React Atomo
import {
useCallback,
useEffect,
useRef,
useState,
type DependencyList,
} from "react"
export interface Atom<Value>
extends Readonly<{
@lfades
lfades / .zshrc
Created December 18, 2018 20:16
Oh My Iterm
source $HOME/.bash_profile
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/lalvarezd/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
@lfades
lfades / Auth.js
Created October 11, 2018 19:06
Next.js Auth implementation: Apollo Server + Passport + Passport-jwt
/**
* server/dataSources/Auth.js
* Auth implementation, it's not really a dataSource so it doesn't need to be here
*/
const { authenticate, createJwt } = require('../lib/passport');
const { ON_HTTPS } = require('../configs');
const ONE_MINUTE = 1000 * 60;
const ONE_DAY = ONE_MINUTE * 60 * 24;
const ONE_MONTH = ONE_DAY * 30;
@lfades
lfades / .eslintrc
Created September 25, 2018 14:31
My personal linter config
{
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"plugins": [
"prettier"
],
"parser": "babel-eslint",
@lfades
lfades / page.jsx
Created February 22, 2018 20:34
Next with Stripe
function LoadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script')
script.src = src
script.addEventListener('load', resolve)
script.addEventListener('error', reject)
document.body.appendChild(script)
})
@lfades
lfades / .babelrc.json
Created October 13, 2017 16:35
Using separated babel config for server and client in Nextjs
{
"presets": ["node8"],
"plugins": [
["module-resolver", {
"root": ["."],
"alias": {
"~": "./server"
}
}]
]
@lfades
lfades / cloudSettings
Last active October 6, 2020 22:48
VS Code settings
{"lastUpload":"2020-10-06T22:48:06.882Z","extensionVersion":"v3.4.3"}
@lfades
lfades / async.js
Created May 23, 2017 22:34
Comparación entre async/await y promises utilizando un fragmento de codigo de mi implementación con Stripe.
/**
* async/await
*/
import request from 'request'
import express from 'express'
import { GraphQLError } from 'graphql/error'
import { STRIPE_API_KEY } from '../configs'
const server = express()
const TOKEN_URI = 'https://connect.stripe.com/oauth/token'