Skip to content

Instantly share code, notes, and snippets.

View armstrjare's full-sized avatar

Jared Armstrong armstrjare

View GitHub Profile
@armstrjare
armstrjare / Notify-requester-of-comment-update.liquid
Last active March 7, 2019 20:55
Zendesk Regular Email Formatting
{% capture newline %}
{% endcapture %}{% capture htmlemail %}{{ ticket.latest_comment_formatted | split:"<table" | size }}{% endcapture %}{% if htmlemail == '1' %}{{ ticket.latest_comment.value }}
{% else %}{{ ticket.latest_comment.formatted_value }}{% endif %}
{% for attachment in ticket.latest_comment.attachments %}
Attachment: {{attachment.filename}} {{attachment.url}}
{% endfor %}
{% if htmlemail == '1' %}
{% for comment in ticket.public_comments %}{% if forloop.index > 1 %}{% capture preline_prefix %}
{% for i in (3..forloop.index) %}>{% endfor %}{% if forloop.index > 2%} {% endif %}{% endcapture %}{{ preline_prefix }}On {{ comment.created_at_with_time | date:'%a, %B %-d, %Y at %-I:%M %p' }}, {{ comment.author.name }} <{{ comment.author.email }}> wrote:{{ preline_prefix }}{% capture line_prefix %}
{% for i in (2..forloop.index) %}>{% endfor %} {% endcapture %}{{ line_prefix }}{{ comment.value | split:newline | join:line_prefix }}{{ line_prefix }}{% endif %}{% endfor %}

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:

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
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
# 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:
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
# 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(",")
# 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})" } %>
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
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