Skip to content

Instantly share code, notes, and snippets.

View jsloyer's full-sized avatar

Jeff Sloyer jsloyer

View GitHub Profile
function authenticate() {
return function(request, response, next) {
if (request.headers["secret"] !== "supersecretkey") {
response.send("Must authenticate");
return next();
}
};
}
app.get("/secured-api", authenticate(),function (request, response) {
@jsloyer
jsloyer / package.json
Created July 29, 2015 16:28
business rules example package.json
{
"name": "bluemix-business-rules",
"version": "0.0.1",
"dependencies": {
"express": "~4.10.8",
"restler": "~3.2.2",
"async": "~0.9.0",
"body-parser": "~1.12.4"
},
"engines": {
@jsloyer
jsloyer / app.js
Created July 29, 2015 16:28
business rules example app.js
var app = require("express")(),
restler = require("restler");
app.get("/", function(request, response) {
var json = {
"employeeID": "jujuju",
"loanAmount": 10517320,
"theEmployee": {
"seniority": 3,
@jsloyer
jsloyer / blue-green-deployment-cf-autopilot
Last active October 23, 2018 12:52
A/B deployments on Cloud Foundry using autopilot plugin
go get github.com/concourse/autopilot
cf install-plugin $GOPATH/bin/autopilot
cf login -a ${CF_API} -u ${CF_USERNAME} -p ${CF_PASSWORD} -o ${CF_ORG} -s ${CF_SPACE}
cf zero-downtime-push myapp -f manifest.yml

Keybase proof

I hereby claim:

  • I am jsloyer on github.
  • I am jsloyer (https://keybase.io/jsloyer) on keybase.
  • I have a public key whose fingerprint is 38F6 518D DC8A F4CF 3A3D 3EC3 E266 D00C 8F79 BBB6

To claim this, I am signing this object:

.DS_STORE
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
---
applications:
#swap out myapp-jbs for your own app name
- name: myapp-jbs
memory: 1GB
instances: 1
path: .
command: bundle exec rake db:setup && bundle exec rails s -p $PORT
services:
#swap out the below for your own
require 'resque/status_server'
require 'json'
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
if rails_env != "production"
Resque.redis = resque_config[rails_env]
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
@jsloyer
jsloyer / .lights.cfg
Created February 16, 2015 16:28
custom config for pylights
[hardware]
gpio_pins = 0,1,2,3,4,5,6,7,21,22,23,24,25,26,28,29
[lightshow]
preshow_configuration =
{
"transitions": [
{
"type": "on",
"duration": 1,