Skip to content

Instantly share code, notes, and snippets.

View jamesholcomb's full-sized avatar

James Holcomb jamesholcomb

View GitHub Profile
@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
@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 / 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 / appLinks.js
Created December 23, 2016 20:50
apple-app-site-association middleware for express
@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 / 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 / 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 / fnName.js
Created June 27, 2017 22:32
Get function name from inside scope
const myCoolFunc = () => {
const name = new Error().stack.match(/at (.*?) /)[1]
console.log(name) // myCoolFunc
}
@jamesholcomb
jamesholcomb / pubsub-kefir.js
Created November 1, 2017 03:08 — forked from antonioaguilar/pubsub-kefir.js
Simple PubSub using KefirJS (version 1)
( function(root, factory) {
root.pubsub = factory(root);
}(this, function() {
var publishEmitter;
var directory;
var eventStream;
var SubscriptionDefinition = function(stream, callback) {
this.stream = stream;
@jamesholcomb
jamesholcomb / SegmentedControl.js
Last active November 6, 2017 22:52
React Native Segmented Control Tab
// From https://github.com/kirankalyan5/react-native-segmented-control-tab
// Added enabled prop
// Use Material theme Indigo color defaults
// Add propType validation
// Lower opacity for disabled
// Fix border and width issues for Android
import React from "react"
import {
View,
ViewPropTypes,