Skip to content

Instantly share code, notes, and snippets.

View willscripted's full-sized avatar

Will O'Brien willscripted

View GitHub Profile
@willscripted
willscripted / nginx-conf
Created May 1, 2014 12:08
Nginx config to do ssl termination and serve static assets. If static assets are not found, forward request to another server
upstream api {
server hopper-api.herokuapp.com;
}
server {
listen 80;
listen 443 ssl;
server_name www.schedjs.com$;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
@willscripted
willscripted / index-page.coffee
Created July 8, 2014 17:30
Tanner look at this router
class IndexPage
constructor: (opts) ->
@view = new RactiveView(el: opts.el)
# Ask the router for current user,
# if success, set user
# if fail, redirect to login
opts.router.getCurrentUser().then (user) =>
@willscripted
willscripted / user_controller.rb
Created August 28, 2014 16:46
Fine-grained permissions
## e.g. Usage
def V1::UserController < V1::BaseController
## In controller
def show
render :json => reject_unpermitted(user, V1::UserPresenter.new(user))
end
def update
sudo apt-get install libnss3-tools
certutil -d sql:.pki/nssdb -A -t "C,," -n "will-ob localhost" -i /usr/share/ca-certificates/moar/localhost.crt
sudo dpkg-reconfigure ca-certificates
@willscripted
willscripted / csr.pem
Last active August 29, 2015 14:13
Server for testing CORS configs
-----BEGIN CERTIFICATE REQUEST-----
MIIBnzCCAQgCAQAwXzELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAwwPYmV0
YS50YXBqb3kuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDtuGIDiuI7
7W4RAc0pGwi0f906ie3zzt4zbBcrS6WHXm49TmQzd+alRS8QDKONgwKPPagmKp4Z
p00laKphVrhIkXr+hiEEoypRlhyMKVLGfpQZhIqiYbFYbs4weCHTRpTQXXfmnOCw
ZuL1jTzIvBaONwGsc1oSnXUBu4a9sfvj9QIDAQABoAAwDQYJKoZIhvcNAQELBQAD
gYEAtP/dhSOv/Fo6vVRKFiKNaqroTa6Hi//JGosm7YubX5+n4ZwVJ4bpmzcJym5n
FpuMKiXpqlNGGUQ4yEkSCkP+Ab1dnS6dAGi63wjsWeAgwAbQH0xlN4ovsJNBtHRz
SUUZdA9wOs5tBAyGrEr6mTuO/kVKd24i3E1dZtxeUZKOQlo=
@willscripted
willscripted / getopts.sh
Created February 8, 2015 13:53
playing around with getopts
#!/usr/bin/env bash
OPTIND=1 # Reset getopts iterator
while getopts "ht:f:" opt; do
case "$opt" in
h|\?)
echo "h or nothing?"
exit 0
;;

test gist!

Things & Stuff

^ I need this to test '&' in headers

@willscripted
willscripted / bootstrap-consul.sh
Last active August 29, 2015 14:20
Bootstrap Consul on Docker via Cloudconfig
#!/bin/bash
# Inspired by Brandon Philips' consul bootstrap script
# https://gist.github.com/philips/56fa3f5dae9060fbd100
source /etc/environment
num_expected_nodes=$1
do_join() {
CREATE OR REPLACE FUNCTION update_modified_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ language 'plpgsql';
ALTER TABLE consumer_offsets ADD COLUMN updated_at timestamp default current_timestamp;
CREATE TRIGGER update_consumer_offsets_modtime BEFORE UPDATE ON consumer_offsets FOR EACH ROW EXECUTE PROCEDURE update_modified_column();
@willscripted
willscripted / kafka.sh
Created July 8, 2015 14:20
install kafka
#!/usr/bin/env bash
# Just for editor highlighting
### Kafka configuration
version=0.8.2.1
scala_version=2.11
install_dir=/usr/local/share
sudo -E su - --command "cd /tmp && wget http://archive.apache.org/dist/kafka/$version/kafka_$scala_version-$version.tgz"