Skip to content

Instantly share code, notes, and snippets.

View ronal2do's full-sized avatar

Ronaldo Lima ronal2do

View GitHub Profile
@ronal2do
ronal2do / AppStrings.js
Created February 4, 2019 11:40 — forked from BrianJVarley/AppStrings.js
Mocking react-native-localization package in jest spec
// ES6 module syntax
import LocalizedStrings from 'react-native-localization';
let AppStrings = new LocalizedStrings({
'en-US': {
settingMenuOptionOne: 'Centimeters ({0})',
},
en: {
settingMenuOptionOne: 'Centimeters ({0})',
},
@ronal2do
ronal2do / gatsby-ssr.js
Created January 29, 2019 11:17 — forked from LawJolla/gatsby-ssr.js
Apollo + Gatsby SSR
import React from 'react'
import { renderToString, renderToStaticMarkup } from 'react-dom/server'
import ApolloClient, { createNetworkInterface, } from 'apollo-client'
import { ApolloProvider, getDataFromTree } from 'react-apollo'
// Apollo Setup
const networkInterface = createNetworkInterface({
uri: process.env.GRAPHCOOL_API
})
@ronal2do
ronal2do / mapbox-custom-camera.js
Created September 26, 2018 12:25 — forked from kristfal/mapbox-custom-camera.js
Mapbox camera snippets
const cameraValid = camera =>
camera && camera.geometry && Array.isArray(camera.geometry.coordinates);
// Workaround for Mapbox issue
// https://github.com/mapbox/react-native-mapbox-gl/issues/1126
export const enforceIntegerPadding = padding =>
padding.map(value => parseInt(value, 10));
export const isValidBounds = camera =>
camera &&
@ronal2do
ronal2do / resolvePromise.js
Created September 9, 2018 08:23 — forked from mjackson/resolvePromise.js
An easy way to do async APIs in JavaScript that support both promises *and* callbacks!
// Here is a function that I use all the time when creating public
// async APIs in JavaScript:
const resolvePromise = (promise, callback) => {
if (callback)
promise.then(value => callback(null, value), callback)
return promise
}
// Sometimes I like to use callbacks, but other times a promise is
@ronal2do
ronal2do / react-native-double-tap.js
Created September 5, 2018 18:45 — forked from brunotavares/react-native-double-tap.js
Double tap gesture recognition for React Native.
const DOUBLE_PRESS_DELAY = 300;
// ...
/**
* Double Press recognition
* @param {Event} e
*/
handleImagePress(e) {
const now = new Date().getTime();
@ronal2do
ronal2do / MongoDB_macOS_Sierra.md
Created August 22, 2018 19:58 — forked from nrollr/MongoDB_macOS_Sierra.md
Install MongoDB on Sierra using Homebrew

Install MongoDB on macOS Sierra

This procedure explains how to install MongoDB using Homebrew on macOS Sierra 10.12.
Official MongoDB install documentation: here

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
import paramsToProps from 'paramsToProps.js'
const MainNavigator = StackNavigator({
firstScreen: { screen: paramsToProps(FirstScreenComponent) },
secondScreen: { screen: paramsToProps(SecondScreenComponent) },
});
import paramsToProps from 'paramsToProps.js'
const MainNavigator = StackNavigator({
firstScreen: { screen: paramsToProps(FirstScreenComponent) },
secondScreen: { screen: paramsToProps(SecondScreenComponent) },
});