Skip to content

Instantly share code, notes, and snippets.


Kenneth Taylor switchspan

View GitHub Profile
switchspan / reconnect.js
Created Nov 13, 2018 — forked from carlhoerberg/reconnect.js
How to build reconnect logic for amqplib
View reconnect.js
var amqp = require('amqplib/callback_api');
// if the connection is closed or fails to be established at all, we will reconnect
var amqpConn = null;
function start() {
amqp.connect(process.env.CLOUDAMQP_URL + "?heartbeat=60", function(err, conn) {
if (err) {
console.error("[AMQP]", err.message);
return setTimeout(start, 1000);
switchspan / gdrive.js
Created Aug 9, 2018 — forked from Teivaz/gdrive.js
Google Drive API V3 simple but working use case.
View gdrive.js
'use strict';
const driveUploadPath = '';
// 'id' is driveId - unique file id on google drive
// 'version' is driveVersion - version of file on google drive
// 'name' name of the file on google drive
// 'appProperties' keep the custom `ifid` field
const fileFields = 'id,version,name,appProperties';
switchspan /
Last active Jun 15, 2018
Mule Netsuite SavedSearch Criteria JavaComponent
import org.mule.api.MuleEventContext;
import org.mule.api.lifecycle.Callable;
import com.netsuite.webservices.lists.relationships.CustomerSearchAdvanced;
public class CustomerSearchAdvancedSavedComponent implements Callable {
public Object onCall(MuleEventContext eventContext) throws Exception {
CustomerSearchAdvanced searchCriteria = new CustomerSearchAdvanced();
switchspan / NetsuiteCustomCriteria.dwl
Last active Jun 15, 2018
Netsuite Mule Criteria via Dataweave
View NetsuiteCustomCriteria.dwl
%dw 1.0
%output application/java
email: {
operator: "IS",
searchValue: inboundProperties["http.query.params"].email
customFieldList: {
customField: [{
switchspan /
Created Jun 14, 2018 — forked from JeOam/
Install Java 8 on OS X

on El Capitan, after installing the brew...

$ brew update
$ brew tap caskroom/cask
$ brew install Caskroom/cask/java

And Java 8 will be installed at /Library/Java/JavaVirtualMachines/

Check version:


Build docker image

$ cd /path/to/Dockerfile
$ sudo docker build .

View running processes

switchspan /
Created Oct 15, 2017 — forked from Kartones/
PostgreSQL command line cheatsheet


Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
switchspan / postgres
Created Oct 12, 2017 — forked from mmrwoods/postgres
Postgres maintenance crontab file
View postgres
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
switchspan /
Created Mar 4, 2017 — forked from PurpleBooth/
A template to make good

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.


switchspan / brew-install-missing-unix-tools
Created Jun 24, 2016 — forked from evnm/brew-install-missing-unix-tools
A brew command to install useful tools missing from Mac OS X
View brew-install-missing-unix-tools
# Legitimately-useful utilities missing from OS X.
brew install wget watch gnu-sed coreutils
# Up-to-date versions of included tools.
brew install git emacs
# Just for fun.
brew install fortune cowsay