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
#!/usr/bin/env ruby | |
command = '/usr/bin/passenger-memory-stats' | |
memory_limit = 200 # megabytes | |
def running?(pid) | |
begin | |
return Process.getpgid(pid) != -1 | |
rescue Errno::ESRCH | |
return false |
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 Library | |
def self.leaf_paths_of(paths) | |
paths.select{|path| | |
!paths.any?{|other| | |
other.start_with?(path + '/') | |
} | |
end | |
end | |
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
guard 'annotate' do | |
watch( 'db/schema.rb' ) | |
# Uncomment the following line if you also want to run annotate anytime | |
# a model file changes | |
#watch( 'app/models/**/*.rb' ) | |
end |
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 'net/http' # CODE FROM: https://github.com/mwmitchell/rsolr/blob/master/lib/rsolr/connection.rb | |
require 'net/https' | |
# The default/Net::Http adapter for RSolr. | |
class RSolr::Connection | |
# using the request_context hash, | |
# send a request, | |
# then return the standard rsolr response hash {:status, :body, :headers} | |
def execute client, request_context |
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
GIT | |
remote: git://github.com/AlessandroBerardi/activerecord_null_object.git | |
revision: b042c43b8cafb753300a13f2aaeeeaf6c79558f2 | |
branch: rails_3_2 | |
specs: | |
activerecord_null_object (0.3.0) | |
activerecord (~> 3.2.11) | |
activesupport (~> 3.2.11) | |
GIT |
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
source 'https://rubygems.org' | |
gem 'ruleby', github: 'Codalytics/ruleby' | |
gem 'q_rules', path: 'q_rules' | |
##################################### | |
# Core Infrastructure | |
##################################### | |
gem 'rails', '~> 3.2.12' | |
gem 'json', '>= 1.7.7' # Required to fix Denial of Service and Unsafe Object Creation Vulnerability in JSON [CVE-2013-0269] |
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
class Filter | |
include FormObject | |
# Proc because Date.yesterday changes every day :) | |
attribute :from, Date, default: Proc.new { Date.yesterday } | |
attribute :to, Date, default: Proc.new { 1.month.from_now - 1.day } | |
end | |
# in controller | |
@filter = Filter.new(params[:filter]) |
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
class Client < ActiveRecord::Base | |
belongs_to :pricing_level | |
end | |
class PricingLevel | |
def self.find_default | |
#... | |
end | |
end |
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
class CoursesController < ApplicationController | |
expose(:course, attributes: :course_params) | |
expose(:current_course) { current_user.courses.find_by_id(params[:id] || params[:course_id]) } | |
expose(:first_of_each_month_of_course) { (current_course.start_date.change(day: 1)..current_course.end_date).select{ |d| d.day == 1 } } | |
# ... | |
end | |
# Orginal code gives: | |
# line 4 of [PROJECT_ROOT]/app/controllers/courses_controller.rb: block in <class:CoursesController> |
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
the next common error is likely from side effects: "How did the value of this variable change?!" | |
immutability... |
OlderNewer