This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git tests to skip on Solaris Nevada (mainly iconv-related). | |
make test GIT_SKIP_TESTS='t3900 t3901 t5100 t9301' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
gems = {} | |
`gem dependency -R`.split("\n\n").each do |gem| | |
unless gem["Used by"] | |
version = gem[/\d+\.\d+\.\d+$/] | |
name = gem[4..-1][/^.*(?=-\d\.)/] | |
(gems[name] ||= []) << version | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Parser for the jQuery Tablesorter Plugin to sort European dates, e.g. 30/02/08 */ | |
$.tablesorter.addParser({ | |
id: 'dates', | |
is: function(s) { return false }, | |
format: function(s) { | |
var dateArray = s.split('/'); | |
return "20" + dateArray[2] + dateArray[1] + dateArray[0]; | |
}, | |
type: 'numeric' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
# Shaun Inman's original Widon't | |
# http://shauninman.com/archive/2006/08/22/widont_wordpress_plugin | |
# | |
# @param [String] text the text to apply Widon't to | |
# @return [String] the text with Widon't applied | |
def widont(text) | |
text.strip! | |
text[text.rindex(' '), 1] = ' ' if text.rindex(' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For Rails 2.3.2 or earlier. | |
require 'maruku' # or use config.gem "maruku" in environment.rb | |
module ApplicationHelper | |
# Replacement for Rails' default Markdown helper which uses Maruku instead | |
# of BlueCloth. | |
def markdown(text) | |
text.blank? ? "" : Maruku.new(text).to_html | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following will allow you to use URLs such as the following: | |
# | |
# example.com/anything | |
# example.com/anything/ | |
# | |
# Which will actually serve files such as the following: | |
# | |
# example.com/anything.html | |
# example.com/anything.php | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.succ = function() { | |
var alphabet = 'abcdefghijklmnopqrstuvwxyz'; | |
var result = ''; | |
for (var i = 0; i < this.length; i++) { | |
if (alphabet.indexOf(this.charAt(i).toLowerCase()) != -1) { | |
if (this.charAt(i).isUpperCase()) { | |
result += alphabet.charAt( | |
alphabet.toUpperCase().indexOf(this.charAt(i)) + 1).toUpperCase(); | |
} else { | |
result += alphabet.charAt(alphabet.indexOf(this.charAt(i)) + 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure that all the arrays in a hash are ordered the same (even if | |
# they have missing elements). | |
def ordered?(hash_of_arrays) | |
hash_of_arrays.all? do |k,v| | |
hash_of_arrays.all? { |k2,v2| v - (v - v2) == v2 - (v2 - v) } | |
end | |
end | |
ordered?({ 1 => [1, 2, 3, 4], 2 => [1, 3, 4], 3 => [2, 4, 5], 4 => [1, 2, 4, 6]}) | |
#=> true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
# "Hello says Bob" - "Bob" | |
#=> "Hello says " | |
# "Hello says Bob" - /l+/ | |
#=> "Heo says Bob" | |
# | |
# @param [String, Regexp] pattern either a string or regular expression to remove from the string. | |
# @return [String] a copy of the string with the pattern remvoed | |
def -(pattern) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace non-ASCII characters with their decimal-encoded XML entity. | |
str.gsub!(/[^\x00-\x7f]/) { |s| "&##{s.unpack("U")[0]};" } |