- create some temp files (but not
Tempfile
s since they would be GC'd too quickly) - append standard file descriptor redirects to the commands that we'll run in the detached spawned process, i.e.
1>>stdout_tempfile_path 2>>stderr_tempfile_path
- tack on a final command that will trigger copying the files to S3 regardless of exit status of original commands, i.e.
{original commands with io redirection &&'d together}; bundle exec rake cleanup_task
- cleanup other io redirection temp files older than some threshold
Other than the default Panini pieces, you will also need to make sure that lodash
is included as a devDependencies in your package.json
Tag a section of text as translatable. The section will be replaced with a set of if/elseif/else Merge Tags for each translation provided, otherwise only the wrapped content is displayed.
# Put this in Rakefile (doesn't matter where) | |
require 'benchmark' | |
class Rake::Task | |
def execute_with_benchmark(*args) | |
bm = Benchmark.measure { execute_without_benchmark(*args) } | |
puts " #{name} --> #{bm}" | |
end | |
alias_method :execute_without_benchmark, :execute |
source 'https://rubygems.org' | |
ruby '2.1.4' | |
gem 'rails', '~> 3.2.0' | |
gem 'mysql2' | |
group :development, :test do | |
gem 'byebug' |
# RUBY / RUBY ON RAILS COMMANDS | |
alias bexec='bundle exec' | |
alias rails_mv="bexec rails -v | sed 's/Rails \([0-9]\).*/\1/g'" | |
# Alias the rake command to Spring binstubs or fallback to "bundle exec" | |
# http://goo.gl/HkhHAf, http://goo.gl/STtIvF | |
function brake { | |
if [ -f bin/rake ] | |
then | |
bin/rake "$@" | |
else |
require 'capistrano/rvm' |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
# db/migrations/20140101000000_add_hstore_field_to_trip_tickets.rb | |
class AddHstoreFieldToTripTickets < ActiveRecord::Migration | |
def change | |
add_column :trip_tickets, :customer_identifiers, :hstore | |
end | |
end |
The following will prevent all future AJAX requests from being cached, regardless of which jQuery method you use (
$.ajaxSetup({ cache: false });
Source: http://stackoverflow.com/a/735101/83743
However, jQuery's AJAX object will follow redirects, so even if you disable caching globally the "_={timestamp}"
parameter that jQuery adds to bust the browser's cache may not be forwarded with the redirect. In that case, your request can still be cached by the browser. The solution is to either make sure that special param is passed along with redirects, or to send the appropriate cache-busting response headers from the server-side code for those requests.
Reference: http://api.jquery.com/jQuery.ajax/
# app/models/change.rb | |
class Change < ActiveRecord::Base | |
belongs_to :changeset, inverse_of: :changed_fields | |
validates :changeset, presence: true, associated: true | |
validates :field, presence: true, uniqueness: {scope: :changeset_id}, inclusion: { in: :field_enum } | |
def field_enum | |
if changeset.try(:model).present? | |
changeset.model_attributes | |
else |