Skip to content

Instantly share code, notes, and snippets.

View IanVaughan's full-sized avatar
👯‍♀️
OMG

Ian Vaughan IanVaughan

👯‍♀️
OMG
View GitHub Profile
@IanVaughan
IanVaughan / git-push-all
Created August 6, 2020 14:53
Push each commit on the branch on its own so CI builds each one by one
branch=$(git branch --show-current)
for sha1 in $(git rev-list --reverse ...master) ; do
git push origin $sha1:$branch --force
done
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<http://www.foo.com|This message *is* a link>"
}
}
]
gcloud config set project ${PROJECT_ID}
gcloud sql instances create ex-kills-db-us-west1 --region=us-west1 --database-version=POSTGRES_9_6 --tier=db-f1-micro
gcloud sql instances describe ex-kills-db-us-west1 #=> connectionName: ex-kills:us-west1:ex-kills-db-us-west1
gcloud sql users set-password postgres --instance=ex-kills-db-us-west1 --prompt-for-password #=> 123456
gcloud container clusters create ex-kills-cluster-us-west1 --num-nodes=1 --zone=us-west1 --scopes=gke-default,sql-admin
gcloud container clusters get-credentials --zone=us-west1 ex-kills-cluster-us-west1
gcloud config set container/cluster ex-kills-cluster-us-west1
mkdir -p /tmp/cloudsql
May 13 08:00:33.022	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:114:in `get'
May 13 08:00:33.022	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:107:in `request'
May 13 08:00:33.022	pid=4 tid=baglec WARN: /app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/client.rb:119:in `request'
May 13 08:00:33.021	pid=4 tid=baglec WARN: OAuth2::Error: internal_server_error: Sorry, we are experiencing technical difficulties. Please try again later.
May 12 20:00:59.103	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:114:in `get'
May 12 20:00:59.103	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:107:in `request'
May 12 20:00:59.103	pid=4 tid=40uw WARN: /app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/client.rb:119:in `request'
# Put somewhere in your $PATH, and chmod +x git-rename
# On a branch with files already moved and changed locally but not in git.
# Usage:
# git rename existing-checked-in-filename new-and-changed-filename
#!/usr/bin/env bash
FROM=$1
TO=$2
mv $TO ${TO}-1
@IanVaughan
IanVaughan / cred-diff
Created April 8, 2020 09:53
See diffs between rails credentials
#!/usr/bin/env bash
# usage: On your branch or commit 'cred-diff production'
git checkout production --quiet
rails credentials:show --environment $1 > /tmp/prod
git checkout - --quiet
rails credentials:show --environment $1 > /tmp/yours
diff /tmp/prod /tmp/yours
rm /tmp/prod /tmp/yours

The part which wasn’t clear enough was on the topic how the read models extraction can help in designing aggregates. Here’s my written attempt to explain this strategy:

Introduce a Service objects layer (aka application layer)

class RegisterUser
  def call
    User.create
    Mailer.send
  end
@IanVaughan
IanVaughan / schema.rb.diff
Created March 18, 2020 14:12
Flipper schema commit
diff --git a/db/schema.rb b/db/schema.rb
index 79ce7b88..d9914a59 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2020_03_16_124239) do
+ActiveRecord::Schema.define(version: 2020_03_17_181241) do
require 'rails_helper'
RSpec.feature 'User signup flow', :js do
scenario 'Visits home page to signup' do
puts "*** Capybara start ***"
visit root_path
new_window = window_opened_by { click_link 'Sign Up', match: :first }
within_window new_window do
expect(page).to have_text('New Enquiry', wait: 5)
# on heroku ci dyno via: heroku ci:debug --pipeline release-pipeline
~ $ bundle exec rspec spec/features/
CI:true
/app/vendor/bundle/ruby/2.7.0/gems/graphql-1.9.17/lib/graphql/schema/mutation.rb:71: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/app/vendor/bundle/ruby/2.7.0/gems/graphql-1.9.17/lib/graphql/schema/member/has_fields.rb:11: warning: The called method `field' is defined here
/app/vendor/bundle/ruby/2.7.0/gems/graphql-1.9.17/lib/graphql/language/nodes.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/app/vendor/bundle/ruby/2.7.0/gems/graphql-1.9.17/lib/graphql/language/nodes.rb:259: warning: The called method `initialize_node' is defined here
/app/vendor/bundle/ruby/2.7.0/gems/graphql-1.9.17/lib/graphql/language/nodes.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call