Skip to content

Instantly share code, notes, and snippets.

View alexford's full-sized avatar
:shipit:
Shipping it

Alex Ford alexford

:shipit:
Shipping it
View GitHub Profile
@alexford
alexford / main.yml
Last active August 31, 2023 02:31
Running Rails tests with RSpec on GitHub actions with Postgres
name: CI
on: [push]
jobs:
rspec:
runs-on: ubuntu-latest
container:
image: ruby:2.6.5

Keybase proof

I hereby claim:

  • I am alexford on github.
  • I am alexford (https://keybase.io/alexford) on keybase.
  • I have a public key ASDmBLpFcciDokPbMfbJHmY0sFtXu8MayH7fFOqI6LzpZQo

To claim this, I am signing this object:

@alexford
alexford / faketime_rspec.md
Created April 1, 2019 19:23
Freeze system time for Ruby/RSpec

Assumptions

  • macOS 10.14
  • rbenv
  • Homebrew

Steps

Install libfaketime

@alexford
alexford / example_spec.rb
Created November 10, 2018 14:27
Mocking a specific instance of an ActiveRecord model that hasn't yet been queried
require 'rails_helper'
RSpec.describe 'Mocking specific instance' do
let!(:student_to_stub) { create_list(:student, 3).first }
let(:stubbed_name) { junk }
before do
stub_model(Student, :first_name, { id: student_to_stub.id }, stubbed_name)
end
@alexford
alexford / clear_twilio_recordings.rb
Created November 2, 2014 21:05
A quick and dirty Ruby script to remove ALL call recordings from a Twilio account
require 'twilio-ruby' #twilio-ruby gem
account_sid = 'your account SID'
account_token = 'your account auth token'
@client = Twilio::REST::Client.new account_sid, account_token
recordings = @client.recordings.list
puts "Total recordings: #{recordings.total}"
recordings_remaining = recordings.total
@alexford
alexford / index.php
Created December 11, 2012 20:54
Quick way to include Git branch/commit info on PHP page
<strong>Branch: </strong><?=shell_exec('git rev-parse --abbrev-ref HEAD')?><br/>
<strong>Commit: </strong><?=shell_exec("git log -1 --pretty=format:'%h - %s (%cn, %cr)' --abbrev-commit")?>