Skip to content

Instantly share code, notes, and snippets.

View ajw725's full-sized avatar

Andrew Weinstein ajw725

View GitHub Profile
@ajw725
ajw725 / debug_output.txt
Created February 12, 2021 05:18
Terraform debug output - Cognito account_recovery_setting
2021/02/11 22:10:56 [INFO] Terraform version: 0.14.6
2021/02/11 22:10:56 [INFO] Go runtime version: go1.15.7
2021/02/11 22:10:56 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2021/02/11 22:10:56 [DEBUG] Attempting to open CLI config file: /Users/andrewweinstein/.terraformrc
2021/02/11 22:10:56 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021/02/11 22:10:56 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/02/11 22:10:56 [DEBUG] ignoring non-existing provider search directory /Users/andrewweinstein/.terraform.d/plugins
2021/02/11 22:10:56 [DEBUG] ignoring non-existing provider search directory /Users/andrewweinstein/Library/Application Support/io.terraform/plugins
2021/02/11 22:10:56 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2021/02/11 22:10:56 [INFO] CLI command args: []string{"apply"}
@ajw725
ajw725 / readme.md
Last active March 19, 2016 15:28
Linking two ActiveRecord models with multiple different foreign keys

Linking Two ActiveRecord Models with Multiple Foreign Keys

My colleague and I have been working on a project for a client in the real estate industry. The product we're creating is a Rails app that tracks apartment listings, and one of the key features is that our client's agents must be able to create and edit "specials" that modify the prices of existing listings. There are many different types of specials: those that simply award a credit upon move-in; those that are relative to the rent of the property, such as one month free; and those that only apply during a particular date range, either for the signing of the lease or for the actual move-in date.

Any given special can apply to any number of matching listings, but any given listing can only have one special. We want to be able to retrieve the special linked to a particular listing quickly and easily, so this leads to a pretty straightforward association:

class Property < ActiveRecord::Base
  belongs_to :special
end
@ajw725
ajw725 / red_green_scale.rb
Last active February 11, 2016 21:30
given a single intensity value and range parameters, return a hex string for color on red-green scale
# generate hex string for RGB color on a red-to-green scale. default scale is
# -1 to 1, with -1 = red, 0 = yellow, and 1 = green. options hash can be used to
# reverse the scale (-1 = green, 1 = red) or to provide numbers not centered on zero.
# For example:
# offset = 2, factor = 3: numbers range from -1 to +5
# offset = 3, factor = 1: numbers range from +2 to +4
#
# note that despite being a red-green scale, blue is added (with maximum
# contributions at -50% and +50% intensity) to avoid muddy/brown colors.
#
@ajw725
ajw725 / ActiveRecord_without_Rails.md
Last active February 10, 2016 16:54
using ActiveRecord without Rails

There are plenty of tips out there for using ActiveRecord without Rails, but I was having trouble synthesizing all of the relevant information. Once I got things working, I decided to bring together all of the important pieces I used.

Steps, for an imaginary app called MyApp:

  1. Make directories

     mkdir myapp
     mkdir myapp/lib
     mkdir myapp/db
    

mkdir myapp/config