This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Configure AWS provider | |
| variable "acme_operations" { | |
| default = "ACCOUNTID" | |
| } | |
| provider "aws" { | |
| alias = "acme_operations" | |
| profile = "acme_operations" | |
| region = "${var.aws_default_region}" | |
| shared_credentials_file = "./credentials" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| require "bundler/inline" | |
| rescue LoadError => e | |
| $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
| raise e | |
| end | |
| gemfile(true) do | |
| source "https://rubygems.org" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # the new and improved one-file rails app -- now including | |
| require "action_controller/railtie" | |
| class Tester < Rails::Application | |
| config.session_store :cookie_store, :key => '_rails_session' | |
| config.secret_token = '095f674153982a9ce59914b561f4522a' | |
| end | |
| class UsersController < ActionController::Base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # frozen_string_literal: true | |
| require 'active_record' | |
| require 'rspec/autorun' | |
| require 'pg' | |
| require 'byebug' | |
| # Extend for effect | |
| class String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Order | |
| include ActiveModel::Validations | |
| attr_reader :name | |
| validates :name, presence: true | |
| def initialize(name) | |
| @name = name | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Orders < ActiveRecord::Migration[7.0] | |
| def change | |
| create_table :orders do |t| | |
| t.string :first_name # use Rails validations | |
| t.string :last_name, null: false, limit: 128 | |
| end | |
| end | |
| end | |
| Orders.migrate(:up) unless Orders.data_source_exists?(:orders) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| require 'openssl' | |
| TYPES = { | |
| 6 => {magic: 'RSA1', private_key: false}, | |
| 7 => {magic: 'RSA2', private_key: true} | |
| } | |
| data = ARGV[0] ? File.binread(ARGV[0]) : $stdin.binmode.read | |
| type, version, algo, magic, bits, rest = data.unpack('ccx2l<a4l<a*') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'openssl' | |
| require 'base64' | |
| require 'rexml/document' | |
| class PKeyRSAConverter | |
| def initialize(from_pem: nil, from_xml: nil) | |
| @from_pem = from_pem | |
| @from_xml = from_xml | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "openssl" | |
| require "digest" | |
| def aes128_cbc_encrypt(key, data, iv) | |
| key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize) | |
| iv = Digest::MD5.digest(iv) if(iv.kind_of?(String) && 16 != iv.bytesize) | |
| aes = OpenSSL::Cipher.new('AES-128-CBC') | |
| aes.encrypt | |
| aes.key = key | |
| aes.iv = iv |