Skip to content

Instantly share code, notes, and snippets.

View Yenwod's full-sized avatar

Chris D Yenwod

View GitHub Profile
@Yenwod
Yenwod / .gitlab-ci.yml
Created September 17, 2021 16:13 — forked from julianrubisch/.gitlab-ci.yml
Gitlab CI Config for Minitest/system tests
image: "ruby:2.7"
services:
- postgres
- redis:latest
variables:
RAILS_ENV: test
POSTGRES_DB: my_app_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "password"
@Yenwod
Yenwod / USWDS-Heroku-Rails-6-webpacker
Created May 23, 2020 18:30
Rapidly spin up a default landing page with USWDS template, Rails 6 webpacker, deploy to Heroku
rails new your-app-name --skip-active-record --webpack=stimulus --skip-action-mailbox --skip-active-storage --skip-action-cable
@Yenwod
Yenwod / heroku.rake
Last active December 25, 2019 23:00
require 'platform-api'
namespace :heroku do
desc "set test webhook for Stripe based upon review-app url"
task update_stripe_test_webhook: :environment do
new_webhook_url = ""
heroku = PlatformAPI.connect_oauth('the-token-you-generated-via-README-instructions')
heroku.app.list.each do |app|
if app["name"].include?('vaxcalc-app-pattern-')
new_webhook_url = app["web_url"]
@Yenwod
Yenwod / review_app
Last active December 25, 2019 22:51
bundle exec rails heroku:update_stripe_test_webhook
{
"name": "VaxCalc",
"description": "Informed consent technology",
"website": "https://vaxcalc.org/",
"scripts": {
"postdeploy": "bin/review_app"
}
}
Stripe.api_key = ENV['STRIPE_API_KEY'] || Rails.application.credentials.stripe_secret_key
StripeEvent.signing_secret = ENV['STRIPE_SIGNING_SECRET'] || Rails.application.credentials.stripe_signing_secret

Simplecov aggregated coverage report from CircleCI 2.0 parallel builds (focused on storing locally/within CI containers as artifacts)

Problem Statement

We have Rails application which is running tests on circleCI 2.0, we have simplecov configured to track the coverage of our test suite. Now the problem is with parallelism enabled, we have partial coverage reports in all different containers according to the tests those containers ran.

We obviously want to have consolidated simplecov coverage report which actually shows us overall coverage report.

-- how many new users signed in past 24 hours?
--select id, email, name, sign_in_count, last_sign_in_at, created_at
select count(*)
from users
where NOW() > last_sign_in_at
AND NOW() - last_sign_in_at <= interval '24 hours'
and sign_in_count = 1;
-- how many return users?
--select id, email, name, sign_in_count, last_sign_in_at, created_at
<% ab_test(:donate_color, "btn btn-primary btn-lg text-right",
"btn btn-info btn-lg text-right",
"btn btn-warning btn-lg text-right",
"btn btn-danger btn-lg text-right") do |color| %>
<%= link_to 'Donate', donate_path, class: 'btn btn-danger btn-lg text-right' %>
<% end %>
@Yenwod
Yenwod / postgres-translate-utc.sql
Created May 24, 2014 13:10
PostgreSQL translate UTC to another time zone in query
-- source: http://icu.iorahealth.com/blog/2012/05/07/expressing-postgresql-timestamps-without-zones-in-local-timee
select id, route, url_id, created_at at time zone 'UTC' at time zone 'US/Eastern' from visitors order by id desc;