Skip to content

Instantly share code, notes, and snippets.

View mattyoho's full-sized avatar

Matt Yoho mattyoho

  • Portland, OR, USA
View GitHub Profile

Install

brew install logrotate

add to .bash_profile

export PATH=${PATH}:/usr/local/sbin

restart terminal just to check the logrotate command returns something

logrotate -?

make logrotate.d directory inside of /etc/ and add new config file

http {
upstream app_server {
# for UNIX domain socket setups:
server unix:/tmp/app.sock fail_timeout=0;
# for TCP setups, point these to your backend servers
# server 127.0.0.1:8081 fail_timeout=0;
# server 127.0.0.1:8082 fail_timeout=0;
# server 127.0.0.1:8083 fail_timeout=0;
}
require 'minitest/autorun'
###
# Test to demonstrate TCO in Ruby. Tested in 1.9.2+
class TestTCO < MiniTest::Unit::TestCase
code = <<-eocode
class Facts
def fact_helper(n, res)
if n == 1
res

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add:

@mattyoho
mattyoho / test_confirm.rb
Created May 1, 2012 02:43
Capybara test confirm
# http://stackoverflow.com/questions/2458632/how-to-test-a-confirm-dialog-with-cucumber
page.evaluate_script('window.confirm = function() { return true; }')
page.click('Remove')
@mattyoho
mattyoho / silent_assets.rb
Created April 24, 2012 19:37 — forked from cstrahan/silent_assets.rb
Silence assets in Rails
# Place in config/initializers/
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
@mattyoho
mattyoho / integration_spec.rb
Created April 16, 2012 22:03 — forked from austenito/integration_spec.rb
Integration Testing w/ Sorcery
describe "Shopping Cart Requests" do
let!(:user) { Fabricate(:user) }
before(:each) do
login_user_post("admin", "admin")
end
context "when I visit the shopping cart" do
it " show the logged in users' cart items " do
#Test stuff
@mattyoho
mattyoho / 0-readme.md
Created March 19, 2012 13:26 — forked from burke/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

/* See: http://nicolasgallagher.com/micro-clearfix-hack/ */
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:table;
// Firefox <= 3.5 will need the following instead:
// content:".";
@mattyoho
mattyoho / kellum.css
Created March 7, 2012 14:50
Kellum Method - Semantic Text Replace with Image
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}