Skip to content

Instantly share code, notes, and snippets.

View DRBragg's full-sized avatar

Drew Bragg DRBragg

View GitHub Profile
@DRBragg
DRBragg / .solargraph.yml
Last active April 13, 2024 01:43
My config with steps to use solargraph for Rails projects in VS Code (WIP)
---
include:
- "app/**/*.rb"
- "config/**/*.rb"
- "lib/**/*.rb"
exclude:
- spec/**/*
- vendor/**/*
- ".bundle/**/*"
require:
@DRBragg
DRBragg / render_erb.rb
Created November 15, 2021 16:39
Liquid tag to render `app/view/` erb partials in `cdk/product_templates/*/*/templates/` liquid templates
module CDK
class RenderERB < Liquid::Tag
SYNTAX = /(?<path>#{Liquid::QuotedFragment})(?<locals>\s+.*)?/
private_constant :SYNTAX
def initialize(tag_name, markup, tokens)
super
@data = SYNTAX.match(markup).named_captures
end
@DRBragg
DRBragg / add_style_guide_links.rb
Created April 22, 2021 16:01
Add style guide links to rubocop config
@DRBragg
DRBragg / gist:fb2cd7d6fe8e4c0333dcbc33a7c27406
Created January 12, 2021 17:03
gem install ffi -v '1.9.17' Error Fix
gem install ffi -v '1.9.17' -- --with-cflags="-Wno-error=implicit-function-declaration"
@DRBragg
DRBragg / sendgrid.md
Created December 17, 2020 15:47
Getting an API key from Sendgrind
  • Login to sendgrid

  • From the menu on the lefthand side click on Email API > Integration Guide

  • For VAP projects:

    • Select SMTP Relay
    • Name the key (usually the short name of the VAP instance)
    • Click 'Create Key'
    • From the 'Configure your application section' copy the Password (this is actually your API key)
    • In Hatchbox (or SSH into the server for legacy versions) put the API key in your ENVs
  • The key is SENDGRID_PASSWORD and the value is the API key you just generated.

@DRBragg
DRBragg / sentry.md
Created December 16, 2020 21:48
Add Sentry tracking to an app
  • From the projects route click on 'Create Project'
  • Select the proper platform from the provided list
    • Vue for VAP frontends
    • Rails for VAP APIs
  • Under 'Set your default alert settings' select 'Alert me on every new issue'
  • Name the project something unquie like the instance short name + frontend or api. eg: PSC would be PSC-frontend & PSC-api.
  • Click 'Create Project'

You can ignore most of the next screen as each app already has sentry configured. What you need to grab is the DSN from the configuration instructions and feed it to your instance via the proper ENV.

@DRBragg
DRBragg / ip_update.sh
Created August 20, 2020 21:14
Little shell script run via cron job to update my google domain to point to my local server.
#!/bin/bash
IP_ADDR_FILE="ip_addr.txt"
old_ip=$(cat $IP_ADDR_FILE)
current_ip=$(curl ifconfig.me/ip)
if [ "$old_ip" != "$current_ip" ]; then
curl "https://username:password@domains.google.com/nic/update?hostname=test.drbragg.ninja&myip=$current_ip"
rm $IP_ADDR_FILE
touch $IP_ADDR_FILE
@DRBragg
DRBragg / stimulus.md
Created July 30, 2020 16:28 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
@DRBragg
DRBragg / id_seq_reset.rb
Last active June 18, 2020 16:17
To reset ActiveRecords id sequence after restoring DB from a dump
# TABLE_NAME = the name of the table you need to reset the id sequence for
ActiveRecord::Base.connection.execute(%q{
select setval('TABLE_NAME_id_seq', m)
from (
select max(id) from TABLE_NAME
) as dt(m)
})
# OR