Skip to content

Instantly share code, notes, and snippets.

View hugobarauna's full-sized avatar

Hugo Baraúna hugobarauna

View GitHub Profile
Rails CMS alternatives
======================
Active projects:
---------------
adva-cms
repo: http://github.com/svenfuchs/adva_cms/
site: http://adva-cms.org/
Last update: 11/24/09
"the cutting edge Rails CMS platform"
@jcf
jcf / spork-1.9.2-p0-error.txt
Created August 19, 2010 13:29
Output from spork crash
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
No server is running
Running specs locally:
dyld: lazy symbol binding failed: Symbol not found: _rb_method_node
Referenced from: /Users/jcf/.rvm/gems/ruby-1.9.2-p0/gems/ruby-debug-base19-0.11.23/lib/ruby_debug.bundle
Expected in: flat namespace
dyld: Symbol not found: _rb_method_node
@sidwood
sidwood / cucumber_support_code_example.rb
Created January 16, 2012 14:13
Quick example of cucumber support code
# features/step_definitions/search_steps.rb
When /^I search for "([^"]*)"$/ do |search_term|
search_catalogue_with search_term, :using_direct_model_access
end
# features/support/search_support.rb
module SearchSupport
class SearchAutomator
@durran
durran / moped.txt
Created February 16, 2012 10:59
First run perf numbers, Moped.
##################################################################
# ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]
# 10gen: mongo-1.5.2
# bson-1.5.2 (BSON::BSON_C)
##################################################################
user system total real
10gen: insert 10,000 blank documents 0.670000 0.060000 0.730000 ( 0.744400)
10gen: insert 10,000 blank documents safe mode 1.200000 0.140000 1.340000 ( 1.800714)
10gen: insert 1,000 normal documents 0.090000 0.010000 0.100000 ( 0.091035)
@pixeltrix
pixeltrix / comparison.rb
Last active December 31, 2015 17:39
Comparison of functional tests vs. integration tests using current implementation and a simple implementation using Rack::Test
require 'benchmark/ips'
require "action_controller/railtie"
class BlogApplication < Rails::Application
config.eager_load = false
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'session'
config.secret_key_base = 'secret'
end
@jasonrudolph
jasonrudolph / 2011-09-29-why-you-dont-get-mock-objects.md
Created September 29, 2011 18:19
RubyConf 2011: Why You Don't Get Mock Objects

"Why You Don't Get Mock Objects" by Gregory Moeck

RubyConf 2011 | 2011-09-29 | Gregory Moeck (@gregmoeck) | Slides

  • Recommended as the best book on mocks: Growing Object-Oriented Software, Guided by Tests by Steve Freeman & Nat Pryce
  • Common arguments against mocks
    • They duplicate implementation
    • They lead to brittle tests
  • Mock objects + procedural programming = bad idea
  • If you're doing traditional Rails development (which tends to follow more of a "procedural", do-this-and-then-do-that style), mock objects probably aren't for you

Devise / Warden Tagged logging

I wrote a middleware (actually two, but they do the same with different implementations) that logs information about signed in scopes in a Rails + Devise application. The solution works with multiple logins (like having a person logged both as an Admin and a User). I tested against Rails 4 and Devise HEAD, but it should work fine in any Rails 3 application.

This solution doesn't use the log_tags configuration option since it isn't very helpful when you need to retrieve information stored in cookies/session. That information isn't 'ready' when the Rails::Rack::Logger is executed, since it happens way down in the middleware chain.

Add one of the following implementations to your application load path and use the following configuration to add the middleware to your application stack:

# application.rb
@carlosantoniodasilva
carlosantoniodasilva / post-receive
Created February 9, 2011 01:28
Basic git post-receive hook file to deploy a Rails app.
#!/bin/bash
APP_NAME="your-app-name-goes-here"
APP_PATH=/home/deploy/${APP_NAME}
# Production environment
export RAILS_ENV="production"
# This loads RVM into a shell session. Uncomment if you're using RVM system wide.
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
@mislav
mislav / _notes.md
Created July 21, 2010 18:25
"livereload" server replacement for working with Rails

A replacement for "livereload" gem on OS X

This script is a replacement for livereload server component designed for working with Rails. It watches the filesystem with FS Events (Mac OS X) rather than with EventMachine. This is better for large projects for wich EventMachine fails with "too many open files" exception.

Sass is supported; .sass files can also be stored in "app/styles/" directory. Compass is detected if "config/compass.rb" file exists.

Installation:

Download this script to somewhere in your PATH and make it executable. You can name it something different than "livereload" if you want to try this and the official gem executable in parallel.

@rtomayko
rtomayko / gist:2601550
Created May 5, 2012 10:58
Open beautiful git-scm.com manual pages w/ git help -w
# The new git-scm.com site includes man pages designed for pleasant viewing in a web browser:
#
# http://git-scm.com/docs
#
# The commands below can be used to configure git to open these pages when
# using `git help -w <command>' from the command line. Just enter the config
# commands in your shell to modify your ~/.gitconfig file.
# Create a new browser command and configure help -w to use it.
git config --global browser.gitscm.cmd "/bin/sh -c 'open http://git-scm.com/docs/\$(basename \$1 .html)' --"