Skip to content

Instantly share code, notes, and snippets.

View stevenringo's full-sized avatar

Steven Ringo stevenringo

View GitHub Profile
@stevenringo
stevenringo / undent.rb
Created May 18, 2017 04:53 — forked from ashrithr/undent.rb
Ruby un-indent lines of here document
class String
def undent
gsub(/^.{#{slice(/^ +/).length}}/, '')
end
end
#Usage:
test = <<-EOS.undent
testing unindent
..another line
@stevenringo
stevenringo / aws-keychain-sts.sh
Created August 24, 2016 12:38 — forked from lox/aws-keychain-sts.sh
A wrapper for @pda's aws-keychain that generates temporary credentials via STS.
#!/bin/bash
set -euo pipefail
: ${AWS_CREDENTIALS_FILE="$HOME/.aws/credentials"}
: ${STS_SESSION_DURATION=36000}
sts_keychain_get_session_token() {
echo generating temporary credentials via sts >&2
aws-keychain exec $1 \
@stevenringo
stevenringo / nginx.conf
Created March 1, 2016 21:10 — forked from daveslutzkin/nginx.conf
Nginx conf for solid SSL/TLS
# Thin serving Rails.
upstream app_server {
server 127.0.0.1:3050 fail_timeout=0;
}
# SSL/TLS certificates - the key should be 4096 bit generated with: 'openssl genrsa -des3 -out server.key 4096'
ssl_certificate_key /var/app/deploy/www.thisisatest.com.key;
ssl_certificate /var/app/deploy/www.thisisatest.com.chained.crt;
# Ideally we'd have only TLSv1.2, but that compromises client support significantly
---
- name: Deploy new site release
user: deployer
hosts: all
tasks:
- name: Fetch repo updates
git: >
repo=git@github.com:my/repo.git
require 'yaml'
require 'erb'
require 'ostruct'
class Settings < OpenStruct
# Settings.new(:google_analytics)
def initialize(config_file_base_name)
super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env])
end
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
What's new in Ruby on Rails 4
A RoR 4 press review
Silvio Relli @ Florence On Ruby
Bibliography and related resources
1) Rails queue
http://reefpoints.dockyard.com/ruby/2012/06/25/rails-4-sneak-peek-queueing.html
http://blog.remarkablelabs.com/2012/12/rails-queue-rails-4-countdown-to-2013
https://github.com/rails/rails/commit/adff4a706a5d7ad18ef05303461e1a0d848bd662
#!/bin/zsh
/usr/bin/vagrant destroy --force
yes | knife client delete {NODE_NAME}
yes | knife node delete {NODE_NAME}
/usr/bin/vagrant up
knife bootstrap localhost --node-name {NODE_NAME} --ssh-user vagrant --ssh-password vagrant --ssh-port 2222 --sudo
/usr/bin/vagrant provision
@stevenringo
stevenringo / .rspec
Created December 27, 2012 22:39 — forked from coreyhaines/.rspec
--colour
-I app