Skip to content

Instantly share code, notes, and snippets.

@Dnar
Dnar / check-env-vars.rb
Created September 24, 2025 12:40
Sanity check in CI that enforces parity between your plain .env.* files and the encrypted config/vars-staging.enc.env (SOPS)
require "set"
DEV_ENV = ".env.development"
ENC_ENV = "config/vars-staging.enc.env"
def vars_from_file(file)
File.readlines(file)
.map(&:strip)
.reject { |line| line.empty? || line.start_with?("#") }
.map { |line| line.split("=", 2).first }
@Dnar
Dnar / check-env-vars.sh
Last active September 24, 2025 12:40
Sanity check in CI that enforces parity between your plain .env.* files and the encrypted config/vars-staging.enc.env (SOPS)
# sanity check in CI that enforces parity between your plain .env.* files and the encrypted config/vars-staging.enc.env (SOPS).
# If a new variable is introduced locally but missing in the encrypted file, the check should fail on PR.
#!/usr/bin/env bash
set -euo pipefail
# Files to compare
DEV_ENV=".env.development"
ENC_ENV="config/vars-staging.enc.env"
@Dnar
Dnar / google_spreadsheet_updater.rb
Last active January 24, 2025 16:12
google_spreadsheet_updater.rb
def credentials_json
{
type: "service_account",
project_id: "deployment-info",
private_key_id: ENV.fetch("GOOGLE_PRIVATE_KEY_ID", nil),
private_key: ENV.fetch("GOOGLE_PRIVATE_KEY", nil),
client_email: "sheets-api-service-worker@deployment-info.iam.gserviceaccount.com",
client_id: ENV.fetch("GOOGLE_CLIENT_ID", nil),
auth_uri: "https://accounts.google.com/o/oauth2/auth",
token_uri: "https://oauth2.googleapis.com/token",
[
{
"Date": "2022-01-01 00:00:00",
"#Available Spaces Left": 10,
"Quarter Number": 1,
"#Month Number": 1,
"Month Name": "January",
"Month of Quarter": 1,
"#Week of Month": 1,
"Day of Month Number": 1,
name: Test Pull Request
on:
pull_request:
jobs:
test:
services:
db:
image: postgres:13.8-alpine
ports:
@Dnar
Dnar / test.rb
Created February 17, 2023 11:24
require 'rails_helper'
RSpec.describe Mutations::CancelContract, type: :request do
describe '#resolve' do
let(:customer) { create(:customer) }
let(:mutation) { described_class.new(object: nil, context: { current_customer: customer }) }
let(:args) do
{
some_argument: "some_value"
}
require 'rails_helper'
RSpec.describe Mutations::CancelContract, type: :request do
describe '#resolve' do
let(:customer) { create(:customer) }
let(:mutation) { described_class.new(object: nil, context: { current_customer: customer }) }
let(:args) do
{
some_argument: "some_value"
}
def create_missed_customers_production
require "csv"
inexistent_lead = []
correct_lead_data = []
incorrect_lead_data = []
headers = ["email", "uuid", "result"]
csv_file_path = Rails.root.join("tmp", "customer_uuids.csv")
csv_file = File.open(csv_file_path)
uuids = CSV.read(csv_file, col_sep: ";", liberal_parsing: true)