Skip to content

Instantly share code, notes, and snippets.

View woods's full-sized avatar

Scott Woods woods

View GitHub Profile
@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
# 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 / 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 @@
@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 / 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 / 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 / gen-key-script
Last active October 31, 2024 23:23
Creating gpg keys non-interactively
Key-Type: 1
Key-Length: 2048
Subkey-Type: 1
Subkey-Length: 2048
Name-Real: Root Superuser
Name-Email: root@handbook.westarete.com
Expire-Date: 0
@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 / gist:8713516
Created January 30, 2014 17:07
Command line options in bash
#!/bin/bash
if [ "$1" == "-t" ] ; then
test_mode='true'
else
if [ "$1" == "" ] ; then
test_mode='false'
else
echo "Unrecognized option \"$1\""
echo "Usage: asdf.sh [-t]"
@woods
woods / gist:8138988
Created December 26, 2013 21:35
Run the night's google analytics code
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42147894-1', 'runthenightltd.com');
ga('send', 'pageview');
</script>