Skip to content

Instantly share code, notes, and snippets.

@pcreux
pcreux / multi_command.rb
Created December 13, 2024 08:40
Ruby script to run commands in parallel, print the output with different colors, and provide a summary.
#!/usr/bin/env ruby
# Run commands in parallel, print the output with different colors,
# and provide a summary.
COMMANDS = [
"curl -v www.google.com",
"curl -v www.yahoo.com",
"dig www.google.com",
"hoo",
@pcreux
pcreux / clone-heroku-app
Last active July 26, 2024 17:19
Script to clone a heroku app (including buildpacks, users, add-ons, environment variables, lab features)
#!/usr/bin/env ruby
# Copy a heroku app (buildpacks, add-ons, labs, config, users).
# This script is idempotent so it can run against an existing app.
#
# Usage:
# $> clone-heroku-app source-app target-app
require 'json'
@pcreux
pcreux / dbt_to_dbdiagram.rb
Created May 3, 2021 16:15
Generate an ERD via dbdiagram.io from a dbt project.
#!/usr/bin/env ruby
# Generate a dbdiagram for dbdiagram.io from a dbt project.
#
# Usage:
# 1. Run `dbt docs generate` first.
# 2. Run `dbt_to_dbdiagram.rb`
# 3. Paste the output in https://dbdiagram.io/
require 'yaml'
require 'json'
@pcreux
pcreux / Jabber-SH
Created December 17, 2009 06:17
Jabber-SH — SH console via XMPP/Jabber (GTalk) Jabber-SH allows to you to administrate a remote computer via a command line through a Jabber client. It’s like SSH via GoogleTalk! :)
#!/usr/bin/env ruby
# Jabber-SH — SH console via XMPP/Jabber (GTalk)
#
# Jabber-SH allows you to administrate a remote computer via a command line
# through a Jabber client. It’s like SSH via GoogleTalk! :)
# This is just a hack but it might be usefull sometime to run basic commands
# on a machine that is not accessible via ssh.
#
# Philippe Creux. pcreux/AT/gmail/DOT/com
@pcreux
pcreux / Gemfile
Last active December 11, 2023 20:24
Fast Rails + Heroku Configuration
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end
@pcreux
pcreux / dbt-ctags.rb
Created December 4, 2023 16:51
Generate ctags for dbt models and macros
#!/usr/bin/env ruby
# Generate ctags for dbt models and macros.
sql_files = Dir['macros/**/*.sql'] + Dir['models/**/*.sql']
mappings = sql_files
.map { |path| [File.basename(path, '.sql'), path] }
.sort
File.open('tags', 'w') do |f|
@pcreux
pcreux / README.md
Last active July 3, 2023 09:46
A client for Basecamp 4
@pcreux
pcreux / dry-struct-active-model-benchmark.rb
Last active June 19, 2023 22:37
Benchmark ActiveModel vs Dry::Struct (with strict types)
require 'active_model'
require 'dry-struct'
require 'benchmark/ips'
require 'benchmark/memory'
class AMUser
include ActiveModel::Model
include ActiveModel::Attributes
attribute :id, :integer
@pcreux
pcreux / gist:1681580
Created January 26, 2012 07:48
Reword *first* commit
# You can't use rebase -i here since it takes the parent commit as argument.
# You can do the following though:
git checkout FIRST_COMMIT_SHA && git commit --amend && git rebase HEAD master
@pcreux
pcreux / 0-gourmet-service-objects.md
Last active August 21, 2022 15:32
Gourmet Service Objects - Lightning Talk - http://vanruby.org - Feb 27, 2014

Gourmet Service objects

 @pcreux

 Feb 27, 2014
 http://vanruby.org