Skip to content

Instantly share code, notes, and snippets.

set :user, "adam"
set :application, "samaraparts"
role :app, "samaraparts.ru"
role :web, "samaraparts.ru"
role :db, "samaraparts.ru", :primary => true
set :scm, "git"
set :repository, "[email protected]:adammiribyan/samaraparts.git"
@adammiribyan
adammiribyan / application.html.haml
Created March 20, 2011 22:27
rails app template layout file
!!! 5
%html{:lang => "en-US"}
%head
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
%title
= yield (:title)
= stylesheet_link_tag "reset", "application"
= javascript_include_tag "jquery.min", "application", "rails"
= csrf_meta_tag
%body
@adammiribyan
adammiribyan / .gitignore
Created March 20, 2011 22:43
gitignore default file
.DS_Store
.bundle
.redcar
config/database.yml
db/*.sqlite3
log/*.log
tmp/**/*
tmp/restart.txt
public/stylesheets
cerebrum/
@adammiribyan
adammiribyan / application_helper.rb
Created March 20, 2011 22:46
initial helper methods for new rails app
module ApplicationHelper
def title(page_title)
content_for(:title) { page_title }
end
end
@adammiribyan
adammiribyan / started_in_last_scope.rb
Created April 2, 2011 01:45
Interesting ActiveRecord scope method
# find_created_in_last(7.months)
def self.find_started_in_last(time_span)
old_time = Date.today - time_span
all(:conditions => ["created_at > ?", old_time.to_s(:db)])
end
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
@adammiribyan
adammiribyan / application.html.erb
Created April 14, 2011 09:15
rails app template layout file
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title><%= yield :title %></title>
<%= stylesheet_link_tag "reset", "application" %>
<%= javascript_include_tag "jquery.min", "application", "rails" %>
<%= csrf_meta_tag %>
</head>
<body>
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@adammiribyan
adammiribyan / invitation.html.erb
Created June 11, 2011 17:14
Invitation instructions email
<p>Hello <%= @resource.email %>!</p>
<p>Someone has invited you to <%= root_url %>, you can accept it through the link below.</p>
<p><%= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %></p>
<p>If you don't want to accept the invitation, please ignore this email.<br />
Your account won't be created until you access the link above and set your password.</p>
en:
devise:
invitations:
send_instructions: 'An invitation email has been sent to %{email}.'
invitation_token_invalid: 'The invitation token provided is not valid!'
updated: 'Your password was set successfully. You are now signed in.'
no_invitations_remaining: "No invitations remaining"
mailer:
invitation_instructions:
subject: 'Invitation instructions'