Skip to content

Instantly share code, notes, and snippets.

View OutlawAndy's full-sized avatar
🏠
Working from home

Andy Cohen OutlawAndy

🏠
Working from home
View GitHub Profile
@OutlawAndy
OutlawAndy / object_comparator.rb
Created December 3, 2024 02:51
General purpose comparator interface I've occasionally found useful when testing complex objects.
class ObjectComparator < BasicObject
include ::Enumerable
extend ::Forwardable
def initialize(*members)
@members = members.flatten(1)
end
def_delegators :@members, :to_a, :each, :<=>, :==, :eql?, :hash
@OutlawAndy
OutlawAndy / esignature.rb
Created November 16, 2023 22:43
simple digital signature example in Ruby
require 'openssl'
class KeyGen
def initialize
@pkey = OpenSSL::PKey::RSA.new(2048)
@cipher = OpenSSL::Cipher.new('AES-256-CBC')
end
def public_key = @pkey.public_key
def secure_key(password) = @pkey.export(@cipher, password)
@OutlawAndy
OutlawAndy / dialog_controller.js
Created June 22, 2023 00:23
quick spike adapting our TurboFrame Modal approach to work with the dialog element
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ['dialog']
static values = {
shouldOpen: Boolean,
isOpen: Boolean,
}
connect() {
@OutlawAndy
OutlawAndy / TrixAttachmentHelper.rb
Created March 9, 2022 15:24
a Rails system test helper module for attaching files to trix editors
module TrixAttachmentHelper
def attach_to_rich_text_area(trix_editor_id, file:, wait: 1)
page.execute_script(attach_temp_file_input)
find('#temp-file-input').attach_file(file)
page.execute_script(attach_file_to_trix, trix_editor_id)
# this 'expect' ensures that Capybara will wait for the Trix javascript to execute
expect(page).to have_content file.basename
# allow for direct upload to complete, if your app is doing that.
sleep wait

Keybase proof

I hereby claim:

  • I am outlawandy on github.
  • I am outlawandy (https://keybase.io/outlawandy) on keybase.
  • I have a public key ASAqItY0cNuDB37SChPSnJ1DKEQjuo7_Ar4q_UxpDlOy9Ao

To claim this, I am signing this object:

How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS
@OutlawAndy
OutlawAndy / _.md
Created May 2, 2014 11:48
boomstick_motion_wcolor_coffee
@OutlawAndy
OutlawAndy / _.md
Created May 1, 2014 22:37
boomstick_motion_wcolor_coffee
<!doctype html>
<head>
<title>Stripe OAuth Example</title>
</head>
<body>
<%= @access_token %>
</body>
</html>
@OutlawAndy
OutlawAndy / s3_request_builder.rb
Created August 4, 2013 19:40
a simple ruby class for generating Query String Request Authentication urls and signing them. usage: S3RequestBuilder.new("bucket_name","filename.mp3").url expects `AWS_ACCESS_KEY_ID` & `AWS_SECRET_ACCESS_KEY` environment variables.
require 'base64'
require 'cgi'
require 'hmac-sha1'
require 'active_support/core_ext/numeric/time'
class S3RequestBuilder
@@access_key = ENV['AWS_ACCESS_KEY_ID']
@@secret_key = ENV['AWS_SECRET_ACCESS_KEY']
def initialize bucket, filename