Skip to content

Instantly share code, notes, and snippets.

View jamesreggio's full-sized avatar

James Reggio jamesreggio

View GitHub Profile
@jamesreggio
jamesreggio / boost.js
Created August 26, 2023 17:42 — forked from radermacher/boost.js
Arc ChatGPT Boost
// fork of https://gist.github.com/b-nnett/2749adb44566239e4c85ad1a8937c2bc
// origin by @B_nnett → https://twitter.com/joshm/status/1648346253355282432?s=20
/*
To set up this boost for chat.openai.com:
1) open Arc browser and login at chat.openai.com.
2) Head over to the + button in your sidebar and select New Boost.
Or hit ⌘ + T and type New Boost into your Command Bar.
3) Click the `Code` button.
@jamesreggio
jamesreggio / react-native-instrument-startup.patch
Created January 20, 2019 01:26
Patch to instrument JavaScriptCore startup time in React Native 0.56.0
From 76ad8283e5de2a0733cbac375c0c16d1d03de891 Mon Sep 17 00:00:00 2001
From: James Reggio <james.reggio@gmail.com>
Date: Wed, 14 Feb 2018 18:57:24 -0500
Subject: [PATCH] add trace statements to JSCLoadApp fn
---
ReactCommon/cxxreact/JSCExecutor.cpp | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp
@jamesreggio
jamesreggio / App.js
Created September 19, 2018 17:47
Example of proposed imperative StatusBar API for React Native
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, StatusBar} from 'react-native';
const instructions = `
This app demonstrates the proposed imperative stack-manipulation methods on \`StatusBar\`.
`;
const pad = (value, width) => (
`${value}${Array(width - String(value).length).fill(' ').join('')}`
);
@jamesreggio
jamesreggio / react-forwardref-banter-logged.js
Last active August 27, 2018 21:54
Log output showing the broken interaction between React.forwardRef and hoist-non-react-statics
// Even though CurrentEpisodeWaveform is a component class that
// properly composes the three HOCs with Waveform, its static
// properties make it appear like a `forwardRef` component type.
const CurrentEpisodeWaveform = compose(
withCurrentEpisode,
withEpisodeAmplitudes,
withSize
)(Waveform);
@jamesreggio
jamesreggio / react-forwardref-banter-example.js
Last active August 27, 2018 21:43
Example of broken interaction between React.forwardRef and hoist-non-react-statics
// Waveform.js
import React, { Component } from 'react';
export default class Waveform extends Component {
static MIN_AMPLITUDE = 0;
static MAX_AMPLITUDE = 100;
render() {
console.log('Received props:', Object.keys(this.props));
@jamesreggio
jamesreggio / react-forwardref-output.js
Last active August 27, 2018 20:29
Example showing the component type object returned from React.forwardRef
const WrappedInput = React.forwardRef((props, ref) => (
<input ref={ref} {...props} />
));
console.log(WrappedInput);
// => Object {
// $$typeof: Symbol(react.forward_ref),
// render: (props, ref) => <input ref={ref} {...props} />,
// }
@jamesreggio
jamesreggio / react-forwardref-simple-example.js
Last active September 21, 2024 06:31
Simple example usage of React.forwardRef()
// EmailInput wraps an HTML `input` and adds some app-specific styling.
const EmailInput = React.forwardRef((props, ref) => (
<input ref={ref} {...props} type="email" className="AppEmailInput" />
));
class App extends Component {
emailRef = React.createRef();
render() {
return (
@jamesreggio
jamesreggio / patch-react-redux-forwardRef.sh
Last active August 24, 2018 18:35
Self-applying patch to work around react-redux#914 (invariant failures when using `connect` upon a component wrapped in `React.forwardRef`)
#!/bin/sh
###############################################################################
# USAGE
###############################################################################
# 1. Install the `react-is` package in your project with
# `npm i --save react-is` or `yarn add react-is`.
#
# 2. Place this script in the root of your repository, alongside `package.json`.
#
@jamesreggio
jamesreggio / example.js
Created June 5, 2018 18:24
MetaQuery example in reply to @gunar
const ProductsQueryWithConfigurableFragment = `
query {
products {
...ProductFragment
}
}
`;
const SlimProductFragment = `
fragment ProductFragment on Product {
@jamesreggio
jamesreggio / error.txt
Created May 21, 2018 14:08
Repro for apollo-cache-inmemory stack overflow issue
RangeError: Maximum call stack size exceeded
at Array.forEach (native)
at merge (blob:file:///71f10210-bc6a-4c31-bb2d-281064e4b98f:64781:24)
at blob:file:///71f10210-bc6a-4c31-bb2d-281064e4b98f:64787:11
at Array.forEach (native)
at merge (blob:file:///71f10210-bc6a-4c31-bb2d-281064e4b98f:64781:24)
at blob:file:///71f10210-bc6a-4c31-bb2d-281064e4b98f:64787:11
at Array.forEach (native)
at merge (blob:file:///71f10210-bc6a-4c31-bb2d-281064e4b98f:64781:24)
at blob:file:///71f10210-bc6a-4c31-bb2d-281064e4b98f:64787:11