Skip to content

Instantly share code, notes, and snippets.

View nfantone's full-sized avatar
👨‍💻
Working from home

Nicolás Fantone nfantone

👨‍💻
Working from home
View GitHub Profile
@nfantone
nfantone / event.json
Created April 13, 2021 16:20
An AWS API Gateway Lambda event payload
{
"resource": "/",
"path": "/",
"httpMethod": "POST",
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en;q=0.9",
"cookie": "s_fid=7AAB6XMPLAFD9BBF-0643XMPL09956DE2; regStatus=pre-register",
"Host": "70ixmpl4fl.execute-api.us-east-2.amazonaws.com",
@nfantone
nfantone / before-shutdown.js
Created September 23, 2020 13:00
Node.js graceful shutdown handler
'use strict';
/**
* @callback BeforeShutdownListener
* @param {string} [signalOrEvent] The exit signal or event name received on the process.
*/
/**
* System signals the app will listen to initiate shutdown.
* @const {string[]}
@nfantone
nfantone / use-validation-schema.js
Last active May 29, 2024 01:55
Use `yup` with `react-final-form`
import { setIn } from 'final-form';
import { useMemo } from 'react';
/**
* Sets the `innerError.message` in an `errors` object at the key
* defined by `innerError.path`.
* @param {Object} errors The object to set the error in.
* @param {{ path: string, message: string }} innerError A `yup` field error.
* @returns {Object} The result of setting the new error message onto `errors`.
*/
@nfantone
nfantone / js-for-loop.js
Created July 28, 2020 03:19
The simplest JS loop
for (var i = 0; i < 10; i++) {
console.log(i);
}
@nfantone
nfantone / cache-invalidation-class.js
Created July 28, 2020 02:41
A simple class component holding a static reference
class MyExpensiveComponent extends React.Component {
myExpensiveField = null;
componentDidMount() {
this.myExpensiveField = createExpensiveField(this.props);
}
render() {
return <div>this.myExpensiveField.data</div>
}
using UnityEngine;
public class Mario1Controller2DScript : MonoBehaviour
{
//Movement related variables
public float moveSpeed; //Our general move speed. This is effected by our
//InputManager > Horizontal button's Gravity and Sensitivity
//Changing the Gravity/Sensitivty will in turn result in more loose or tighter control