Skip to content

Instantly share code, notes, and snippets.

View jamesholcomb's full-sized avatar

James Holcomb jamesholcomb

View GitHub Profile
@jamesholcomb
jamesholcomb / index.android.js
Last active May 20, 2017 15:15
Issue with getCurrentPosition location request timed out on Android
import React, { Component } from 'react'
import { StyleSheet, Alert, Text, View, PermissionsAndroid } from 'react-native'
function currentPosition() {
return new Promise((resolve, reject) =>
navigator.geolocation.getCurrentPosition(
({ coords }) => resolve(coords),
(err) => reject(err), {
enableHighAccuracy: false,
timeout: 1000,
@jamesholcomb
jamesholcomb / parse.js
Created April 22, 2017 16:57
Google Maps geocode address components to object using lodash
import _ from 'lodash'
const json = {
results: [] //...use actual results from API
}
const result = _.chain(json.results[0].address_components)
.keyBy('types[0]')
.mapValues('short_name')
.value()
@jamesholcomb
jamesholcomb / apns-test.js
Last active January 11, 2017 00:17
APNS auth token push notification test for Node
const PushNotifications = new require('node-pushnotifications')
const bundleId = '<BUNDLE_ID>'
const deviceToken = '<DEVICE_TOKEN>'
const settings = {
apn: {
token: {
"key": './certs/key.p8', // optionally: fs.readFileSync('./certs/key.p8')
"keyId": "<APNS_AUTH_KEY>",
"teamId": "<TEAM_ID>",
@jamesholcomb
jamesholcomb / appLinks.js
Created December 23, 2016 20:50
apple-app-site-association middleware for express
@jamesholcomb
jamesholcomb / feathers-upsert-before-create-hook.js
Last active February 23, 2017 15:01
A feathers.js before create hook to handle Mongoose upserts
// Use this hook to manipulate incoming or outgoing data.
// For more information on hooks see: http://docs.feathersjs.com/hooks/readme.html
import fromPairs from 'lodash/fromPairs'
import map from 'lodash/map'
/**
* upsert
* Executes upsert on a Mongoose model
* Configure in your service as a before:create hook
* Note: Update hooks will not fire as a result
@jamesholcomb
jamesholcomb / .bashrc
Last active January 29, 2016 16:30
bash setup
# git command autocompletion script
source ~/bin/git-completion.bash
# git commamands simplified
alias gst='git status'
alias gco='git checkout'
alias gci='git commit'
alias grb='git rebase'
alias gbr='git branch'
alias gad='git add -A'
@jamesholcomb
jamesholcomb / xd2md.cs
Created October 13, 2015 19:15 — forked from OldNo7/xd2md.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace Formix.Utils
{
class Program