This file contains hidden or 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 WillPaginate | |
| class RemoteLinkRenderer < LinkRenderer | |
| def page_link(page, text, attributes = {}) | |
| @template.link_to_remote( text, {:url => url_for(page), :method => :get}, attributes) | |
| end | |
| end | |
| end |
This file contains hidden or 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
| after_filter :compress | |
| def compress | |
| if self.request.env['HTTP_ACCEPT_ENCODING'] and self.request.env['HTTP_ACCEPT_ENCODING'].match(/gzip/) | |
| if self.response.headers["Content-Transfer-Encoding"] != 'binary' | |
| begin | |
| ostream = StringIO.new | |
| gz = Zlib::GzipWriter.new(ostream) | |
| gz.write(self.response.body) | |
| self.response.body = ostream.string | |
| self.response.headers['Content-Encoding'] = 'gzip' |
This file contains hidden or 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
| # Add Template Identification HTML Comments to ERB output | |
| module ::ActionView | |
| module TemplateHandlers | |
| class ERB < TemplateHandler | |
| include Compilable | |
| cattr_accessor :erb_trim_mode | |
| self.erb_trim_mode = '-' | |
| def compile(template) | |
| buf = <<-HTML | |
| <% unless request and request.xhr? %> |
This file contains hidden or 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 'prawn/measurement_extensions.rb' | |
| class StandardBriefB < Prawn::Document | |
| def initialize(*args) | |
| super( | |
| :page_size => 'A4', | |
| :page_layout => :portrait, | |
| :margin => [107.4.mm, 8.1.mm, 30.mm, 24.1.mm] | |
| ) | |
| options = args.last.is_a?(Hash) ? args.last : {} |
This file contains hidden or 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 ActiveRecord | |
| class Base | |
| # updates a single attribute on the record directly to the database using | |
| # ActiveRecord::Base.update_all | |
| def update_single_attribute(name, value) | |
| write_attribute(name, value) | |
| self.class.update_all({name => value}, {self.class.primary_key => read_attribute(self.class.primary_key)}, {:limit => 1}) | |
| end | |
| end | |
| end |
This file contains hidden or 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
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: mongodb | |
| # Required-Start: $all | |
| # Required-Stop: $all | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: starts the mongodb data-store | |
| # Description: starts mongodb using start-stop-daemon |
This file contains hidden or 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
| # ~/.bashrc: executed by bash(1) for non-login shells. | |
| # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
| # for examples | |
| # If not running interactively, don't do anything | |
| [ -z "$PS1" ] && return | |
| # ANSI color codes |
This file contains hidden or 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 CallerMethodName | |
| extend self | |
| def caller_method_name | |
| parse_caller(caller(2).first).last | |
| end | |
| def parse_caller(at) | |
| if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at | |
| file = Regexp.last_match[1] | |
| line = Regexp.last_match[2].to_i |
This file contains hidden or 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 DynamicAttributes | |
| class DynamicAttributesError < StandardError; end; | |
| def self.included(base) | |
| base.send(:include, InstanceMethods) | |
| base.send(:extend, ClassMethods) | |
| end | |
| module ClassMethods |
This file contains hidden or 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 'ostruct' | |
| class ROpenStruct < OpenStruct | |
| def table | |
| @table ||= {} | |
| end | |
| def method_missing(mid, *args) | |
| mname = mid.id2name | |
| len = args.length |
OlderNewer