Skip to content

Instantly share code, notes, and snippets.

View williamtran29's full-sized avatar
🏠
Working from home

William Tran williamtran29

🏠
Working from home
  • Freelancer
  • Silicon Valley
View GitHub Profile
@williamtran29
williamtran29 / SectionListView.js
Last active September 15, 2020 21:13
[React Native ListView] Scroll to a section by a sectionId, Scroll to a row by a rowId, Receive callbacks when a section changes, Pinned Section and more...
import React, {
Component,
PropTypes
} from 'react'
import {
ListView
} from 'react-native'
// arbitrarily large distance to pre-render all sections for measurements
const RENDER_AHEAD_DISTANCE = 1000000
@williamtran29
williamtran29 / FadeIn.js
Last active April 25, 2017 10:56
Create FadeIn Animation for any React Native Component
/* @flow */
import React, { Component, PropTypes } from 'react'
import {
Animated
} from 'react-native'
export default class FadeIn extends Component {
static propTypes = {
children: PropTypes.node,
@williamtran29
williamtran29 / App.js
Created June 29, 2017 12:17 — forked from knowbody/App.js
Check internet connection in React Native app
// quick snippet to check the connection in your RN app
// dispatches an `setIsConnected` action every time the NetInfo changes (on/off network)
componentDidMount() {
const dispatchConnected = isConnected => this.props.dispatch(setIsConnected(isConnected));
NetInfo.isConnected.fetch().then().done(() => {
NetInfo.isConnected.addEventListener('change', dispatchConnected);
});
}
import React from 'react';
import User from './User';
import { connect } from 'react-redux';
import { fetchUsers } from '../actions/index';
import { lifecycle, compose } from 'recompose';
const enhance = compose(
lifecycle({
componentDidMount() {
this.props.fetchUsers();
import { compliment, compose, get } from 'lodash/fp';
import { connect } from 'react-redux';
import { branch, renderComponent } from 'recompose';
const selectIsAuthenticated = state => ({
isAuthenticated: Boolean(state.currentUser),
});
const withAuth = compose(
connect(selectAuthorizationStatus),
@williamtran29
williamtran29 / Ethereum-Rinkeby
Created October 15, 2017 13:43
0x10dDBD1079f4Ac4797e9A374CDDB8BC9F84fCe39
0x10dDBD1079f4Ac4797e9A374CDDB8BC9F84fCe39
@williamtran29
williamtran29 / elixir_timer_interval.exs
Created December 23, 2017 18:04 — forked from kandros/elixir_timer_interval.exs
Set an interval in elixir-lang using erlang timer module
:timer.apply_interval(1000, IO, :puts, ["weeeee"]) # millisends, module, function as atom, list of arguments
set mouse=""
set tabstop=2
set clipboard=unnamedplus
set softtabstop=2
set expandtab
set shiftwidth=2
set autoread
set autoindent
set si
set nobackup
@williamtran29
williamtran29 / .eslintrc
Created May 6, 2018 09:44 — forked from radiovisual/.eslintrc
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
# for development
pm2 start npm --name "next" -- run dev
# for production
npm run build
pm2 start npm --name "next" -- start
"scripts": {
"start": "node ./node_modules/.bin/pm2 start app.js -i max --attach"