Skip to content

Instantly share code, notes, and snippets.

@brianburridge
brianburridge / gist:934644
Created April 21, 2011 14:34
Clear default text when user selects the input field
$('input[data-default]').select(function () {
if ($(this).val() == $(this).attr('data-default')) {
$(this).val('');
}
});
$('input[data-default]').click(function () {
if ($(this).val() == $(this).attr('data-default')) {
$(this).val('');
}
@brianburridge
brianburridge / config.ru
Created May 23, 2011 18:57
Rack mounting with Rails app
require "config/environment"
require 'api'
rails_app = Rack::Builder.new do
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new
end
run Rack::Cascade.new([
@brianburridge
brianburridge / global_settings.rb
Created June 30, 2011 13:31
An easy and flexible way to set global variables for a Rails app using Ostruct.
require "ostruct"
case RAILS_ENV
when "staging"
google_maps_key = 'staging google maps key'
support_email = 'support@email.com'
ssl_subdomain = 'secure'
original_subdomain = 'www'
when "production"
google_maps_key = 'production google maps key'
@brianburridge
brianburridge / gist:2219745
Created March 27, 2012 20:00
Using html_safe and collect to create links to a post's tags
<%= post.tags.collect{|tag| link_to tag.name, forum_index_path(:tags => tag.name)}.join(' ').html_safe %>
def Tumblr.youtube_views(post)
begin
doc = Hpricot.parse(post)
video_count = 0
if doc.present?
embed_doc = doc.at("embed")
embed_doc = doc.at("iframe") if embed_doc.class != Hpricot::Elem
if !embed_doc.nil?
video_url = embed_doc.attributes["src"]
video_id = video_url.split("/")[4]
@brianburridge
brianburridge / caveatPatchor.js
Created July 10, 2012 16:13
My Propane Customizations
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@brianburridge
brianburridge / gist:3828703
Created October 3, 2012 18:11
Check Hash for key and append to it
if options.class != Hash
options = {class: "required"}
else
options[:class] = ((options[:class] || "") + " required").split(" ").uniq.join(" ")
end
@brianburridge
brianburridge / gist:5310983
Created April 4, 2013 14:48
Create a gemspec from the currently installed gems within a Heroku app
`gem list`.split("\n").each do |gem| a = gem.split(" ");puts "gem '#{a[0]}', '#{a[1].gsub(/[()]/, "")}'";end ;nil
@brianburridge
brianburridge / gist:7362537
Last active December 27, 2015 17:29
Wifi, inefficiencies and a bizarre trip to the library

After dropping my son off at football practice, I attempted to work at Panera Bread for a bit today but the wifi was horribly slow. Sadly, my tethering was unable to bail me out this time because of the poor connection my phone was getting. I packed up and drove down the road to the library. Been meaning to try it anyway.

It's a nice new library. Very modern with all the newest amenities and in great condition. I attempted to use the wifi but it required a username and password. I inquired at the 'Information Desk' and was guided over to another desk to get a library card. Signing up for a card was in itself inefficient, as I had to both present my driver's license and enter the information from it onto another card. Really?

Once I had my new library card, with a password (never had a library card before that required a password) I went back to the information desk. Here I was told that I now had to get signed up for the wifi into a different system and then, an even more bizarre process was explained to me

@brianburridge
brianburridge / gist:11298396
Last active October 8, 2023 12:49
How to load MySQL time zone tables from Mac OS time zone files

The easiest way to load the Mysql Time Zone tables from your Mac OS time zone fields is via this command:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

However, on many systems like mine that will fail because some of the time zone information is incompatible with the database schema for the time zone tables.

Therefore, you'll want to load the time zone information into a text file and edit it to only include the time zones you need. (Or, attempt to find the data breaking the import.)

mysql_tzinfo_to_sql /usr/share/zoneinfo > zone_import.sql