Skip to content

Instantly share code, notes, and snippets.

View reservationlive's full-sized avatar

Administrator reservationlive

View GitHub Profile
$(document).ready(function() {
$("a[rel=external]").click(function(){
_gaq.push(['_trackPageview', '/outgoing/' + $(this).attr('href')]);
});
});
<a rel='external' href='http://blog.reservationlive.net/'>ReservationLove</a>
180.upto(230) do |green|
if green % 10 == 0
puts "<p style='background:#fa" + green.to_s(base=16) + "ae;'>Sexy</p>"
end
end
230.downto(180) do |red|
if red % 10 == 0
puts "<p style='background:#" + red.to_s(base=16) + "faae;'>Sexy</p>"
end
end
/* ------------------------------------------------------------------------- */
// Convert str to UTF-8 (if not already), then convert that to HTML named entities.
// and numbered references. Compare to native htmlentities() function.
// Unlike that function, this will skip any already existing entities in the string.
// mb_convert_encoding() doesn't encode ampersands, so use makeAmpersandEntities to convert those.
// mb_convert_encoding() won't usually convert to illegal numbered entities (128-159) unless
// there's a charset discrepancy, but just in case, correct them with correctIllegalEntities.
function makeSafeEntities($str, $convertTags = 0, $encoding = "") {
if (is_array($arrOutput = $str)) {
foreach (array_keys($arrOutput) as $key)
For example, convert this:
["AUD", "Australian Dollar"],
["NZD", "New Zealand Dollar"],
["USD", "US Dollar"],
to this:
["Australian Dollar", "AUD"],
["New Zealand Dollar", "NZD"],
We couldn’t find that file to show.
@reservationlive
reservationlive / gist:108808
Created May 8, 2009 14:51
Showing how to reference attributes in a polymorphic association
<% for comment in @article.comments %>
<p>Name: <%=h comment.name %><br />
Comment: <%=h comment.body %></p>
<hr />
<% end %>
@reservationlive
reservationlive / Ruby script to convert CSV to YAML
Created February 25, 2009 15:23
Textmate/Ruby script to convert CSV to YAML
#!/usr/bin/env ruby
#
# Originally written by http://redartisan.com/tags/csv
# Added and minor changes by Gavin Laking
# Remove ::Reader and it shall work in Ruby 1.9.x
#
# "id","name","mime_type","extensions","icon_url"
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif"
# "2","image/tiff","image/tiff","|tiff|tif|","/images/icon/blank.png"
#
##
# Calendar helper with proper events
# http://www.cuppadev.co.uk/webdev/making-a-real-calendar-in-rails/
#
# (C) 2009 James S Urquhart (jamesu at gmail dot com)
# Derived from calendar_helper
# (C) Jeremy Voorhis, Geoffrey Grosenbach, Jarkko Laine, Tom Armitage, Bryan Larsen
# Licensed under MIT. http://www.opensource.org/licenses/mit-license.php
##