Skip to content

Instantly share code, notes, and snippets.

View woods's full-sized avatar

Scott Woods woods

View GitHub Profile
@woods
woods / auto.direct.erb
Last active August 29, 2015 13:56
Example of conditional automount map in chef templates
/dlt/repo storage.
/dlt/users storage.
<% if node['application'] %>
/dlt/<%= node['application'] %> -local storage.dlt/ifs/data/<%= node['application'] %>
/dlt/<%= node['application'] %> -local storage.dlt/ifs/data/<%= node['application'] %>
<% end %>
@woods
woods / README.md
Created February 13, 2014 16:05
Thoughts on chef, gpg, git, and group permissions

Justin Patterson and I brainstormed this operation in the hopes of finding a more secure, and perhaps more convenient alternative to chef encrypted data bags and our secure drive.

  • Like rbenv, each directory can potentially have a .gpg-recipients file that contains the identifiers of recipients who should be allowed to decrypt the files in that directory and in child directories. Another way of saying the same thing is that a given file should be decrypt-able by the union of recipients listed in .gpg-recipients files of all parent directories.
  • The root of the project contains a .gpg-known-keys directory. Each file in that directory is the public key of one of the potential recipients. This directory by itself does not grant any permissions — it just provides the database of potential recipients that are known to the system. This is our mechanism for distributing public keys — it’s essentially our own key server.
  • When we’re encrypting a file, the command reads each .gpg-recipients file in each of the par
@woods
woods / gpgme_demo.rb
Created February 25, 2014 12:48
Example of using GPGME to access a keyring in a nonstandard location
# Read source here: https://github.com/ueno/ruby-gpgme
require 'gpgme'
# The given directory must contain pubring.gpg
GPGME::Engine.home_dir = 'spec/fixtures/gnupg'
GPGME::Key.find(:public) # => An array of public key objects
# Print ascii-armored public key to stdout
@woods
woods / snippet.html
Created October 18, 2014 16:23
Code snippet for New Leaf virtual tour via "sphere"
<iframe src="https://www.thesphere.com/direct_embed/311266" height="500" width="100%" allowfullscreen="true" frameborder="0" scrolling="no"></iframe>
@woods
woods / ruby-2.0.0.diff
Created November 2, 2014 05:06
Get ruby-2.0.0 to build on Ubuntu 14.04
Used this to build ruby-2.0.0 on Ubuntu 14.04. The command was:
rbenv install --patch 2.0.0-p353 < ruby-2.0.0.diff
Ref: https://github.com/sstephenson/ruby-build/issues/526#issuecomment-37932244
diff -ur ext/readline/readline.c ext/readline/readline.c
--- ext/readline/readline.c 2014-03-18 13:53:31.866359527 +0100
+++ ext/readline/readline.c 2014-03-18 13:56:26.390247250 +0100
@@ -1883,7 +1883,7 @@
# Include this module into your fake models to get some helpful default functionality.
#
# Example usage:
#
# class AuxiliaryOfficer
# include FakeModel
#
# attr_accessor :name, :started_on, :comments
#
# def self.fake_attributes
@woods
woods / application_helper.rb
Created January 8, 2015 14:40
An example of a helper for determining which instance/flavor we're running.
# A helper for determining which partner site we're on. This can be
# used for setting a CSS class on the body tag in the layout, or
# for referencing namespaced assets or translations.
def parner(host=request.host)
if $ENV['PARTNER'] == 'graduate' || host =~ /graduate/i
'graduate'
elsif $ENV['PARTNER'] == 'schreyer' || host =~ /schreyer/i
'schreyer'
else
# decide whether to fail or default to one of the above
irb(main):006:0* class Dog
irb(main):007:1> def bark
irb(main):008:2> puts "Ruff!!"
irb(main):009:2> end
irb(main):010:1> def age
irb(main):011:2> 12
irb(main):012:2> end
irb(main):013:1> end
=> :age
irb(main):014:0>
@woods
woods / current_partner.rb
Created May 13, 2015 20:19
How we might spec out the global current_partner method
# This lives in config/initializers/current_partner.rb
# A global method to return the current partner
def current_partner
Partner.current
end
class User
has_many :things
has_many :sub_things, through: :things
has_many :sub_sub_things, through: :sub_things
end