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 CachedMethod | |
def self.included(base) | |
base.class_eval do | |
@method_cache_validators = Hash.new(0) | |
extend ClassMethods | |
end | |
end | |
module ClassMethods |
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
# Run rake db:size to get a print of your database size in bytes. | |
# Works for Mysql, as for the others not really sure. | |
namespace :db do | |
desc 'Print data size' | |
task :size => :environment do | |
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database] | |
adapter = ActiveRecord::Base.connection.adapter_name.downcase |
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
# Usage: ruby fetch_logos.rb <FULL_DOMAIN> | |
require 'httparty' | |
require 'nokogiri' | |
require 'css_parser' | |
require 'byebug' | |
class Array | |
def self.wrap(object) | |
if !object.is_a?(Array) |
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
let isRunning = false | |
const foo = function() { | |
isRunning = true | |
console.log('called') | |
isRunning = false | |
} | |
const events = ['click', 'mousedown'] | |
let func = function(eventsArr, cb) { |
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 String | |
module WidgetExceptions | |
class InvalidWidget < ArgumentError; end | |
end | |
def widget_inject(widgets = []) | |
self_with_widgets = self.clone | |
widgets.sort_by {|w| w[:position] }.reverse.each do |widget| | |
raise WidgetExceptions::InvalidWidget, "widget must be a hash, was #{widget.class.name}" unless widget.is_a?(Hash) |
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 'active_record' | |
require 'active_record/fixtures' | |
Fixtures.create_fixtures('test/fixtures/', ActiveRecord::Base.connection.tables) |
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
<%= f.label :time_zone %> | |
<%= f.time_zone_select :time_zone %> |
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
check process thin-3000 with pidfile /var/www/html/redmine2/current/tmp/pids/thin.3000.pid | |
start program = "cd /var/www/html/redmine2/current && /usr/local/rvm/bin/rvm default do bundle exec thin start -C /var/www/html/redmine2/current/config/thin/performance.yml" | |
stop program = "cd /var/www/html/redmine2/current && /usr/local/rvm/bin/rvm default do bundle exec thin stop -C /var/www/html/redmine2/current/config/thin/performance.yml" | |
if 3 restarts within 5 cycles then timeout | |
if totalmem is greater than 400.0 MB for 2 cycles then restart | |
group thin |
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
check process thin-3000 with pidfile /var/www/html/redmine2/current/tmp/pids/thin.3000.pid | |
start program = "cd /var/www/html/redmine2/current && /usr/local/rvm/bin/rvm default do bundle exec thin start -C /var/www/html/redmine2/current/config/thin/performance.yml" | |
stop program = "cd /var/www/html/redmine2/current && /usr/local/rvm/bin/rvm default do bundle exec thin stop -C /var/www/html/redmine2/current/config/thin/performance.yml" | |
if 3 restarts within 5 cycles then timeout | |
if totalmem is greater than 400.0 MB for 2 cycles then restart | |
group thin |
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 FavoritesManager | |
attr_reader :user_id | |
def initialize(user_id) | |
@user_id = user_id | |
@client = REDIS | |
end | |
def favorite_post(post) |
NewerOlder