Skip to content

Instantly share code, notes, and snippets.

class EventController
...
def index
@month = current_month
@year = current_year
if @month == 1
@previous_month = 12
@previous_year = @year - 1
module EventsHelper
def previous_month(month)
if month == 1
12
else
month - 1
end
end
def previous_year(month, year)
@balepc
balepc / gist:340575
Created March 22, 2010 21:52
Typical nginx configuration
worker_processes 2; # Usually number of processors
error_log logs/error.log;
events {
worker_connections 2024;
}
http {
#! /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
# Redis configuration file example
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
# You can specify a custom pid file location here.
pidfile /var/run/redis.pid
@balepc
balepc / .irbrc.rb
Created April 11, 2010 20:01 — forked from dekart/.irbrc.rb
# 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
@balepc
balepc / gist:895023
Created March 30, 2011 18:57
MySQL Performance Tuning Primer
#!/bin/sh
#########################################################################
# #
# MySQL performance tuning primer script #
# Writen by: Matthew Montgomery <mmontgomery@mysql.com> #
# Inspired by: MySQLARd (http://gert.sos.be/demo/mysqlar/) #
# Version: 1.5-r5 Released: 2009-11-22 #
# Licenced under GPLv2 #
# #
@balepc
balepc / ses_quota.rb
Created June 3, 2011 17:15
Amazon SES quota Scout plugin
# Amazon Simple Email Service Quota monitor
# Monitors the maximum number of emails you can send in a 24 hour period and actual sent emails.
class SesQuotaPlugin < Scout::Plugin
needs 'aws/ses'
OPTIONS=<<-EOS
awskey:
name: AWS Access Key
notes: Your Amazon Web Services Access key. 20-char alphanumeric, looks like 022QF06E7MXBSH9DHM02
@balepc
balepc / ses_statistics.rb
Created June 6, 2011 14:59
Amazon SES statistics Scout plugin
# Amazon Simple Email Service Statistics (http://aws.amazon.com/ses/)
# Displays Amazon SES automatically collected statistics regarding your sending activity:
# * Successful delivery attempts
# * Rejected messages
# * Bounces
# * Complaints
class SesStatisticsPlugin < Scout::Plugin
needs 'aws/ses'
@balepc
balepc / ec2_http_health.rb
Created September 15, 2011 13:25
Scout plugin for checking HTTP statuses on AWS EC2
# EC2 Http servers health status
# * Number of running instances
# * Average response time
class Ec2HttpHealth < Scout::Plugin
needs 'right_aws'
needs 'timeout'
OPTIONS=<<-EOS
access_key_id: