Skip to content

Instantly share code, notes, and snippets.

@raulgrecio
raulgrecio / mock-axios.js
Created August 23, 2021 08:37 — forked from cowboy/mock-axios.js
axios mocking via interceptors
import axios from 'axios'
let mockingEnabled = false
const mocks = {}
export function addMock(url, data) {
mocks[url] = data
}
@raulgrecio
raulgrecio / createCtx-noNullCheck.tsx
Created November 9, 2019 11:00 — forked from swyxio/createCtx-noNullCheck.tsx
better createContext APIs with setters, and no default values, in Typescript. this is documented in https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/README.md#context
// create context with no upfront defaultValue
// without having to do undefined check all the time
function createCtx<A>() {
const ctx = React.createContext<A | undefined>(undefined)
function useCtx() {
const c = React.useContext(ctx)
if (!c) throw new Error("useCtx must be inside a Provider with a value")
return c
}
return [useCtx, ctx.Provider] as const
@raulgrecio
raulgrecio / docker_wordpress.md
Created September 24, 2019 08:51 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@raulgrecio
raulgrecio / docker_wordpress.md
Created September 24, 2019 08:51 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@raulgrecio
raulgrecio / lambda-function-package.json
Created June 22, 2016 15:34 — forked from satoshun00/lambda-function-package.json
Deploy AWS Lambda function with npm run script(ES6 transpile, mocha test)
{
"private": true,
"name": "my-function",
"version": "1.0.0",
"description": "my-function",
"main": "index.js",
"scripts": {
"test": "mocha --opts 'test/mocha.opts' 'test/**/*.test.js'",
"build-init": "rm -rf dist && rm -f archive.zip && mkdir dist",
"build:js": "babel index.js lib/*.js --out-dir dist",