Skip to content

Instantly share code, notes, and snippets.

Avatar

Kenneth Taylor switchspan

View GitHub Profile
@switchspan
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
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 = 'https://www.googleapis.com/upload/drive/v3/files';
// '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
switchspan / CustomerSearchAvancedSavedComponent.java
Last active Jun 15, 2018
Mule Netsuite SavedSearch Criteria JavaComponent
View CustomerSearchAvancedSavedComponent.java
import org.mule.api.MuleEventContext;
import org.mule.api.lifecycle.Callable;
import com.netsuite.webservices.lists.relationships.CustomerSearchAdvanced;
public class CustomerSearchAdvancedSavedComponent implements Callable {
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
CustomerSearchAdvanced searchCriteria = new CustomerSearchAdvanced();
@switchspan
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
switchspan / Java.md
Created Jun 14, 2018 — forked from JeOam/Java.md
Install Java 8 on OS X
View Java.md

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/jdk1.8.xxx.jdk/

Check version:

View docker-cheat-sheat.md

Build docker image

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

View running processes

@switchspan
switchspan / postgres-cheatsheet.md
Created Oct 15, 2017 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

PSQL

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
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
switchspan / README-Template.md
Created Mar 4, 2017 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

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.

Prerequisites

@switchspan
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