Skip to content

Instantly share code, notes, and snippets.

View JeanMertz's full-sized avatar

Jean Mertz JeanMertz

View GitHub Profile
upstream www {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/var/www/shared/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.app.com;
*filter
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -i lo -d 127.0.0.0/8 -j REJECT
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allows all outbound traffic
@JeanMertz
JeanMertz / 1 routes.rb
Created November 14, 2012 11:22
route has_many locations
class Route < ActiveRecord::Base
belongs_to :to_location, class_name: 'Location'
belongs_to :from_location, class_name: 'Location'
end
ruby_block 'mount_install_unmount' do
block do
volumes_dir = new_resource.volumes_dir
# Mount the image
%x[hdiutil mount '#{dmg_file}'] unless %x[hdiutil info | grep -q 'image-path.*#{dmg_file}'].strip!
# Get the volume name
unless volumes_dir
all_volumes = %x[hdiutil info -plist].gsub!(/(\t|\n)/, '')\
def verify_backend_access
# Redirect guest users to login page.
if ! user_signed_in?
redirect_to new_user_session_url(subdomain: subdomain_account.name), notice: 'Not logged in!'
# Redirect users with `Client` roles to signup page.
elsif ! current_user.has_backend_access?
redirect_to new_user_registration_url(subdomain: app_subdomain), notice: 'No access, please sign up!'
# Redirect users without access to this account to their own account page.
Process: Sublime Text 2 [85892]
Path: /Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2
Identifier: com.sublimetext.2
Version: Beta, Build 2186 (2186)
Code Type: X86-64 (Native)
Parent Process: launchd [144]
Date/Time: 2012-03-10 09:40:20.960 +0100
OS Version: Mac OS X 10.7.3 (11D50)
Report Version: 9
@JeanMertz
JeanMertz / gist:1885444
Created February 22, 2012 15:00
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+X delete line
Ctrl+↩ insert line after
Ctrl+⇧+↩ insert line before
Ctrl+⇧+↑ move line (or selection) up
class Account < ActiveRecord::Base
has_many :memberships
has_many :users, through: :memberships
has_many :team_members, through: :memberships, source: :user, conditions: { 'memberships.role' => 'TeamMember' }
has_one :ownership, class_name: 'Membership', conditions: { 'memberships.role' => "Owner" }
has_one :owner, through: :ownership, source: :user
end
# == Schema Information
#
# Table name: pages
#
# id :integer not null, primary key
# published :boolean default(FALSE)
# theme_id :integer
# parent_id :integer
# created_at :datetime
# updated_at :datetime
Feature: Authentication
In order to be able to manage my website
As a client of a designer using the service
I want to be able to log in and log out of my website backend
Background: Website exists with a user and I am on the login page
Given a "website" exists with name: "twitter"
And for that website, a "user" exists with email: "[email protected]" and password: "password123"
And for that website, a "domain" exists with name: "twitter-dev.manager.dev"
And for that website, a "domain" exists with name: "twitter.dev"