Skip to content

Instantly share code, notes, and snippets.

View mcavaliere's full-sized avatar

Mike Cavaliere mcavaliere

View GitHub Profile
@cullylarson
cullylarson / config.ts
Last active January 30, 2024 14:23
Example configuration file
const stages = ['production', 'staging', 'development', 'test'] as const;
type Stage = typeof stages[number];
function getStage(stages: Stage[]) {
if (!stages.length) return 'production';
for (const stage of stages) {
// if any of the provided stages is production, assume we are in production
if (stage === 'production') {
@jsjoeio
jsjoeio / notes.md
Last active November 3, 2021 14:31
Julian's Writing Workshop - 11/2/2021 - Notes

Raw Notes

These are my unstructured notes from the workshop. Read with caution (they're biased to my own interpretation).

Notes

1,000,000 Julian.com visitors

Part 1: What's your objective for your article?

Part 2: pair it with an objective

@slikts
slikts / advanced-memo.md
Last active April 27, 2024 02:40
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@slikts
slikts / react-memo-children.md
Last active April 27, 2024 02:44
Why using the `children` prop makes `React.memo()` not work

nelabs.dev

Why using the children prop makes React.memo() not work

I've recently ran into a pitfall of [React.memo()][memo] that seems generally overlooked; skimming over the top results in Google just finds it mentioned in passing in a [React issue][regit], but not in the [FAQ] or API [overview][react-api], and not in the articles that set out to explain React.memo() (at least the ones I looked at). The issue is specifically that nesting children defeats memoization, unless the children are just plain text. To give a simplified code example:

const Memoized = React.memo(({ children }) => (<div>{children}</div>));
// Won't ever re-render
<Memoized>bar</Memoized>
// Will re-render every time; the memoization does nothing
@henrikhaugboelle
henrikhaugboelle / app.test.js
Last active February 16, 2021 08:28
Example of running appium locally on android device with jest and async/await.
/**
* Example of running BrowserStacks Appium WikipediaSample test app locally
* using jest and async/await instead of promise chains.
*
* Before running, you should install appium and make sure that all dependencies
* are met with appium-doctor. Get started at:
*
* http://appium.io/docs/en/about-appium/getting-started/?lang=en
*/
@joelbowen
joelbowen / README.md
Last active September 19, 2018 13:49
create-react-native-app environment variables

Change your app.json to base-app.json and untrack the original file in your .gitignore

Then add something like "generateConfig": "rimraf app.json &amp;&amp; node generateConfig" to your package.json scripts, and yarn generateConfig &amp;&amp; react-native-scripts start to scripts like "start" or any others that may need app.json generated.

@andrewmunro
andrewmunro / .babelrc
Created July 17, 2017 11:30
Sequelize cli with ES6
{
"presets": ["es2015"],
"plugins": [
"add-module-exports"
],
}
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active April 15, 2024 09:41
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@leaysgur
leaysgur / index.ios.js
Last active May 22, 2020 15:21
getUserMedia() w/ React Native WebRTC
// @flow
import React, { Component } from 'react';
import {
AppRegistry,
Button,
StyleSheet,
Text,
View
} from 'react-native';
import {
<?php
/**
* Template Name: Testimonials - Native Functions
*/
add_action( 'genesis_entry_content', 'prefix_output_testimonials' );
/**
* Output ACF testimonials.
*
* @link https://acfextras.com/simple-testimonials-repeater-field/