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
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 }
end
def app_client
Mogli::AppClient.new(AppConfig.facebook.access_token, AppConfig.facebook.app_id)
@tmilewski
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
set_omniauth()
click_link_or_button 'Sign up with Facebook'
end
@tmilewski
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 = ''
result.force_encoding("BINARY")
View placeholder.js.coffee
(($) ->
$.fn.placeholder = ->
# Check for Placeholder Support
$.support.placeholder = (->
"placeholder" of document.createElement("input")
)()
# Emulate Form Placeholders
unless $.support.placeholder
active = document.activeElement
@tmilewski
tmilewski / jquery.textcounter.js.coffee
Created Jan 16, 2012
Manages character counts for a textarea
View jquery.textcounter.js.coffee
# Usage
$("textarea").counter
elements:
counter: '.note-area p.counter'
# Manages Character Counts
jQuery.fn.counter = (opts) ->
defaults =
elements:
counter: '.counter'
View example.html
<html>
<head>
<title>Example</title>
</head>
<body>
<div id="fb-root"></div>
<iframe src="http://www.facebook.com/plugins/like.php?app_id=140499949374170&amp;href=http%3A%2F%2Fexample.com&amp;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="example.com" num_posts="2" width="500"></fb:comments>
</body>
@tmilewski
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
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.
jQuery.extend({
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
tmilewski / gist:820666
Created Feb 10, 2011
Verbose be_valid RSpec matcher
View gist:820666
RSpec::Matchers.define :be_valid do
match do |model|
model.valid?
end
failure_message_for_should do |model|
"expected valid? to return true, got false:\n #{model.errors.full_messages.join("\n ")}"
end
failure_message_for_should_not do |model|
@tmilewski
tmilewski / railscasts.rb
Created Jan 2, 2011
Download all Railscasts Episodes
View railscasts.rb
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = open('http://railscasts.com/') { |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.