Skip to content

Instantly share code, notes, and snippets.

@pjkelly
pjkelly / serverless.yml
Created Dec 14, 2019
Serverless / LocalStack - DynamoDB Table
View serverless.yml
service: my-service
frameworkVersion: ">=1.45.0 <2.0.0"
plugins:
- serverless-localstack
- serverless-deployment-bucket
custom:
stage: ${opt:stage}
View keybase.md

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 Oct 27, 2017
Sample express app that acts as a proxy with CORS support.
View app.js
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 May 25, 2016
PG gem error after PostgreSQL upgrade.
View PgError.md

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
Copy a local file to server w/ Cap 3
View copy.rb
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 Sep 18, 2014
whs.saba.do auto-deploy
View circle.yml
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 Jan 27, 2020
Installing PhantomJS
View install-phantomjs.md

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 Sep 3, 2014
Setting up an Amazon S3 bucket to share files.
View s3-file-sharing.md

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.
View 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')
View sublime-user-settings.json
{
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": false,
"folder_exclude_patterns":
[
"log",
"tmp",
"backups",
"dump",