Skip to content

Instantly share code, notes, and snippets.

View armstrjare's full-sized avatar

Jared Armstrong armstrjare

View GitHub Profile
nums = [1,2,3,5,8,9,12,13,14,15,16,19]
def numbers_grouped(nums)
nums = nums.sort
start, last = nums.first, nil
sequences = []
nums.each_with_index do |num, i|
# Are we out of sequence?
if last && last+1 != num
nums = [1,2,3,5,8,9,12,13,14,15,16,19]
def numbers_grouped(nums)
nums = nums.sort
start, last = nums.first, nil
sequences = []
nums.each_with_index do |num, i|
# Are we out of sequence?
if last && last+1 != num
set :asset_precompile_locations, ["config/application.rb", "app/assets"] # We check the git log for these locations to determine if recompilation necessary
# ...
namespace :assets do
task :recompile, :roles => :web do
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} GROUP=assets assets:precompile}
end
# Provides a method of accessing our URL routes from JavaScript.
<%# Helper function to define our routes %>
<% route = lambda { |*args|
route_name = args.shift
route_args = args.map { |kw| ":#{kw}" } # Provide interpolation of route arguments
route_args.push({ :only_path => true})
url = MyApp::Application.routes.url_helpers.send("#{route_name}_url", *route_args).to_json
"#{route_name}_url : route(#{url})" } %>
# from koz, tweaked
class FixAcceptsBehaviourMiddleware
def initialize(app, formats, logger = Rails.logger)
@app = app
@formats = formats
@logger = logger
end
def call(env)
current_accept_header = env["HTTP_ACCEPT"].to_s.split(",")
task :precompile, :roles => :web, :except => { :no_release => true } do
needs_recompile = if current_revision
from = source.next_revision(current_revision)
capture("cd #{latest_release} && #{source.local.log(from)} #{asset_precompile_locations.join(' ')} | wc -l").to_i > 0
end
# Symlink public/assets to the shared assets directory.
symlink
if needs_recompile
# Helper class that encapsulates common functionality of
# nested attribute fields with removal and add via a template field set.
#
# Usage:
# new NestedAttributesForm('.wrapper_for_nested_model', {
# # Additional options (see: defaultOptions)
# });
class @NestedAttributesForm
# Default options.
defaultOptions:
MAP = []
('A'...'Z').each do |c|
MAP << c
end
('a'..'z').each do |c|
MAP << c
end
('0'..'9').each do |c|
MAP << c.to_s
end
set :asset_precompile_locations, ["config/application.rb", "app/assets"] # We check the git log for these locations to determine if recompilation necessary
after "deploy:update_code" do
assets.precompile
end
namespace :assets do

Keybase proof

I hereby claim:

  • I am armstrjare on github.
  • I am armstrjare (https://keybase.io/armstrjare) on keybase.
  • I have a public key whose fingerprint is 812B 50BB 2474 ECFF 1425 44FB E405 5047 1507 3325

To claim this, I am signing this object: