Skip to content

Instantly share code, notes, and snippets.

class PostsController < ApplicationController
respond_to :html, :json
before_action :find_post, only: %i(show edit update destroy)
before_action :find_posts, only: %i(index)
def index
respond_with decorate(@posts)
end
# Updated by Siege 3.0.5, February-03-2014
# Copyright 2000-2013 by Jeffrey Fulmer, et al.
#
# Siege configuration file -- edit as necessary
# For more information about configuring and running
# this program, visit: http://www.joedog.org/
#
# Variable declarations. You can set variables here
# for use in the directives below. Example:
@xionon
xionon / gist:9916302
Created April 1, 2014 15:19
keybase.md
### Keybase proof
I hereby claim:
* I am xionon on github.
* I am alechipshear (https://keybase.io/alechipshear) on keybase.
* I have a public key whose fingerprint is 7D65 BBE1 3BD5 E1F7 891E D8A3 3586 6DC4 A359 A3E5
To claim this, I am signing this object:
@xionon
xionon / regex.rb
Last active August 29, 2015 13:55
This is a runable tutorial on 3 regex tips that will make your code more readable: 1) named capture groups, 2) whitespace+comments, 3) an alternate syntax
require 'minitest'
require 'minitest/spec'
require 'minitest/autorun'
describe 'Regexes are super great' do
before do
@month = "12"
@day = "15"
@year = "2014"
@date = "#{@month}/#{@day}/#{@year}"
@xionon
xionon / Vagrantfile
Created January 31, 2014 15:36
Big old vagrantfile to spin up multiple nodes
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
NODES = [
['proxy', 1, 10],
['app', 1, 20],
['db', 1, 30],
['cache', 1, 40]
]
@xionon
xionon / Gemfile
Last active January 4, 2016 16:39
Use rake and knife-solo to cook or bootstrap multiple EC2 instances. Automatically load EC2 IP addresses via the SDK
source 'https://rubygems.org'
gem 'rake'
gem 'aws-sdk'
gem 'dotenv'
gem 'chef'
gem 'librarian-chef'
gem 'knife-solo'
gem 'knife-solo_data_bag'
@xionon
xionon / hashtest.rb
Created January 20, 2014 15:50
Show off default hash values
puts "hash_without_default = Hash.new"
hash_without_default = Hash.new
print "hash_without_default[:key] # => "
puts hash_without_default[:key].inspect
print "hash_without_default[:key][:value] # => "
begin
puts hash_without_default[:key][:value].inspect
rescue => e
@xionon
xionon / Vagrantfile
Created January 17, 2014 16:00
Using this Vagrantfile, "vagrant up" fails running chef-solo with the error: FATAL: Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/client.pem, which you told me to use to sign requests!
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.provision :chef_solo do |chef|
chef.environment = "development"
chef.environments_path = "environments"
end
@xionon
xionon / .env
Created December 3, 2013 17:40
Simple rake task to upload a cookbooks archive to S3, for use with OpsWorks
S3_ACCESS_KEY_ID='SOME_SECRET_ID'
S3_SECRET_ACCESS_KEY='SOME_SECRET_KEY'
S3_BUCKET_NAME='SOME_BUCKET_NAME'