Skip to content

Instantly share code, notes, and snippets.

View jamesholcomb's full-sized avatar

James Holcomb jamesholcomb

View GitHub Profile
@sdgluck
sdgluck / query.js
Last active April 23, 2024 17:48
Pagination using Mongo: populate, match, sort, count, and limit with the aggregation pipeline
/**
* Query blog posts by user -> paginated results and a total count.
* @param userId {ObjectId} ID of user to retrieve blog posts for
* @param startRow {Number} First row to return in results
* @param endRow {Number} Last row to return in results
* @param [filter] {Object} Optional extra matching query object
* @param [sort] {Object} Optional sort query object
* @returns {Object} Object -> `{ rows, count }`
*/
function queryBlogPostsByUser (userId, startRow, endRow, filter = {}, sort = false) {
#!/usr/bin/env bash
# MongoDB port
PORT=27017
# Consul key to setup the lock
MONGO_KEY="mongodb/replicaset"
#
# Retrieve MongoDB instance IPs from Consul
#
@carlessanagustin
carlessanagustin / kubernetes.md
Created March 15, 2017 15:53
Kubernetes tutorial steps

1. Create cluster

Cluster up and running

minikube version
minikube start
kubectl version
@richardgill
richardgill / forcingRNAppUpgrades.js
Created March 16, 2017 14:42
Forcing React Native App Upgrades
import { Alert, Linking } from 'react-native'
import DeviceInfo from 'react-native-device-info'
import config from 'expresso-common/config'
import { platformIsIos } from 'expresso-common/common/platform'
import Firebase from 'firebase'
import semanticVersion from 'semver'
const attemptAndroidUpgrade = (appId) => {
const playStoreUri = `market://details?id=${appId}`
const playStoreUrl = `https://play.google.com/store/apps/details?id=${appId}`
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
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},
@Frizi
Frizi / build.sh
Last active November 12, 2018 22:53
gcloud cached docker build setup
#!/usr/bin/env bash
cd `dirname $0`/../..
set -e
IMAGE_NAME=eu.gcr.io/${PROJECT_ID}/${REPO_NAME}/$1
# Use multiple cache sources that make sense in given context.
# This setup is good for pull-request based CI, as most branches
# are based on master branch, each commit has a high chance
# to hit the cache of it's direct parent.
@infoslack
infoslack / cloudbuild.yaml
Last active November 13, 2018 00:44
example
steps:
# build steps
- name: 'gcr.io/cloud-builders/docker'
args: ['pull', 'gcr.io/$PROJECT_ID/project:latest']
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '--cache-from', 'gcr.io/$PROJECT_ID/project:latest', '-t', 'gcr.io/$PROJECT_ID/projetc:latest', '-t', 'gcr.io/$PROJECT_ID/project', '.' ]
- name: 'gcr.io/cloud-builders/docker'
args: [ 'tag', 'gcr.io/$PROJECT_ID/project', 'gcr.io/$PROJECT_ID/project:stable-v-$TAG_NAME']
@hardbyte
hardbyte / Automated TLS certificates on k8s.md
Last active September 17, 2018 22:00
Free automated TLS certificates on k8s

Cross posted from blog.n1analytics.com

At N1 Analytics we use Kubernetes for running experiments, continuous integration testing and deployment. In this post I document setting up a Kubernetes cluster to automatically provision TLS certificates from Let's Encrypt using Jetstack's Certificate Manager, the helm package manager and the nginx-ingress controller.

I wrote this after migrating our cluster from traefik to use cert manager and nginx-ingress. The end state will be one where we can create Kubernetes ingress with a TLS certificate with only a set of annotations in the respective helm template.

I'm going to assume some background knowlege for this post, if you haven't heard of [Let's Encrypt](https://letsencrypt.org/abou