Skip to content

Instantly share code, notes, and snippets.

View base10's full-sized avatar

Nathan L. Walls base10

View GitHub Profile
@base10
base10 / freebsd.json
Created May 21, 2013 20:39
Ansible setup module differences between Ubuntu 12.04 LTS and FreeBSD 8.0
# ansible appservers -m setup -i playbooks/ansible_hosts -u vagrant
{
"ansible_facts": {
"ansible_all_ipv4_addresses": [
"10.0.2.15",
"172.16.2.12"
],
"ansible_all_ipv6_addresses": [],
"ansible_architecture": "amd64",
"ansible_date_time": {
@base10
base10 / url_save.rb
Created September 9, 2012 00:13
Simple script to list the urls of all open Safari tabs in a datestamped YAML file
#!/usr/bin/env ruby
require 'appscript'
require 'yaml'
include Appscript
safari = app 'Safari'
url_list = safari.windows.tabs.URL.get
# Validates whether the value of the specified attribute matches the format of an URL,
# as defined by RFC 2396. See URI#parse for more information on URI decompositon and parsing.
#
# This method doesn't validate the existence of the domain, nor it validates the domain itself.
#
# Allowed values include http://foo.bar, http://www.foo.bar and even http://foo.
# Please note that http://foo is a valid URL, as well http://localhost.
# It's up to you to extend the validation with additional constraints.
#
# class Site < ActiveRecord::Base
INFO: Setting the run_list to ["system"] from JSON
INFO: Starting Chef Run
ERROR: Running exception handlers
ERROR: Exception handlers complete
ERROR: Re-raising exception: NameError - wrong constant name Mysql.Database
/usr/lib/ruby/gems/1.8/gems/chef-0.9.4/bin/../lib/chef/provider.rb:89:in `const_defined?'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.4/bin/../lib/chef/provider.rb:89:in `build_from_file'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.4/bin/../lib/chef/run_context.rb:65:in `load'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.4/bin/../lib/chef/run_context.rb:103:in `call'
/usr/lib/ruby/gems/1.8/gems/chef-0.9.4/bin/../lib/chef/run_context.rb:103:in `foreach_cookbook_load_segment'
#!/usr/bin/php
<?php
function bottle (&$i) {
$bottle;
switch ($i) {
case ($i == 1):
$bottle = 'bottle';
break;
default:
diff --git a/lib/fleakr.rb b/lib/fleakr.rb
index 8e222c8..26ac96a 100644
--- a/lib/fleakr.rb
+++ b/lib/fleakr.rb
@@ -9,7 +9,7 @@ require 'forwardable'
# Require only what we need from ActiveSupport
require 'active_support/core_ext/array'
require 'active_support/core_ext/module'
-require 'active_support/core_ext/blank'
+require 'active_support/core_ext/object/blank'
#!/usr/bin/env ruby
#
# Find bloating passengers and kill them gracefully. Run from cron every minute.
#
# required for passenger since cron has no environment
ENV['HTTPD'] = 'httpd'
MEM_LIMIT = ARGV[0] || 500
it "should map #edit" do
route_for(:controller => "admin/responses", :action => "edit", :id => "1", :message_id => "1").should == "/contact/admin/messages/1/responses/1/edit"
end
it "should map #update" do
route_for(:controller => "admin/responses", :action => "update", :id => "1", :message_id => "1").should == { :path => "/contact/admin/messages/1/responses/1", :method => :put }
end
it "should map #destroy" do
route_for(:controller => "admin/responses", :action => "destroy", :id => "1", :message_id => "1").should == { :path => "/contact/admin/messages/1/responses/1", :method => :delete }
(in /Users/otto/Desktop/Incubator/shallow_routes)
communities GET /communities(.:format) {:action=>"index", :controller=>"communities"}
POST /communities(.:format) {:action=>"create", :controller=>"communities"}
new_community GET /communities/new(.:format) {:action=>"new", :controller=>"communities"}
edit_community GET /communities/:id/edit(.:format) {:action=>"edit", :controller=>"communities"}
community GET /communities/:id(.:format) {:action=>"show", :controller=>"communities"}
PUT /communities/:id(.:format) {:action=>"update", :controller=>"communities"}
DELETE /communities/:id(.:format) {:action=>"destroy", :controller=>"communities"}
community_forums GET /communities/:community_id/forums(.:format) {:action=>"index", :controller=>"forums"}
def create
valid_save = true
Contact.transaction do
## See if we're dealing with a new @contact or an existing contact
## FIXME: Error out if email isn't filled in.
@contact = Contact.find_by_email( params[:contact][:email] )
if @contact.nil?
logger.debug("New contact")