View paperclip_initializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Para salvar a altura e largura das imagens enviadas pelo plugin paperclip, utilize o callback abaixo | |
# | |
# class Document < ActiveRecord::Base | |
# | |
# has_attached_file :document, :styles => { :medium => "300x300>" } | |
# | |
# before_save :save_dimensions | |
# | |
# def save_dimensions | |
# if document.image? |
View Interval.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Interval = function( fn, delay ) { | |
this.id = null; | |
this.fn = fn; | |
this.delay = delay; | |
}; | |
Interval.prototype = { | |
start: function() { | |
if (this.id === null) this.id = setInterval(this.fn, this.delay); |
View tests.watchr.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV["WATCHR"] = "1" | |
system 'clear' | |
def growl(message) | |
growlnotify = `which growlnotify`.chomp | |
title = "Watchr Test Results" | |
message.gsub! /\[[0-9]+?m/, '' | |
image = message.include?('0 failures, 0 errors') ? "~/.watchr_images/pass.png" : "~/.watchr_images/fail.png" | |
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'" | |
system %(#{growlnotify} #{options} &) |
View replace-class.jquery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.extend({ | |
replaceClass: function(original, replace) { | |
return this.each(function() { | |
jQuery(this).removeClass(original); | |
jQuery(this).addClass(replace); | |
}); | |
} | |
}); |
View fizz_buzz_in_78_bytes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1..100).each{|n|f=n%3==0?"Fizz":nil;b=n%5==0?"Buzz":nil;p f||b ?"#{f}#{b}":n} |
View run_deve_server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This file is part of the Spludo Framework. | |
* Copyright (c) 2009-2010 DracoBlue, http://dracoblue.net/ | |
* | |
* Licensed under the terms of MIT License. For the full copyright and license | |
* information, please see the LICENSE file in the root folder. | |
*/ | |
var child_process = require('child_process'); | |
var fs = require("fs"); |
View rspec_should_change_bug.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rspec' | |
class TestBug | |
attr_reader :array | |
def initialize | |
@array = [] | |
end | |
View ultra_simple_counter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1..10).each do |i| | |
print "\r" | |
print "#{i}" | |
sleep 0.1 | |
end |
View highline_gem_use_case.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'highline' | |
prompt = HighLine.new | |
prompt.say("Hello!") | |
username = prompt.ask("Tell me your username: ") | |
password = prompt.ask("And now your password: ") { |options| options.echo = false } | |
prompt.say("Thanks #{username}! bye") |
View authentication_matcher.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AuthenticationMatcher | |
class RequireAuthentication | |
def initialize(method, action, params, context) | |
@method = method | |
@action = action | |
@params = params | |
@context = context | |
end | |
def matches?(controller) |
OlderNewer