Skip to content

Instantly share code, notes, and snippets.

View andrewsantarin's full-sized avatar

Cezar Andrew Villegas Santarin andrewsantarin

View GitHub Profile
@andrewsantarin
andrewsantarin / README.md
Last active September 8, 2023 09:41
Identifying successful race conditions in Promises

race.ts

Wrapper over Promise.race([...promises]) to identify which condition was met.

Method signature interface is identical to Redux Saga's race({...promiseMap}) method, but without Redux Saga as a requirement. Straight up plain JavaScript async...await without dependencies. In TypeScript, return type is also identified according to object key provided per Promise instance (in Redux Saga, a key is described as a "label"), so, there is clear indication of which key maps to which expected type of return value.

Method signature:

race({
@andrewsantarin
andrewsantarin / Sponge Cake.md
Last active June 19, 2020 18:13
The moron's colorful, comprehensive guide to making a sponge cake... based on a moron's personal experience

Sponge Cake

The one that often has fruit toppings & whipped cream in it & maybe even flavored like fruit, coffee, tea, etc. Known for its – surprise, surprise – spongy texture. Relatively easy to make & add variety to, but also very easy to screw up when careless / impatient.

Speaking of relatives...

  • Fruit cake
  • Chiffon cake
  • Swiss roll
  • Angel food cake
@andrewsantarin
andrewsantarin / README.md
Last active February 4, 2020 05:30
Grid-in-Grid for Ext.js v5.0.1
@andrewsantarin
andrewsantarin / MyInput.tsx
Last active May 12, 2023 20:13
React generic function component prop types in TypeScript
import React from 'react';
export type MyInputFieldProps<
NameType extends string = string,
ValueType extends string | string[] | number | undefined = string | string[] | number | undefined
> = Partial<{
name: NameType;
value: ValueType;
}>;
@andrewsantarin
andrewsantarin / react-intl-tel-input TypeScript Drop-In Support.md
Last active January 31, 2022 00:48
Drop-in TypeScript support for the 'react-intl-tel-input' module

react-auto-controlled explained

Some components

Suppose you have a component that uses an autocontrolled manager. Let's call it <Number />.

class Number extends React.Component {
  state = {
    // Initialize the component class instance with
    // the prop you provided from the outside.
 number: this.props.number || 0, // defaults to 0
@andrewsantarin
andrewsantarin / staticify TypeScript Drop-In Support.md
Last active June 27, 2021 23:06
Drop-in TypeScript support for the 'staticify' module
@andrewsantarin
andrewsantarin / example-layout.json
Last active April 25, 2019 06:57
Finding a tab parent panel through its tab ID (rc-dock)
{
"dockbox": {
"id": "+147",
"size": 200,
"mode": "horizontal",
"children": [
{
"id": "+135",
"size": 280,
"mode": "vertical",
@andrewsantarin
andrewsantarin / README.md
Created August 13, 2018 03:10 — forked from joelbowen/README.md
create-react-native-app environment variables

Steps:

  1. Rename your app.json file to base-app.json. This will be used as the template to generate the final app.json output.
  2. On your .gitignore file, add:
# ...your other ignored files

# use base-app.json instead because we're generating this file during builds.
app.json
  1. Follow this: https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe13.

    Note: mysql is already at v8.0.11 as of this point of writing, so make sure you explicitly install v5.7 by replacing mysql with mysql@5.7.

  2. Create a new entry into your PATH environment as the postinstall note suggests:

    # Edit the Terminal startup configuration file.
    open ~/.bash_profile
    
    

Copy this into the file and save.