Skip to content

Instantly share code, notes, and snippets.

@concept47
concept47 / gist:5295522
Created April 2, 2013 19:42
Showing better highlighted search result fragments with Elasticsearch
def ellipses_for_highlights(params_highlight, params_original)
# have to do this because highlighted stuff from ES has a trailing space for whatever reason
stripped_highlighted_item = strip_tags(params_highlight).rstrip
# if the beginning of the highlighted text doesn't match the original it has been clipped
tmp = params_original =~ /#{stripped_highlighted_item}/
front_ellipsis = tmp != 0
# if the last 10 characters of the highlighted text don't match the original, same deal
back_ellipsis = last_string_chars(stripped_highlighted_item, 10) != last_string_chars(params_original, 10)
highlighted_item = front_ellipsis ? "... " + params_highlight : params_highlight
@concept47
concept47 / gist:4592477
Created January 22, 2013 06:05
stack trace for puma 2.0.0.b4 with
NoMethodError (undefined method `empty?' for nil:NilClass):
actionpack (3.2.11) lib/action_view/lookup_context.rb:145:in `detail_args_for'
actionpack (3.2.11) lib/action_view/lookup_context.rb:139:in `args_for_lookup'
actionpack (3.2.11) lib/action_view/lookup_context.rb:109:in `find'
actionpack (3.2.11) lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
actionpack (3.2.11) lib/action_view/renderer/template_renderer.rb:34:in `determine_template'
newrelic_rpm (3.4.2.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:153:in `render_with_newrelic'
actionpack (3.2.11) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.11) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:110:in `_render_template'
Dave Brubeck took a stand against racism and would refuse to play in segregated venues. He turned down offers to perform in South Africa because of ordinances that prohibited racially mixed groups. He apparently started one the first racially integrated bands in the U.S. army during WW II.
We lost a musical genius and a good human being.
@concept47
concept47 / framework.rake
Created May 5, 2011 04:04
This makes rake rails:freeze:edge work for your Rails 2 installation. find your rails gem then navigate to /lib/tasks/framework.rake ... locate a similar looking section and replace it with this
desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0'
task :edge do
require 'open-uri'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
version = ENV["RELEASE"] || "edge"
target = "v#{version}"
commits = "http://github.com/api/v1/yaml/rails/rails/commits/master"
#url = "http://dev.rubyonrails.org/archives/#{target}"