This file contains hidden or 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
# urlmonitor - print out the URLs requested system wide on the main network interface | |
# Accept a network interface name as an optional argument | |
iface = ARGV.first | |
# No interface specified? Try to guess which one is king.. | |
unless iface | |
`ifconfig -l`.split.each do |iface| | |
next if iface =~ /^lo/ | |
break if `ifconfig #{iface}` =~ /inet (0|1|2)/ |
This file contains hidden or 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
# Monitor HTTP requests being made from your machine with a one-liner.. | |
# Replace "en1" below with your network interface's name (usually en0 or en1) | |
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" | |
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile: | |
# (again replace "en1" with correct network interface name) | |
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"" | |
# All the above tested only on OS X. |
This file contains hidden or 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
#!/usr/bin/env ruby | |
# | |
# Be sure to configure this node in the plugin configuration | |
# Memory stats must be run by root | |
# Ex: | |
# [passenger_memory] | |
# user root | |
# env.memory_stats_command path_to_passenger-memory-stats | |
# | |
This file contains hidden or 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
# syntax_helper.rb | |
module SyntaxHelper | |
WhiteListHelper.tags.merge(UV_SYNTAX_TAGS) | |
def colorize_code(body, options = {}) | |
options = {:line_numbers => false, :theme => DEFAULT_SYNTAX_STYLE}.merge(options) | |
r = RedCloth.new(body || '') | |
output = r.gsub(/<code[\.|\:]([\w\-]+)>(.*?)<\/code[\.|\:]?\1?>/m) do | |
lang, text = $1, $2 | |
html = "<notextile>" + code((text || ''), {:syntax => (lang if UV_SYNTAXES.include?(lang))}.merge(options)) + "</notextile>" |
This file contains hidden or 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
## | |
# Calendar helper with proper events | |
# http://www.cuppadev.co.uk/webdev/making-a-real-calendar-in-rails/ | |
# | |
# (C) 2009 James S Urquhart (jamesu at gmail dot com) | |
# Derived from calendar_helper | |
# (C) Jeremy Voorhis, Geoffrey Grosenbach, Jarkko Laine, Tom Armitage, Bryan Larsen | |
# Licensed under MIT. http://www.opensource.org/licenses/mit-license.php | |
## | |
This file contains hidden or 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
def log_test | |
if Rails::logger | |
# When I run tests in rake or autotest I see the same log message multiple times per test for some reason. | |
# This guard prevents that. | |
unless @already_logged_this_test | |
Rails::logger.info "\n\nStarting #{@method_name}\n#{'-' * (9 + @method_name.length)}\n" | |
end | |
@already_logged_this_test = true | |
end | |
end |
This file contains hidden or 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
def assert_layout(expected=nil, message=nil) | |
clean_backtrace do | |
layout = @response.layout ? @response.layout.split('/').last : false | |
msg = build_message(message, "expecting <?> but rendering with <?>", expected, layout) | |
assert_block(msg) do | |
if expected.nil? | |
@response.layout | |
else | |
expected == layout | |
end |
This file contains hidden or 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 ActionMailer::Base | |
helper ActionView::Helpers::UrlHelper | |
def generic_mailer(options) | |
@recipients = options[:recipients] || (Settings.mailer_to_address if Settings.table_exists?) | |
@from = options[:from] || (Settings.mailer_from_address if Settings.table_exists?) | |
@cc = options[:cc] || "" | |
@bcc = options[:bcc] || "" | |
@subject = options[:subject] || "" |
This file contains hidden or 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 << ActiveRecord::Base | |
def paged_find_tagged_with(tags, args = {}) | |
tags.nil? ? paginate(args) : paginate_tagged_with(tags, args) | |
end | |
def concerned_with(*concerns) | |
concerns.each do |concern| | |
require_dependency "#{name.underscore}/#{concern}" | |
end |