Skip to content

Instantly share code, notes, and snippets.

View jamesholcomb's full-sized avatar

James Holcomb jamesholcomb

View GitHub Profile
@jamesholcomb
jamesholcomb / initials.js
Last active April 8, 2019 20:28
Perform a best effort extraction of up to two initials from a space delimited name string
/**
* Perform a best effort extraction of up to two initials from a space delimited name string
* @param {string} text The text
* @return {string} The result
*/
function initials(text) {
if (!text) {
return ""
}
@jamesholcomb
jamesholcomb / print-master.sh
Created February 22, 2019 03:31
outputs the mongodb replica set master host name in a Kubernetes cluster
kubectl exec db-mongodb-replicaset-0 -- sh -c 'mongo --quiet --eval="printjson(rs.isMaster().primary)"' | sed 's/"//g' | awk -F\. '{print $1}'
@jamesholcomb
jamesholcomb / .bash_profile
Created October 6, 2018 20:46
bash_profile
export PATH=$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:/usr/local/sbin:$PATH
export GOPATH=$HOME/go
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
export CLICOLOR=1
alias k=kubectl
alias cat=bat
alias preview="fzf --preview 'bat --color \"always\" {}'"
# add support for ctrl+o to open selected file in VS Code
@jamesholcomb
jamesholcomb / script.sh
Last active March 21, 2018 13:32
Finds the folders which contain a node_modules folder
find . -name node_modules -type d -maxdepth 2
@jamesholcomb
jamesholcomb / kshell
Last active March 13, 2018 21:33 — forked from Stono/kshell
A shell script which enables easy execing into kube pods
#!/bin/sh
if [ "$1" = "" ]; then
echo "Usage: ./ksh <pod>"
exit 1
fi
echo Getting pods...
PODS=$(kubectl get pods --no-headers --output=name | grep $1)
PODS=(${PODS})
NUM_PODS=${#PODS[@]}
@jamesholcomb
jamesholcomb / node_modules_space.sh
Created January 18, 2018 15:52
Recursively finds the disk space used by folders named 'node_modules'
find . -name 'node_modules' -type d -prune -exec du -sh {} +
import React, {Component} from "react";
import {Animated, Dimensions, Platform, Text, View} from 'react-native';
import {Body, Header, List, ListItem as Item, ScrollableTab, Tab, Tabs, Title} from "native-base";
const NAVBAR_HEIGHT = 56;
const {width: SCREEN_WIDTH} = Dimensions.get("window");
const COLOR = "rgb(45,181,102)";
const TAB_PROPS = {
tabStyle: {width: SCREEN_WIDTH / 2, backgroundColor: COLOR},
activeTabStyle: {width: SCREEN_WIDTH / 2, backgroundColor: COLOR},
@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,
@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 / 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
}