Skip to content

Instantly share code, notes, and snippets.

# experiments with logging!
# Logging hook.
before :save, :story_log
# hmm?
before :save!, :story_log
# Logging goodies
def story_log
# the part of the story controller that does the saving and such
def edit
@story = Story.get(params[:id])
@poll = @story.poll[0]
#@blogs = @story.user.blogadmins.map { |b| b.blog }
@blogs = @story.user.allowed_blogs
@taglist = params[:tags] || @story.tags.map { |t| t.tag }.join(", ")
if request.post?
if (params[:commit] == "Preview")
Backtrace:
# File Line Location
0 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 270 in `rescue in require_frameworks'
1 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 266 in `require_frameworks'
2 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 131 in `process'
3 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 110 in `run'
4 /home/jeremy/dk4-exper/config/environment.rb 9 in `'
5 /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.2/lib/phusion_passenger/railz/application_spawner.rb 267 in `require'
6 /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.2/lib/phusion_passenger/railz/application_spawner.rb 267 in `preload_application'
7 /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.2/lib/phusion_passenger/railz/application_spawner.rb 227 in `block in initialize_server'
sub url_story {
my $req = shift;
my @path = @_; #shift;
my $p = {};
my $len = scalar @path;
if ($len == 5){
if ($path[$#path] =~ /^-/){
$p->{id} = $path[3];
/* This should be a highly unusual circumstance,
* but apparently there's known issues with
* IE & 'deflate' - as in, IE claims that it can
* handle deflate, but doesn't actually handle
* it correctly. If we have content encoded with
* deflate and our user agent appears to be IE,
* it's probably safest to decompress it and
* let mod_deflate deal with it properly. This
* is along the lines of tossing it over the
* fence and letting Arby's deal with it. */
@ctdk
ctdk / gist:1123158
Created August 3, 2011 17:07
webhead_dev_test role
# recipe[dk4] is the one that doesn't run in a role's run_list, but runs if you spell out the recipes in a
# node's run_list
name "webhead_dev_test"
description "The development webhead role, for testing."
run_list "recipe[perl]", "recipe[memcached]", "recipe[start_pkgs]", "recipe[apache2]", "recipe[lighttpd]", "recipe[cpan_stuff]", "recipe[dk4_code]", "recipe[dk4]", "recipe[bzrtest]"
default_attributes "dk4" => { "git_branch" => "master", "deploy_type" => "development" }, "lighttpd" => { "extforward_headers" => [ "X-Cluster-Client-Ip", "X-Forwarded-For" ], "extforward_forwarders" => [ "::ffff:10.1.10.215", "10.1.10.215" ] }
@ctdk
ctdk / gist:1123171
Created August 3, 2011 17:10
chef debug output
[Wed, 03 Aug 2011 09:59:23 -0700] INFO: *** Chef 0.10.2 ***
[Wed, 03 Aug 2011 09:59:23 -0700] DEBUG: Loading plugin os
[Wed, 03 Aug 2011 09:59:23 -0700] DEBUG: Loading plugin kernel
[Wed, 03 Aug 2011 09:59:23 -0700] DEBUG: Loading plugin ruby
[Wed, 03 Aug 2011 09:59:23 -0700] DEBUG: Loading plugin languages
[Wed, 03 Aug 2011 09:59:23 -0700] DEBUG: ---- Begin ruby -e "require 'rbconfig'; puts %Q(target_cpu=#{::Config::CONFIG['target_cpu']},bin_dir=#{::Config::CONFIG['bindir']},host_os=#{::Config::CONFIG['host_os']},target_vendor=#{::Config::CONFIG['target_vendor']},target_os=#{::Config::CONFIG['target_os']},host_cpu=#{::Config::CONFIG['host_cpu']},host_vendor=#{::Config::CONFIG['host_vendor']},version=#{RUBY_VERSION},platform=#{RUBY_PLATFORM},host=#{::Config::CONFIG['host']},release_date=#{RUBY_RELEASE_DATE},ruby_bin=#{::File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])},target=#{::Config::CONFIG['target']},)" STDOUT ----
[Wed, 03 Aug 2011 09:59:23 -0700] DEBUG: target_cpu=x86_64,bin
@ctdk
ctdk / gist:1123201
Created August 3, 2011 17:20
dk4 default recipe
#
# Cookbook Name:: dk4
# Recipe:: default
#
# Copyright 2011, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "apache2"
(function(a,b){ if(/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u
@ctdk
ctdk / gist:2218008
Created March 27, 2012 17:06
ufw firewall attributes
override_attributes(
"firewall" => {
"rules" => [
"internal" => {
"interface" => "eth1",
"action" => "allow"
},
"everything" => {
"action" => "deny"
}