View respond_to_warner.rb
if RUBY_VERSION >= '2.0.0'
class Object
alias :_respond_to? :respond_to?
def respond_to?(symbol, include_all = nil)
_respond_to?(symbol, include_all || false).tap do |b|
if b == false && include_all.nil? && _respond_to?(symbol, true)
warn "WARNING! #{self.class.name} responds to #{symbol}, but it's protected or private (from: #{caller[2].inspect})"
end
end
end
View rack_deflater.rb
require "zlib"
require "stringio"
require "time" # for Time.httpdate
require 'rack/utils'
module Hardwired
class Deflater
DEFAULT_CONTENT_TYPES =
[
View howto.md

RE: https://github.com/jonleighton/poltergeist/issues/44

Use Rack::SimpleEndpoint to prevent Poltergeist/PhantomJS from crashing on TTF fonts.

Create config/initializers/middleware-deny-ttf-to-phantomjs-under-test.rb:

if Rails.env.test?
  require 'rack/contrib/simple_endpoint'
  Rails.application.config.middleware.insert_after Rack::Runtime, Rack::SimpleEndpoint, /\.ttf$/ do |req, res|
View sprockets-server-monkeypatch-deny_phantomjs_ttf.rb
# config/initializers/sprockets-server-monkeypatch-deny_phantomjs_ttf.rb
# Monkey patch under test environment that prevents PhantomJS on OSX
# from crashing when dealing with TTF webfonts.
# Note: depending on your setup, it's likely that the RUBY_PLATFORM
# is not actually relevant for server - it's the UA that crashes.
if Rails.env.test? # && RUBY_PLATFORM =~ /darwin/
module Sprockets::Server
def call_with_env_instance_var(env)
@env = env
View binenv.c
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define MAX_ARGS 255
int main(const int argc, char** argv) {
const char delimiters[] = " ";
char *args[MAX_ARGS], *running, *token;
View set_subset_ext.rb
require 'set'
class Set
def subset(&pred)
Set.new.tap do |subset|
each do |x|
subset << x if pred.call(x)
end
end
end
View activesupport_time_calculations_of_hour-monkey-patch.rb
require 'active_support/core_ext/time/calculations'
unless Time.method_defined?(:beginning_of_hour)
class Time
# Returns a new Time representing the start of the hour (x:00)
def beginning_of_hour
change(:min => 0)
end
alias :at_beginning_of_hour :beginning_of_hour
View contact.rb
class Contact < ActiveRecord::Base
validates :dob, :presence => true, :if => :is_patient?
validates :contact_type_id, :first_name, :last_name, :presence => true
has_many :calls
belongs_to :contact_type
def is_patient?
View main.js
/*
*= include fragments/prefix
*= include lib/util
*= include fragments/util_suffix
*/
View ability.rb
can :edit_any, Array do |arr|
arr.any?{|p| p.is_a?(Project) && can?(:edit, p)}
end