Skip to content

Instantly share code, notes, and snippets.

@pjkelly
pjkelly / serverless.yml
Last active December 16, 2021 19:59
Cloudformation Template for Public/Private VPC - Used to create peering connection between Lambda VPC and MongoDB Atlas, also allows public outbound traffic.
service: project-vpc
variablesResolutionMode: 20210326
# Concepts From:
# https://raw.githubusercontent.com/awsdocs/aws-lambda-developer-guide/main/templates/vpc-privatepublic.yaml
# https://datachef.co/blog/aws-vpc-with-public-and-private-subnets/
# https://ordina-jworks.github.io/cloud/2020/02/19/Combining-MongoDB-and-AWS-Lambda.html#vpc-peering-connect-your-lambda-functions-with-your-mongodb-atlas-cluster
custom:
stage: ${opt:stage}
@pjkelly
pjkelly / serverless.yml
Created December 14, 2019 00:46
Serverless / LocalStack - DynamoDB Table
service: my-service
frameworkVersion: ">=1.45.0 <2.0.0"
plugins:
- serverless-localstack
- serverless-deployment-bucket
custom:
stage: ${opt:stage}

Keybase proof

I hereby claim:

  • I am pjkelly on github.
  • I am pjkelly (https://keybase.io/pjkelly) on keybase.
  • I have a public key ASABfS-Igq-O3-uBbvoG2rvBftrNakjRot4KsqS4OFf4oAo

To claim this, I am signing this object:

@pjkelly
pjkelly / app.js
Created October 27, 2017 00:12
Sample express app that acts as a proxy with CORS support.
const express = require('express');
const cors = require('cors');
const proxy = require('http-proxy-middleware');
const app = express();
const port = process.env.PORT || 8080;
const onProxyReq = function (proxyReq, req, res) {
proxyReq.setHeader('Authorization', 'Basic SECRET');
@pjkelly
pjkelly / PgError.md
Last active February 8, 2023 04:49
PG gem error after PostgreSQL upgrade.

When upgrading PostgreSQL on your machine, previously installed versions of the pg Rubygem will complain because their native extensions were compiled against an older version of Postgres. The error will look like this:

[daley (qa)]$ be rake db:create
rake aborted!
LoadError: dlopen(/opt/rubies/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.bundle, 9): Library not loaded: /opt/boxen/homebrew/lib/libpq.5.5.dylib
  Referenced from: /opt/rubies/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.bundle
  Reason: image not found - /opt/rubies/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.bundle
/Users/pjkelly/src/daley/config/application.rb:7:in `<top (required)>'
@pjkelly
pjkelly / copy.rb
Created May 14, 2015 18:08
Copy a local file to server w/ Cap 3
desc "Copy a file"
task :copy do
on roles(:web) do |host|
# localfile.html would be in the root of your repo in this case.
upload! 'localfile.html', current_path.join('public/localfile.html')
execute :chmod, '775', current_path.join('public/localfile.html')
end
end
@pjkelly
pjkelly / circle.yml
Created September 18, 2014 04:40
whs.saba.do auto-deploy
test:
override:
- bundle exec jekyll
deployment:
production:
branch: master
commands:
- '[[ ! -s "$(git rev-parse --git-dir)/shallow" ]] || git fetch --unshallow'
- git push git@heroku.com:mrsabado-production.git $CIRCLE_SHA1:master -f
- curl -sSfL --retry 5 http://whs.saba.do > /dev/null
@pjkelly
pjkelly / install-phantomjs.md
Last active January 27, 2020 21:30
Installing PhantomJS

Installing PhantomJS via Homebrew and fixing Ruby if it breaks

PhantomJS is an awesome tool for doing automated, full-stack acceptance tests in a headless browser. It's a great alternative to capybara-webkit because it doesn't depend on QT or xvfb, and it's way better than Selenium in most cases because it's faster (you don't need to open Firefox to run your tests).

Unfortunately, installing PhantomJS via Homebrew can wreak havoc on your Rubies if you're using rbenv. These are the steps that worked for me in fixing my Ruby installations.

# Update Homebrew
brew update
# Install PhantomJS
@pjkelly
pjkelly / s3-file-sharing.md
Created September 3, 2014 18:15
Setting up an Amazon S3 bucket to share files.

Setting up an Amazon S3 bucket to share files

  1. Sign into your AWS console: https://console.aws.amazon.com/console/home
  2. Click on “S3”.
  3. Click “Create Bucket” and enter a Bucket Name using only alphanumeric characters and no spaces. We recommend prefixing it with your organization’s name, so something like “myorganization-downloads” works well. No other customization is necessary, so then click “Create” to complete the creation process.
  4. Choose the bucket you just created from the list of buckets to navigate into it.
  5. Once inside the folder, click “Upload” and upload all the files you want there.
  6. After your files are done uploading, select them by clicking the square to their left and then choose “Actions” -> “Make Public”. This will make the files publicly accessible.
  7. To get the public URL of a file, select the file and then click the Properties tab (in the top right of the window). The Link attribute contains the publicly accessible URL of the file.
@pjkelly
pjkelly / unicorn.rb
Last active April 19, 2017 09:27 — forked from pablitoc/unicorn.rb
require 'dotenv'
Dotenv.load
listen ENV.fetch('UNICORN_PORT', 5000), :backlog => ENV.fetch('UNICORN_BACKLOG', 200).to_i
worker_processes ENV.fetch('UNICORN_CONCURRENCY', 3).to_i
timeout ENV.fetch('UNICORN_TIMEOUT', 15).to_i
preload_app true
if ENV.include?('UNICORN_LOG')
stderr_path ENV.fetch('UNICORN_LOG')