Skip to content

Instantly share code, notes, and snippets.

View iainsmith's full-sized avatar

Iain Smith iainsmith

View GitHub Profile
@afeld
afeld / gist:1254889
Created September 30, 2011 20:28
YouTube video ID regex
# Parses YouTube URLs directly or from iframe code. Handles:
# * Address bar on YouTube url (ex: http://www.youtube.com/watch?v=ZFqlHhCNBOI)
# * Direct http://youtu.be/ url (ex: http://youtu.be/ZFqlHhCNBOI)
# * Full iframe embed code (ex: <iframe src="http://www.youtube.com/embed/ZFqlHhCNBOI">)
# * Old <object> tag embed code (ex: <object><param name="movie" value="http://www.youtube.com/v/ZFqlHhCNBOI">...)
/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
$5 #=> the video ID
# test it on Rubular: http://rubular.com/r/eaJeSMkJvo
@shripadk
shripadk / gist:552554
Created August 27, 2010 00:59
Setting up Heroku Hostname SSL with GoDaddy SSL Cert
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS
@jkongie
jkongie / polymorphic_factory.rb
Created March 1, 2010 05:53
Factory Girl - Polymorphic Factory
# Setting up a polymorphic factory for a join table
# Since rosterable is not the default name of the model we are calling, we can't use the convenience method
# that is used for area (f.association)
# All we have to do is fall back to the block way of doing it, calling f.rosterable and passing in the
# object you want to populate it with ( in this case a template). This will fill in both rosterable_id
# and rosterable_type for us
Factory.define(:template_rostered_area, :class => RosteredArea) do |f|
f.association :area
f.rosterable { |a| a.association(:template)}