Ctrl+KB | toggle side bar |
Ctrl+Shift+P | command prompt |
Ctrl+` | python console |
Ctrl+N | new file |
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
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D | |
rails_env = ENV['RAILS_ENV'] || 'production' | |
# 16 workers and 1 master | |
worker_processes (rails_env == 'production' ? 16 : 4) | |
# Load rails+github.git into the master before forking workers | |
# for super-fast worker spawn times | |
preload_app true |
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
<%= simple_form_for @search, :as => :search_manufacturer, :url => search_index_url(:search => @search.to_hash), :html => {:novalidate => true, :method => :get} do |search_form|%> | |
<% SimpleForm.wrapper_tag = nil %> | |
<!-- Center everything --> | |
<div class="center-content" itemscope itemtype ="http://schema.org/Product"> | |
<article> | |
<!-- 1 column box with tabs --> | |
<div class="tabs"> | |
<nav> | |
<%= render_filter search_form, @search.filter("boat_manufacturer") %> | |
</nav> |
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
def validate params | |
raise OURERROR if !(self.manufacturer == params[:manufacturer] and self.country_code and params[:country_code] and self.model == params[:model]) | |
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
def validate params | |
[:manufacturer, :model, :country_code].each do |field| | |
incoming_param = params[field].blank? ? '' : params[field] | |
field_value = self.send(field).blank? ? '' : self.send(field) | |
if field_value != incoming_param | |
error = Api::Errors::BadRequest.new('Bad Request it should be like manufacturer-country_code-model') | |
raise error | |
end | |
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
class SampleJob | |
def perform | |
begin | |
# do all your work in the begin block. | |
puts "hello world" | |
rescue Exception => e | |
# rescue any errors so that you know something went wrong. Email yourself the error if you need. | |
error_msg = "#{Time.now} ERROR (SampleJob#perform): #{e.message} - (#{e.class})\n#{(e.backtrace or []).join("\n")}" | |
puts error_msg | |
ensure |
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
# An example of elasticsearch & Tire setup for ActiveRecord associations. | |
# | |
# A `Book has_many :chapters` scenario, with mapping and JSON serialization | |
# for indexing associated models. | |
# | |
# Demonstrates three important caveats as of now: | |
# | |
# 1. You you have to use `touch: true` in the `belongs_to` declaration, | |
# to automatically notify the parent model about the update. | |
# |
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
def search | |
paginate_per = 30 | |
group_id = params[:part_group] | |
make_id = params[:make] | |
model_id = params[:model] | |
vehicle_category_id = params[:category] | |
vehicle_power = params[:power] | |
capacity = params[:capacity] | |
q = params[:q] |
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
connection = Faraday::Connection.new('http://example.com') do |builder| | |
builder.request :url_encoded # for POST/PUT params | |
builder.adapter :net_http | |
end | |
# same as above, short form: | |
connection = Faraday.new 'http://example.com' | |
# GET | |
connection.get '/posts' |
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
gem 'devise' | |
gem 'omniauth' | |
gem 'omniauth-github' | |
gem "omniauth-twitter" | |
gem "omniauth-facebook" | |
gem "omniauth-google-oauth2" |
OlderNewer