Skip to content

Instantly share code, notes, and snippets.

View cpsubrian's full-sized avatar

Brian Link cpsubrian

  • Dropbox
  • Fremont, CA
View GitHub Profile
@cpsubrian
cpsubrian / bookmarklet.js
Last active October 12, 2019 00:06
Test Bookmarklet -- Pinkify
javascript:(function(){var src="https://gist.githack.com/cpsubrian/90fffb1a826143a59364a449b4c586a6/raw/3a0bf7f8b97ba31d7836843fd24dd66ef4c31707/pinkify.js";document.body.appendChild(document.createElement('script')).setAttribute('src', src);})();
@cpsubrian
cpsubrian / .dockerignore
Created October 12, 2017 21:16
Docker Node App
# add git-ignore syntax here of things you don't want copied into docker image
.git
.data
*Dockerfile*
*docker-compose*
node_modules
@cpsubrian
cpsubrian / index.html
Created August 30, 2017 17:56
MyWifi Debugging
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
@cpsubrian
cpsubrian / .env
Created May 12, 2017 23:18
Netlify Build Fails due to Private Dependencies
NPM_TOKEN=[your-npm-authentication-token]
YARN_VERSION=0.24.4
@cpsubrian
cpsubrian / upload.js
Last active December 2, 2018 22:13
Upload files to S3 via node aws-sdk (if aws-cli isn't easily installable)
// Put credentials in ~/.aws/credentials like:
//
// [default]
// aws_access_key_id = [key]
// aws_secret_access_key = [secret]
if (process.argv.length !== 5) {
console.log('Usage: node ./upload.js [filepath] [bucket] [key]')
process.exit()
}
@cpsubrian
cpsubrian / example.test.js
Created March 7, 2017 16:56
Chainable request helper for testing express apps with jest
import request from './request'
// Your express app (or router).
import app from './app'
it('can serve requests', () => {
return request
.app(app)
.post('/foo/bar')
.header({authorization: 'Bearer mytoken'})
@cpsubrian
cpsubrian / db.js
Last active June 13, 2023 06:59
Mock knex database for Jest
/* eslint-env jest */
import _ from 'lodash'
import path from 'path'
import fs from 'fs'
import callsites from 'callsites'
import knex from 'knex'
import hash from 'object-hash'
import conf from '<conf>'
// Get the db config.
@cpsubrian
cpsubrian / regexSupplant.js
Created January 25, 2017 20:05
Create a regex from parts using a tagged template.
function regexSupplant (strings, ...values) {
let parts = []
while (strings.length || values.length) {
if (strings.length) {
parts.push(strings.shift()
.split('\n')
.map((val) => val.trim())
.join('')
)
}
@cpsubrian
cpsubrian / README.md
Last active December 6, 2023 11:03
Compile Xvfb for AWS Lamba
@cpsubrian
cpsubrian / README.md
Last active November 22, 2016 04:14
LetsEncrypt Auto Renewal Via Dgate

Note: You must edit [domain] and [dir] in the examples below.

Step 1. Double-check that dgate-ssl is loading the live certs.

Step 2. Create a script to renew the cert via an http standalone server. (Make sure it has execute permissions)

~/certbot-auto certonly\
  --standalone\
  --standalone-supported-challenges http-01\
 --http-01-port 3005\