Skip to content

Instantly share code, notes, and snippets.

Avatar

Eloy Durán alloy

View GitHub Profile
View Survey.jsx
import React from "react"
import { NativeModules } from "react-native"
const SurveyManager = NativeModules.SurveyManager
class Survey extends React.Component {
componentDidMount() {
SurveyManager.start({ ... }, prompt => {
this.setState({ prompt })
})
View omit-c++-bits-from-RCTImageLoader.diff
diff --git a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h
index 119fb8fb5a..6840cdd57a 100644
--- a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h
+++ b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h
@@ -17,6 +17,7 @@ RCT_EXTERN void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled);
@protocol RCTImageLoaderWithAttributionProtocol<RCTImageLoaderProtocol>
+#ifdef __cplusplus
/**
View adding-more-native-to-your-react-native-app.md

React Native Link

Who am I?

  • Eloy Durán
  • @alloy
  • Author of CocoaPods
  • Engineer at Artsy, where we’ve been using React Native for 3.5 years in our brownfield app

What will you learn from this presentation?

View 1-before-react_redesign.jade.js
(function anonymous(locals, jade
) {
var jade_debug = [ new jade.DebugItem( 1, "/Users/eloy/Code/Artsy/force/src/desktop/components/main_layout/templates/react_redesign.jade" ) ];
try {
var buf = [];
var jade_mixins = {};
var jade_interp;
;var locals_for_with = (locals || {});(function (JSON, Object, asset, assetPackage, body, bodyClass, css, data, defaultOptions, head, helpers, jsonLD, options, scripts, sd, sharify, stitch, styleTags, styledComponents, user, userAgent) {
jade_debug.unshift(new jade.DebugItem( 0, "/Users/eloy/Code/Artsy/force/src/desktop/components/main_layout/templates/redesign.jade" ));
jade_debug.unshift(new jade.DebugItem( 1, "/Users/eloy/Code/Artsy/force/src/desktop/components/main_layout/templates/redesign.jade" ));
@alloy
alloy / steps.sh
Created Sep 11, 2019
Build Swift
View steps.sh
git clone https://github.com/llvm/llvm-project.git
ln -s llvm-project/llvm
ln -s llvm-project/clang
git clone https://github.com/apple/swift-cmark cmark
git clone https://github.com/apple/swift
cd swift
./utils/build-script --release-debuginfo
View 0-base-schema.graphql
# This is just the base schema shared by the two options below.
type User {
name: String
friendships: FriendshipConnection
}
type Friendship {
establishedAt: String
withUser: User
View sigh_modules.md

So here's (part of) the problem:

  • When you use require in Node, Node will look at the closest node_modules and if it can’t find it there look in the parent dir for a node_modules install that has it, until it reaches /.

  • When you ‘link’ npm/yarn do nothing else but create a symlink in your node_modules to the package that presumable lives outside of the tree your app lives in (eg it’s a sibling).

  • Now when your linked package tries to require something and it can’t find it in its own node_modules where should it look? The (real) parent dir isn’t the app, but that’s the default behaviour anyways, so it will fail

  • “But how could that package not be in the linked package’s node_modules?!” you ask, which is a very valid question.

@alloy
alloy / graphql+0.13.2.patch
Last active Apr 20, 2019
relay-compiler v3 clickable error messages
View graphql+0.13.2.patch
patch-package
--- a/node_modules/graphql/error/printError.js
+++ b/node_modules/graphql/error/printError.js
@@ -53,7 +53,7 @@ function highlightSourceAtLocation(source, location) {
var padLen = nextLineNum.length;
var lines = source.body.split(/\r\n|[\n\r]/g);
lines[0] = whitespace(source.locationOffset.column - 1) + lines[0];
- var outputLines = [source.name + ' (' + contextLine + ':' + contextColumn + ')', line >= 2 && lpad(padLen, prevLineNum) + ': ' + lines[line - 2], lpad(padLen, lineNum) + ': ' + lines[line - 1], whitespace(2 + padLen + contextColumn - 1) + '^', line < lines.length && lpad(padLen, nextLineNum) + ': ' + lines[line]];
+ var outputLines = [source.name + ':' + contextLine + ':' + contextColumn, line >= 2 && lpad(padLen, prevLineNum) + ': ' + lines[line - 2], lpad(padLen, lineNum) + ': ' + lines[line - 1], whitespace(2 + padLen + contextColumn - 1) + '^', line < lines.length && lpad(padLen, nextLineNum) + ': ' + lines[line]];
return outputLines.filter(Boolean).join('\n');
View js-to-native.json
{
"type": "many-events",
"events": [{
"type": "event",
"evt": "update",
"data": {
"nodeType": "Native",
"key": null,
"ref": null,
"source": {
View type-emission.html
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Type Emission · Relay</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="&lt;p&gt;As part of its normal work, &lt;code&gt;relay-compiler&lt;/code&gt; will emit type information for your language of choice that helps you write type-safe application code. These types are included in the artifacts that &lt;code&gt;relay-compiler&lt;/code&gt; generates to describe your operations and fragments.&lt;/p&gt;
"/><meta name="docsearch:version" content="next"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Type Emission · Relay"/><meta property="og:type" content="website"/><meta property="og:url" content="https://facebook.github.io/relay/index.html"/><meta property="og:description" content="&lt;p&gt;As part of its normal work, &lt;code&gt;relay-compiler&lt;/code&gt; will emit type
You can’t perform that action at this time.