Skip to content

Instantly share code, notes, and snippets.

Philippe Creux pcreux

Block or report user

Report or block pcreux

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pcreux
pcreux / circleci-trace
Created Nov 21, 2019
Generate a trace of your circleci workflows
View circleci-trace
#!/usr/local/env ruby
#
# Generate html traces from CircleCI workflows
#
require 'json'
require 'http'
OWNER = 'githubowner'
REPO = 'githubrepo'
@pcreux
pcreux / format_bundle_outdated.rb
Created May 31, 2019
Format 'bundle outdated' into a CSV file ordered by version delta
View format_bundle_outdated.rb
#!/usr/bin/env ruby
#
# Run `bundle outdated | format_bundle_outdated`
# to get a CSV file listing the columns below for all outdated gems.
COLUMNS = [ "name", "newest", "installed", "requested", "groups", "delta" ].join(",")
class Version < Struct.new(:major, :minor, :patch, :beta)
def self.build(string)
new(*string.split('.').map(&:to_i))
@pcreux
pcreux / 000 Oh no conditionals!.png
Last active Jun 6, 2018
Turning imperative conditionals into declarative rules
@pcreux
pcreux / Gemfile
Created Apr 19, 2018
Minimal setup to run a static site on Heroku.
View Gemfile
# no ruby gems required
@pcreux
pcreux / extract-migration
Created Oct 6, 2017
Extract all new migrations from the current branch over to a new branch (suffixed with "-migration")
View extract-migration
#!/bin/sh
# Extract all new migrations from the current branch over to a new branch (suffixed with "-migration")
set -ev
export branch=`git rev-parse --abbrev-ref HEAD`
git checkout master
git pull
git checkout -b $branch-migration
git checkout $branch -- db engines/*/db
@pcreux
pcreux / rtt
Last active Nov 3, 2017
Run tests for all changed app, lib and test files
View rtt
#!/usr/bin/env ruby
# Run unit test for all added or changed app, lib and test files.
# Ex:
# * `rtt` will run tests for all files changed since the last commit
# * `rtt master` will run tests for all files different from master
if ARGV[0]
files = `git diff --name-only $(git merge-base HEAD #{ARGV[0]})..$(git rev-parse --abbrev-ref HEAD)`.split("\n")
else
files = `git status -s`.split("\n").map { |f| f.split(' ').last }
@pcreux
pcreux / mktest
Created Jun 14, 2017
Generate a test file. `mktest app/models/user.rb` => `test/models/user_test.rb`
View mktest
#!/usr/bin/env ruby
DESC = "
Generate test file
Example: mktest app/services/user/create.rb will generate test/services/user/create_test.rb
"
@pcreux
pcreux / 000_robust_rails_apps.md
Last active May 14, 2018
Robust Rails Apps - VanRuby - March 29, 2017
View 000_robust_rails_apps.md

Robust Rails Apps

Philippe Creux - @pcreux

#vanruby - March 29th, 2017

@pcreux
pcreux / 99bottles.rb
Last active Dec 7, 2016
99bottles in 15 minutes. Feeling a bit dizzy now... 🍻 `git clone --depth=1 --branch=exercise https://github.com/sandimetz/99bottles.git`
View 99bottles.rb
class Bottles
def verse(current)
<<-VERSE
#{bottles(current).capitalize} of beer on the wall, #{bottles(current)} of beer.
#{take_one_down(current)}, #{bottles((current - 1) % 100)} of beer on the wall.
VERSE
end
def verses(start, finish)
(finish..start).to_a.reverse.map { |number| verse(number) }.join("\n")
View rotate-aws-access-keys.rb
#!/usr/bin/env ruby
require 'json'
# 1. Generate new access key
new_access_key_json = `aws iam create-access-key`
new_access_key_attributes = JSON.parse(new_access_key_json).fetch("AccessKey")
new_access_key_id = new_access_key_attributes.fetch("AccessKeyId")
You can’t perform that action at this time.