Skip to content

Instantly share code, notes, and snippets.

View denmarkin's full-sized avatar

Den Markin denmarkin

  • Rev.com, Inc
  • Carlsbad, CA
View GitHub Profile
@denmarkin
denmarkin / new_company_notification.feature
Created March 11, 2011 20:05
Example email testing cucumber feature
Feature: Notify admin when new company added
In order to manage registration
As an admin
I want to be notified by email about new company added
Scenario: Notify admin about new company
Given they have no companies
When they create company titled MailChimp
Then I should receive an email with subject "Please moderate company ExampleInc"
When I open the email with subject "Please moderate company ExampleInc"
@denmarkin
denmarkin / sass.rb
Created March 29, 2011 19:36
Rails 3 initializer for Heroku/SASS setup
# see http://forrst.com/posts/Setting_up_SASS_on_Heroku-4dZ
# You can put this in config/initializers/sass.rb
# Setup directory in tmp/ to dump the generated css into
require "fileutils"
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "generated"))
# Tell SASS to use the .sass files in public/stylesheets/sass and
# output the css to tmp/stylesheets/generated
# ~/.irbrc
# Requires the following gems: wirble, hirb
#
# Hirb: http://tagaholic.me/hirb/doc/index.html
# Wirble: http://pablotron.org/software/wirble/
require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
@denmarkin
denmarkin / development.rb
Created April 11, 2011 08:38
Example of rails console SQL dumping and result formatting
# dump SQL into console
require 'logger'
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') # rails 2
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT))
else # rails 3
ActiveRecord::Base.logger = Logger.new(STDOUT) if defined? Rails::Console
end
# enable result formatting - install gem 'hirb'
require 'hirb'
@denmarkin
denmarkin / .irbrc.rb
Created April 23, 2011 16:10 — forked from dekart/.irbrc.rb
console luxe - gems for IRb
# Put this content to ~/.irbrc file (no extension)
require "rubygems"
begin
require "ap"
rescue LoadError => err
puts "Cannot find awesome_print gem. Please run 'gem install awesome_print' to install it."
end
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@denmarkin
denmarkin / nginx-init-script.sh
Created April 26, 2011 17:18
ini.d script for nginx, installed by passenger gem
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@denmarkin
denmarkin / devise.en.yml
Created May 4, 2011 18:50
Custom overwrite for Device::SessionsController
sessions:
signed_in: 'Signed in successfully.'
signed_in_first_time: "MY CUSTOM WELCOME GREETING. DO NOT FORGET TO READ OUR GUIDELINE!"
signed_out: 'Signed out successfully.'
@denmarkin
denmarkin / mysql.god.rb
Created May 10, 2011 07:45
God recipes examples for Rackspace Cloud (Ubuntu) with resque and php-cgi. Try any of them with "sudo god -c /path/to/config -D"
God.watch do |w|
w.name = "mysqld"
w.interval = 30.seconds # default
w.start = "service mysql start"
w.stop = "service mysql stop"
w.restart = "service mysql restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
w.pid_file = "/var/lib/mysql/hostname.pid"
@denmarkin
denmarkin / sql_logger.rb
Created May 15, 2011 17:20
Log all SQL statements in RoR 3 app. config/initializers/sql_logger.rb
# config/initializers/sql_logger.rb
connection = ActiveRecord::Base.connection
class << connection
alias :original_exec :execute
def execute(sql, *name)
# try to log sql command but ignore any errors that occur in this block
# we log before executing, in case the execution raises an error
begin
rails_env = ENV['RAILS_ENV'] || 'development'
file = File.open(Rails.root.to_s + "/log/sql_#{rails_env}.log",'a'){|f| f.puts Time.now.to_s+": "+sql} if (%w(staging development).include? rails_env)