Skip to content

Instantly share code, notes, and snippets.

View jimthoburn's full-sized avatar

Jim Thoburn jimthoburn

View GitHub Profile
@johnteske
johnteske / index.html
Created January 5, 2017 18:49
Liquid number format with commas
{% include numberWithCommas.html number=1 %}
{% include numberWithCommas.html number=12 %}
{% include numberWithCommas.html number=123 %}
{% include numberWithCommas.html number=1234 %}
{% include numberWithCommas.html number=12345 %}
{% include numberWithCommas.html number=123456 %}
{% include numberWithCommas.html number=1234567 %}
{% include numberWithCommas.html number=12345678 %}
{% include numberWithCommas.html number=123456789 %}
{% include numberWithCommas.html number=1234567890 %}
@headquarters
headquarters / prevent_widows.rb
Last active September 6, 2015 06:34
Prevent widows in Ruby with this simple function. It replaces only the last space character with a non-breaking space in a string.
def prevent_widows(text)
if text.kind_of? String
trimmed_text = text.rstrip
last_space_index = trimmed_text.rindex(" ")
if !last_space_index.nil?
text[last_space_index] = " "
end
end