Skip to content

Instantly share code, notes, and snippets.

View jbritten's full-sized avatar

Justin Britten jbritten

View GitHub Profile
@jbritten
jbritten / prefinery-iframe-height.js
Created March 19, 2014 15:42
Dynamically resize Prefinery's iframe form height.
/*
It can be difficult to size an iframe properly. The inherit problem
with iframes is that your page controls the size, yet the iframe itself
takes up space. Fortunately, communication is possible across domains
using something called postMessage. This javascript is simply a
cross-browser implementation on how to receive Prefinery's message
containing the form's height so that your iframe's height is set automatically.
You should remove the "height" attribute from your iframe declaration and
post this code in your page's <head>
attr_accessible :invitation_code
attr_accessor :invitation_code
validate :validate_invitation_code, on: :create
def validate_invitation_code
if self.invitation_code == Digest::SHA1.hexdigest('YOUR-SECRET-DECODER-KEY' + self.email)
true
else
errors.add(:invitation_code, "is invalid")
@jbritten
jbritten / Gemfile
Created December 11, 2012 16:59
Creating Testers via the Prefinery API
gem 'prefinery'
package :iptables, :provides => :firewall do
description 'Configure IPTables Firewall'
# Need to run some commands, don't see how to do this unless I hook into a package install
# So, faking a push_text
push_text '', '/dev/null' do
#
# Allow SSH connections on tcp port 22
#
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'),
:backtrace => true