Skip to content

Instantly share code, notes, and snippets.

# encoding: utf-8
module Mongoid #:nodoc:
# Include this module to set the creator of documents.
# This will add a created_at and updated_at field to the +Document+, managed automatically.
#
# To use:
#
# class Person
# include Mongoid::Document
# include Mongoid::Userstamps
@gawin
gawin / userstamp
Created September 16, 2010 08:17
# encoding: utf-8
module Mongoid #:nodoc:
# Include this module to set the creator of documents.
# This will add a created_at and updated_at field to the +Document+, managed automatically.
#
# To use:
#
# class Person
# include Mongoid::Document
# include Mongoid::Userstamps
@gawin
gawin / mongoid.rb
Created May 24, 2011 14:24 — forked from whereisciao/mongoid.rb
Mongoid Observer using ActiveModel.
require "#{RAILS_ROOT}/lib/mongoid/lib/observing.rb"
# Initializer for Observers
User.observers = :user_observer
User.instantiate_observers
# The preferred syntax, similar to AR's setup
# Mongoid.configure do |config|
# config.observers = :user_observer

Keybase proof

I hereby claim:

  • I am gawin on github.
  • I am gawin (https://keybase.io/gawin) on keybase.
  • I have a public key ASD4QuHjJ3Jra6BVlMQWdRnblQ1t96MmCBlf2nHmI7-tRgo

To claim this, I am signing this object:

ERR_SPDY_PROTOCOL_ERROR

Today I found myself in the situation where web pages were not fully served or randomly hang. Often triggering a ERR_SPDY_PROTOCOL_ERROR. First, I suspected this was due to CloudFlare. After some investigation, I found it was my own NGINX installation that was lacking.

Apparently the build of NGINX that came with OpenResty didn't have the tmp_paths set correctly. This can be fixed during the configuration of the build, or afterwards in the configuration files itself. Which was kind of fun since this app didn't use OpenResty but only Sinatra served by Puma and RACK.

NGINX error.log

[crit] 22084#0: *142 open() "/var/lib/nginx/proxy/1/01/0000000011" failed (13: Permission denied) while reading upstream, client: 111.111.111.111, server: my_app.example.com, request: "GET /path HTTP/1.1", upstream: "http://unix:///path/to/app/tmp/puma.sock:/path", host: "my_app.example.com", referrer: "https://my_app.example.com/path"