Skip to content

Instantly share code, notes, and snippets.

Tom Milewski tmilewski

Block or report user

Report or block tmilewski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tmilewski / gist:2694412
Created May 14, 2012 — forked from yuki24/gist:1187574
testing facebook connect with capybara and rspec
View gist:2694412
require 'mogli'
module FacebookIntegrationHelpers
shared_context "with unconnected facebook user" do
let(:fb_user) { create_test_user(installed: false) }
after { fb_user.destroy }
def app_client, AppConfig.facebook.app_id)
tmilewski / facebook_registration.rb
Created May 7, 2012 — forked from nicalpi/facebook_registration.rb
Testing Omniauth with Devise, Rspec and Capybara
View facebook_registration.rb
background do
click_link_or_button 'Sign up with Facebook'
tmilewski / app.rb
Created Mar 26, 2012 — forked from cpatni/app.rb
unique calculation using redis
View app.rb
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
(($) ->
$.fn.placeholder = ->
# Check for Placeholder Support
$.support.placeholder = (->
"placeholder" of document.createElement("input")
# Emulate Form Placeholders
unless $.support.placeholder
active = document.activeElement
tmilewski /
Created Jan 16, 2012
Manages character counts for a textarea
# Usage
counter: '.note-area p.counter'
# Manages Character Counts
jQuery.fn.counter = (opts) ->
defaults =
counter: '.counter'
View example.html
<div id="fb-root"></div>
<iframe src=";;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe>
<fb:comments href="" num_posts="2" width="500"></fb:comments>
tmilewski / jquery.filterBy.custom.js
Created Apr 13, 2011
Filters a select field based a selection from another.
View jquery.filterBy.custom.js
$(document).ready(function() {
$('.search select#search_tour_stop').filterBy('.search select#search_year');
jQuery.fn.filterBy = function(watch) {
options = new Array;
target = $(this);
target.find('option').each(function(index, option) {
tmilewski / jquery.getScript.js
Created Mar 31, 2011
Replace the normal jQuery getScript function with one that supports debugging and which references the script files as external resources rather than inline. Helps with debugging in IE.
View jquery.getScript.js
// Helps with IE debugging.
getScript: function(url, callback) {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
var done = false; // Handle Script loading
script.src = url;
script.onload = script.onreadystatechange = function() { // Attach handlers for all browsers
if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
tmilewski / gist:820666
Created Feb 10, 2011
Verbose be_valid RSpec matcher
View gist:820666
RSpec::Matchers.define :be_valid do
match do |model|
failure_message_for_should do |model|
"expected valid? to return true, got false:\n #{model.errors.full_messages.join("\n ")}"
failure_message_for_should_not do |model|
tmilewski / railscasts.rb
Created Jan 2, 2011
Download all Railscasts Episodes
View railscasts.rb
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = open('') { |f| Hpricot(f) }
total_episodes = (doc/'div.number').first.inner_html[1,3].to_i
total_pages = (total_episodes / 10).ceil
(1..total_pages).each do |i|
puts "PAGE #{i} ================================"
You can’t perform that action at this time.