Skip to content

Instantly share code, notes, and snippets.

View partydrone's full-sized avatar

Andrew Porter partydrone

View GitHub Profile
@partydrone
partydrone / _downloads.html.erb
Created March 23, 2009 22:49
Given the following associations: [ download_types --> downloads --> downloads_products <-- products ], I create a query (in download.rb) that will list all downloads for a given product ordered by download type.
<% @downloads.group_by(&:download_type).each do |download_type, downloads| -%>
<h3><%= download_type.name.pluralize %></h3>
<ul>
<%= render :partial => 'support/download', :collection => downloads %>
</ul>
<% end -%>
<% error_handling_form_for @article do |f| -%>
<%= f.text_field :title %>
<%= f.date_select :post_date, :order => [:month, :day, :year] %>
<%= f.text_area :body %>
<%= f.submit 'Submit' %>
<% end -%>
set :stages, %w(staging production)
set :default_stage, 'staging'
require 'capistrano/ext/multistage'
# repository elsewhere
set :scm, :git
set :repository, "[email protected]:Repositories/wavetronix.git"
set :ssh_options, { :forward_agent => true }
set :deploy_via, :remote_cache
require 'test_helper'
class ProjectTest < ActiveSupport::TestCase
test "should be able to retrieve projects based on day" do
actual = projects(:huddle).reports_grouped_by_day
expected_keys = actual.keys.sort.map { |d| d.to_s(:db) }
assert_equal ["2009-01-06", "2009-01-07"], expected_keys
assert_equal [status_reports(:one_tue).id, status_reports(:two_tue).id], actual[Date.parse("2009-01-06")].map(&:id)
end
@partydrone
partydrone / nginx.conf
Created August 5, 2011 21:51
nginx 1.0.10 configuration with vhost support
# Set another default user than root for security reasons
user nginx nginx;
# As a thumb rule: One per CPU. If you are serving a large amount
# of static files, which requires blocking disk reads, you may want
# to increase this from the number of cpu_cores available on your
# system.
#
# The maximum number of connections for Nginx is calculated by:
# max_clients = worker_processes * worker_connections
@partydrone
partydrone / com.rapidturtle.www.conf
Created August 5, 2011 21:55
nginx 1.0 example vhost config file
server {
server_name rapidturtle.com;
rewrite ^ $scheme://www.rapidturtle.com$request_uri? permanent;
}
server {
server_name www.rapidturtle.com;
root /home/deploy/com.rapidturtle.www/current/public;
access_log logs/com.rapidturtle.www.access.log;
@partydrone
partydrone / Capfile
Created September 10, 2011 22:52
Multistage Capistrano Recipe
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
require 'bundler/capistrano'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
@partydrone
partydrone / download_type_sweeper.rb
Created November 15, 2011 20:39
expire_action producing `can't convert Symbol into Integer` error
class DownloadTypeSweeper < ActionController::Caching::Sweeper
observe DownloadType
def after_save(download_type)
expire_cache_for download_type
end
def before_destroy(download_type)
expire_cache_for download_type
end
@partydrone
partydrone / com.rapidturtle.www.conf
Created November 29, 2011 11:23
nginx 1.0.10 vhost config file for unicorn
server {
# enable one of the following if you're on Linux or FreeBSD
listen 80 default deferred; # for Linux
# listen 80 default accept_filter=httpready; # for FreeBSD
# If you have IPv6, you'll likely want to have two separate listeners.
# One on IPv4 only (the default), and another on IPv6 only instead
# of a single dual-stack listener. A dual-stack listener will make
# for ugly IPv4 addresses in $remote_addr (e.g ":ffff:10.0.0.1"
@partydrone
partydrone / authentication.feature
Created April 12, 2012 22:16
Test Active Directory authentication through adauth gem with Cucumber
Feature: Authentication
Employees should be able to access the applicaiton using their existing network login account.
Scenario: Sign In
Given a valid user
When I am on the sign in page
And I fill in "username" with "brubble"
And I fill in "password" with "secret"
And I click "Sign in"
Then I should see "Signed in as: Barney Rubble"