Skip to content

Instantly share code, notes, and snippets.

View jamesreggio's full-sized avatar

James Reggio jamesreggio

View GitHub Profile
@jamesreggio
jamesreggio / webview-link-probe.js
Last active August 31, 2015 21:55
Script to probe for links on a page that may not function correctly inside of a WebView control
@jamesreggio
jamesreggio / ractivejs-components-repro.htm
Created December 12, 2013 20:20
This Gist illustrates a bug in the latest version of Ractive.js (0.3.7).
<!--
This Gist illustrates a bug in the latest version of Ractive.js (0.3.7).
Download and open this file on your local machine to view the repro.
When an array is shared between the root Ractive view model and a
component (Child), the array's `_ractive.roots` cache will originally contain
`[Ractive, Child]`. However, when the array is modified from within the child,
the cache is reconstructed in the opposite order: `[Child, Ractive]`. It is
unclear whether this difference in ordering is itself a bug, or whether it
just happens to surface a bug in other code.
@jamesreggio
jamesreggio / react-sortable.htm
Last active December 31, 2015 04:39 — forked from petehunt/React sortable
This Gist demonstrates how to use an invasive jQuery plugin (UI Sortable) with the latest version of React (0.5.1). It is a simplified (and perhaps unconventional) approach to what @petehunt built in https://gist.github.com/petehunt/7882164.
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://fb.me/react-0.5.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script>
</head>
@jamesreggio
jamesreggio / IDYN-842-bug.md
Last active August 3, 2016 17:59
Bug report on UIScrollView or WKWebView, discovered while addressing Twitter IDYN-842

Keyboard inset adjustment double-counts toolbar height in WKWebView or UIScrollView

Since iOS 7, the navigation bar and toolbar[0] in a UINavigationController are designed to render atop the content of the current UIViewController. In order to prevent these bars from occluding the contents of the view, UINavigationController will (under certain conditions) automatically reach down the view hierarchy and adjust the insets of the primary UIScrollView, such that the content is padded by the height of these bars.

The system keyboard is also designed to occlude the bottom half of the screen by default. In most cases, this is undesirable, so the app developer is expected to subscribe to NSNotificationCenter keyboard events and adjust the UIScrollView insets themselves.

WKWebView automatically subscribes to th

@jamesreggio
jamesreggio / index.ios.js
Created February 6, 2017 22:31
Repro for an uninitialized memory issue in React Native 0.41.1
// The underlying issue pertains to uninitialized memory and is inherently non-deterministic.
// This will consistently reproduce for me using React Native 0.41.1 on iOS 9.3, but it will not reproduce on iOS 10.2.
// If the app launches and does not immediately display a redbox with an error, the bug did not reproduce.
import React, { Component } from 'react';
import { AppRegistry, View } from 'react-native';
export default class App extends Component {
constructor() {
super();
@jamesreggio
jamesreggio / index.ios.js
Created July 28, 2017 13:28
Repro for an issue with frame calculations in VirtualizedList in React Native 0.46.4
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
FlatList,
Text,
View
} from 'react-native';
const ITEMS = 100;
@jamesreggio
jamesreggio / authContextLink.js
Created October 30, 2017 15:37
Setting an authorization header in Apollo Client 2.0
@jamesreggio
jamesreggio / apollo.js
Created October 30, 2017 15:51
Mostly complete Apollo Client 2.0 initialization code
export default async (services) => {
// Links.
const contextLink = new ApolloLink((operation, forward) => {
operation.setContext(context => update(context, {
headers: {
$apply: (headers = {}) => {
headers = {
...headers,
@jamesreggio
jamesreggio / apollo-cache-persist-quickstart-rn.js
Last active December 11, 2017 18:04
apollo-cache-persist quickstart example for React Native
import { InMemoryCache } from ‘apollo-cache-inmemory’;
import { persistCache } from ‘apollo-cache-persist’;
import { AsyncStorage } from ‘react-native’;
// Set up your cache.
const cache = new InMemoryCache({...});
// Set up cache persistence.
persistCache({
cache,
@jamesreggio
jamesreggio / apollo-cache-persist-quickstart-web.js
Last active December 12, 2017 19:57
apollo-cache-persist quickstart example for web
import { InMemoryCache } from ‘apollo-cache-inmemory’;
import { persistCache } from ‘apollo-cache-persist’;
// Set up your cache.
const cache = new InMemoryCache({...});
// Set up cache persistence.
persistCache({
cache,
storage: window.localStorage,