⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Guide | |
# Configure the essential configurations below and do the following: | |
# | |
# Repository Creation: | |
# cap deploy:repository:create | |
# git add . | |
# git commit -am "initial commit" | |
# git push origin master | |
# | |
# Initial Deployment: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VisitorSession | |
include Mongoid::Document | |
field :visits, :type => Integer, :default => 1 | |
field :project_id | |
def visits_for_project | |
map = <<EOF | |
function() { | |
if (this.project_id == '#{project_id}') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE in JavaScript | |
// without resorting to user-agent sniffing | |
// ---------------------------------------------------------- | |
// If you're not in IE (or IE version is less than 5) then: | |
// ie === undefined | |
// If you're in IE (>=5) then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: | |
// if (ie) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RAKEFILE = <<-RAKEFILE | |
require File.dirname(__FILE__) + '/config/boot.rb' | |
require 'thor' | |
require 'padrino-core/cli/rake' | |
PadrinoTasks.init | |
RAKEFILE | |
PV = Padrino.version | |
GEMFILE = <<-GEMFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My pimped out unicorn config, with incremental killof | |
# and all the latest capistrano & bundler-proofing | |
# @jamiew :: http://github.com/jamiew | |
application = "000000book.com" | |
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production' | |
app_path = "/srv/#{application}" | |
bundle_path = "#{app_path}/shared/bundle" | |
timeout 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check process sequoia_dj2_delayed_job_0 | |
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.0.pid | |
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 0" | |
as uid deploy and gid deploy | |
stop program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh stop production 0" | |
as uid deploy and gid deploy | |
check process sequoia_dj2_delayed_job_1 | |
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.1.pid | |
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 1" |
APIs are becoming an essential feature of modern web applications. Rails does a good job of helping your application provide an API using the same MVC structure you're accustomed to.
Let's work with the following example controller:
class ArticlesController < ApplicationController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def content_for_or_pjax(name, &block) | |
request.headers['X-PJAX'] ? capture(&block) : content_for(name, &block) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rails/test_help' | |
require 'minitest/autorun' | |
require 'minitest/pride' | |
require 'capybara/rails' | |
class MiniTest::Spec | |
include ActiveSupport::Testing::SetupAndTeardown |
OlderNewer