Skip to content

Instantly share code, notes, and snippets.

pcreux / dbt_to_dbdiagram.rb
Created May 3, 2021
Generate an ERD via from a dbt project.
View dbt_to_dbdiagram.rb
#!/usr/bin/env ruby
# Generate a dbdiagram for from a dbt project.
# Usage:
# 1. Run `dbt docs generate` first.
# 2. Run `dbt_to_dbdiagram.rb`
# 3. Paste the output in
require 'yaml'
require 'json'
pcreux /
Last active Aug 21, 2022
Gourmet Service Objects - Lightning Talk - - Feb 27, 2014

Gourmet Service objects


 Feb 27, 2014
pcreux / convert-to-ipad.rb
Last active Jul 26, 2022
ffmpeg - avi to mp4 - iPad
View convert-to-ipad.rb
# ruby convert-to-ipad.rb video1.avi video2.avi video3.avi
# Prereq: brew install ffmpeg
ARGV.each do |input_file|
output_file = input_file.gsub('.avi', '.ipad.mp4')
cmd = "ffmpeg -i #{input_file} -acodec aac -ac 2 -strict experimental -ab 160k -s 1024x768 -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 #{output_file}"
puts cmd
system cmd
pcreux /
Created Sep 7, 2010
Bash script to install chef client on blank ubuntu 10.04 - lucid
# From
# Run: wget && bash
echo "Add the Opscode APT Repository"
echo 'deb lucid main' | sudo tee /etc/apt/sources.list.d/opscode.list
sudo apt-get update
echo "Install curl"
sudo apt-get install curl
pcreux / dbt-log-to-csv.rb
Last active Jul 11, 2022
Parse dbt logs and turn them into a CSV
View dbt-log-to-csv.rb
#!/usr/bin/env ruby
# Usage: ruby dbt-log-to-csv.rb PATH_TO_DBT_LOGS
Model =, :table, :rows_str, :size_str, :duration_str) do
def rows
rows = rows_str.to_f
rows = case rows_str
when /\d$/
pcreux / 000_postgresql_fancy_datatypes
Last active Mar 18, 2022
Postgresql fancy datatypes with Rails / ActiveRecord. Run it with `rake`!
View 000_postgresql_fancy_datatypes
# Postgresql fancy datatypes!
* array
* hstore (=~ hash)
* json
* jsonb
Philippe Creux - [@pcreux](
pcreux / Jabber-SH
Created Dec 17, 2009
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! :)
View Jabber-SH
#!/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 / Gemfile
Last active Feb 3, 2022
Fast Rails + Heroku Configuration
View Gemfile
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'
pcreux / postgres.yaml
Created Jan 26, 2022
datadog + heroku postgres integration for more than 1 database
View postgres.yaml
# `datadog/` will inject instances below on boot
pcreux / dry-struct-active-model-benchmark.rb
Last active Nov 15, 2021
Benchmark ActiveModel vs Dry::Struct (with strict types)
View dry-struct-active-model-benchmark.rb
require 'active_model'
require 'dry-struct'
require 'benchmark/ips'
require 'benchmark/memory'
class AMUser
include ActiveModel::Model
include ActiveModel::Attributes
attribute :id, :integer