Skip to content

Instantly share code, notes, and snippets.

View dabbott's full-sized avatar

Devin Abbott dabbott

View GitHub Profile
@dabbott
dabbott / Paging
Created March 8, 2015 18:17
nearestPage method
# Scroll to the nearest page
nearestPage = (layerCount, pageSize, value, velocity) ->
# Scroll position is negative... easier to think in terms of positive values
value = - value
lowerPageIndex = Math.max 0, Math.floor(value / pageSize)
upperPageIndex = Math.min (layerCount - 1), (lowerPageIndex + 1)
if velocity < -0.2
const once = require('once')
const fork = require('child_process').fork
class npm {
static run(cmd = [], opts = {}, cb) {
cb = once(cb)
console.log('run npm with', cmd, opts)
var stdout = ''
import React, { Component, } from 'react'
import {
View,
Image,
Text,
Dimensions,
ScrollView,
} from 'react-native'
const {height, width} = Dimensions.get('window')
@dabbott
dabbott / component.js
Last active June 26, 2016 02:32
Sample component template
import React, { Component } from 'react'
import { View } from 'react-native'
export default class {{{filename}}} {
constructor() {
super()
this.state = {}
}
}
@dabbott
dabbott / How to git.md
Last active August 6, 2016 22:29
How to git

Git Basics

Basic Commands

There are 5 main commands you'll use with git.

git pull - download any new changes made by other people from the shared repository on GitHub

git push - upload any new changes that you made on your local repository to the shared repository

@dabbott
dabbott / test.js
Last active August 17, 2016 17:01
window.Test = {
getText: function() {
return 'Hello, World!'
}
}
const sceneData = {
scenes: [
{id: '1', x: 0, y: 0, width: 375, height: 667},
{id: '2', x: 400, y: 0, width: 375, height: 667},
{id: '3', x: 800, y: 0, width: 375, height: 667},
],
connections: [
{from: '1', to: '3', label: 'onPress'},
{from: '2', to: '1', label: 'onPress'},
@dabbott
dabbott / actions_index.js
Last active September 4, 2016 17:52
React Project Styleguide
export * as testActions, { at as testConstants } from './testActions'
import { AppRegistry } from 'react-native'
let entry = require('actual-entry-file.js')
// Check if we're dealing with ES6-style imports
if (typeof entry === 'object' && entry !== null && entry._esModule) {
// If we are, pick the default import
entry = entry.default
}
@dabbott
dabbott / Editor.js
Last active September 23, 2016 22:42
Tab Content Management
import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as TabContentUtils from '../utils/TabContentUtils'
class Editor extends Component {
...
}
const ConnectedClass = connect()(Editor)