Skip to content

Instantly share code, notes, and snippets.

View thbar's full-sized avatar

Thibaut Barrère thbar

View GitHub Profile
@thbar
thbar / sql_test.exs
Created May 10, 2016 12:18
Querying generate_series on dates in Postgres via Ecto
defmodule Ecto.Integration.SQLTest do
use Ecto.Integration.Case, async: true
alias Ecto.Integration.TestRepo
alias Ecto.Integration.Barebone
alias Ecto.Integration.Post
import Ecto.Query, only: [from: 2]
# SNIP
@thbar
thbar / how-to-diff-pdf-files-with-git-and-diffpdf.md
Last active November 3, 2023 06:01
How to diff PDF files with Git

One can use MD5 or plain text diff to see differences in PDF files. If that's not enough, here's how to use diff-pdf which knows how to diff based on appearance or words:

  • brew install diff-pdf
  • edit your ~/.gitconfig to add this:
[difftool "diffpdf"]
  cmd = diff-pdf --view \"$LOCAL\" \"$REMOTE\"
@thbar
thbar / rails_lamby_notes.md
Created April 30, 2020 20:52 — forked from joshuap/rails_lamby_notes.md
Deploy a new Rails app to AWS Lambda using Lamby
@thbar
thbar / database.yml.erb
Created March 16, 2012 11:25
ERB template for git-branch aware database.yml (development/test only)
<%
# if you need to work on a branch with a different schema, use
# git config --bool branch.the-new-branch.database true
# http://mislav.uniqpath.com/rails/branching-the-database-along-with-your-code/
branch = `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '')
suffix = `git config --bool branch.#{branch}.database`.chomp == 'true' ? "_#{branch}" : ""
%>
common: &common
@thbar
thbar / deploy.rb
Created September 7, 2010 18:18
Resque + god + capistrano recipe
# note - you may need to split into a before-deploy (stop) and after-deploy (start) depending on your setup
desc "Hot-reload God configuration for the Resque worker"
deploy.task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join deploy_to, 'current', 'config', 'resque.god'}"
sudo "god start resque"
end
after 'deploy:update_code', 'deploy:update_shared_symlinks'
@thbar
thbar / vagrant-vmware-tech-preview-apple-m1-pro.md
Created February 23, 2022 13:37 — forked from sbailliez/vagrant-vmware-tech-preview-apple-m1-pro.md
Vagrant and VMWare Tech Preview on Apple M1 Pro

Vagrant and VMWare Tech Preview on Apple M1 Pro

This document summarizes notes taken while to make the VMWare Tech preview work on Apple M1 Pro, it originated from discussions in hashicorp/vagrant-vmware-desktop#22

Installing Rosetta

First install Rosetta if not already done, this is needed to run x86 code:

@thbar
thbar / _gradients.css.scss
Created October 27, 2011 11:28 — forked from mihar/_gradients.sass
SCSS mixing for CSS3 gradients
@mixin gradient($from, $to) {
/* fallback/image non-cover color */
background-color: $from;
/* Firefox 3.6+ */
background-image: -moz-linear-gradient($from, $to);
/* Safari 4+, Chrome 1+ */
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to));
@thbar
thbar / data.rake
Last active December 5, 2021 22:39
Using ActiveRecord logger and transaction rollback to review data processing task before going live
namespace :data do
task :console_logger do
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
task :do_some_tweaking, [:user_email, :confirmation] => [:environment, :console_logger] do |t, args|
User.transaction do
# ...
raise "Rolling back after dry run - add CONFIRM to confirm!" unless args[:confirmation] == 'CONFIRM'
@thbar
thbar / _readme.md
Created February 15, 2012 11:23
How I got git working with chef on windows
@thbar
thbar / help.md
Created July 12, 2019 13:28
Installing MySQL2 on Mac OS X Mojave (2019 edition)

mysql2 install failing on Mac OS X (Mojave)

If you want to install the gem (client) without having a database, doing brew install mysql-connector-c used to work, but not anymore.

You now have to install a compatible connector (mariadb):

brew install mariadb-connector-c
bundle config build.mysql2 "--with-mysql-config=$(brew info mariadb-connector-c | grep /usr/local | cut -d ' ' -f 1)/bin/mariadb_config"
bundle install