Bob Roberts brobertsaz

View serversetup.md

Ubuntu Precise Rails, Nginx, Unicorn and Capistrano ('2.15.5') Server Setup

I originally tried to use the ~> 3.0 version of Capistrano, but fell back to the 2.15.5 version. There were a lot of changes in the new version that I did not feel like learning right at the moment...

1. Setup deploy user

First we will create a new user for deployment:

$  ssh into your server
View gist:8328248
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
set -u
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
 
# Feel free to change any of the following variables for your app:
APP_ROOT=/home/deploy/public_html/rm/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENV=production
View activity_log
1 2 3 4 5 6 7 8 9 10
.activity-log-header
%p.low
Refine results by Organization
%p
= select_tag 'search[query]', options_for_select(@organizations), class: 'chosen-select', prompt: "Search for organization to select", id: 'org-selection'
.activity_log_results
%table.fancy-table
%thead
%tr
%th Date
View js-welcome-full
1 2 3 4 5 6 7 8 9 10
:javascript
$(document).ready(function()
{
checkForWelcome();
}
);
 
function checkForWelcome() {
var userWelcome = "#{@current_user.hide_welcome}";
if (userWelcome == "false") {
View bobs_ruby_snippets
1 2 3 4 5 6 7 8
These two snippets can be copy/pasted into a Sublime Text 2 new snippet and saved as a [.]sublime-snippet
 
To create <%= <cursor> %> use rb=+tab
<snippet>
<content><![CDATA[<%= ${1} %>]]></content>
<tabTrigger>rb=</tabTrigger>
<description><%=… %></description>
</snippet>
View unicorn
1 2 3
/usr/sbin/update-rc.d -f unicorn defaults
chmod +x /etc/init.d/unicorn
/usr/sbin/update-rc.d -f unicorn remove
View _new.html.haml
1 2 3 4 5 6 7 8 9 10
= form_tag "/auth/identity/register", id: 'loginform' do
= error_messages_for @identity, :header_message => ""
 
%table
%tr{colspan: 2}
%td
= label_tag :title
= text_field_tag :title, @identity.try(:title), size: '32', class: 'logininput'
%tr
%td
View gist:5121612
1 2 3 4 5 6 7 8 9 10
def merge_pdfs
pdfs = []
pdfs << @bulletin.pdf.path
@bulletin.bulletin_inserts.first.bulletin_insert_items.each do |bii|
if bii.pdf.present?
pdfs << bii.pdf.path
end
end
if pdfs.count > 1
system "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=temp.pdf #{pdfs.join(' ')}"
View nginx.puma.conf
1 2 3 4 5 6 7 8 9 10
upstream myapp {
server unix:///myapp/tmp/puma.sock;
}
 
server {
listen 80;
server_name myapp.com;
 
# ~2 seconds is often enough for most folks to parse HTML/CSS and
# retrieve needed images/icons/frames, connections are cheap in
Something went wrong with that request. Please try again.