Skip to content

Instantly share code, notes, and snippets.

View remi's full-sized avatar
👋

Rémi Prévost remi

👋
View GitHub Profile
@remi
remi / intensify.sh
Created August 31, 2023 15:02
intensify.sh
#!/bin/bash
#
# Call this script, passing an image filename
# Creates an intensified version
convert='convert'
realpath='realpath'
# flight check: must have imagemagick
if [ ! $(which $convert) ]; then
@remi
remi / .gitconfig
Created July 27, 2011 18:14
Alias pour utiliser git en français!
[alias]
etat = status
pousser = push
tirer = pull
commettre = commit
ranger = stash
ajouter = add
enlever = rm
cloner = clone
fusionner = merge
@remi
remi / commit-msg
Created August 30, 2011 20:56
Git commit message spell check hook (kind of a proof of concept, but still usable)
#!/usr/bin/env ruby
# 1. Install hunspell
# $ brew install hunspell
# 2. Download a dictionary and install it in a path listed by `hunspell -D`
# $ open http://wiki.services.openoffice.org/wiki/Dictionaries
# 3. Move this file into your repository
# $ mv commit-msg /path/to/repo/.git/hooks
@remi
remi / apple-news.sh
Last active April 14, 2022 05:39
Extract canonical URL from Apple News URL
#!/bin/bash
# Usage:
#
# 1. Create a `apple-news` file somewhere in your $PATH with the content of this file
# 2. That’s it! You can now use the `apple-news` utility:
#
# ```
# $ apple-news https://apple.news/AKoDCWtVEQP2w7Ld657lgIg
# https://www.theguardian.com/technology/2022/mar/30/dyson-launches-zone-air-purifying-bluetooth-headphones-with-visor
@remi
remi / shc.js
Last active March 2, 2022 14:32
Extract JSON object from https://smarthealth.cards QR code
// Extract JSON payload from SHC QR code (without any kind of private/public key verification)
// Credits + inspiration
// https://github.com/dvci/health-cards-walkthrough/blob/main/SMART%20Health%20Cards.ipynb
// Usage
// $ node shc.js "shc:/01234569…"
const zlib = require("zlib");
defmodule Example1 do
@default_now DateTime.utc_now()
def foo(now \\ @default_now) do
IO.puts(now)
end
end
defmodule Example2 do
def foo(now \\ DateTime.utc_now()) do
@remi
remi / .gitconfig
Created March 20, 2012 19:20
Find the most used verbs in your Git commit messages
[alias]
verbs = !git log --pretty=format:'%s' | cut -d \" \" -f 1 | sort | uniq -c | sort -nr

Keybase proof

I hereby claim:

  • I am remi on github.
  • I am remi (https://keybase.io/remi) on keybase.
  • I have a public key whose fingerprint is 0EB8 6575 1221 3709 D835 08F6 2601 D146 D7E8 4CB5

To claim this, I am signing this object:

@remi
remi / cache.rake
Created September 25, 2012 17:38
Clear Rails cache store and do it fast (without loading the whole Rails environment)
# bundle exec rake cache:clear
namespace :cache do
desc "Clear Rails.cache"
task :clear do
Object.const_set "RAILS_CACHE", ActiveSupport::Cache.lookup_store(Rails.configuration.cache_store)
Rails.cache.clear
puts "Successfully cleared Rails.cache!"
end
end
@remi
remi / README.md
Last active July 1, 2018 21:11
ActiveRecord and multiple `belongs_to` associations

ActiveRecord and multiple belongs_to associations

When an ActiveRecord model has more than one belongs_to association, calling delete_all on an ActiveRecord::Associations::CollectionProxy will not delete the records but unassociate them. That might be a problem in a table with a NOT NULL clause.

Client.create
# => #<Client id: 1, created_at: "2013-08-14 17:43:42", updated_at: "2013-08-14 17:43:42">
 
Team.create
# => #<Team id: 1, created_at: "2013-08-14 17:43:55", updated_at: "2013-08-14 17:43:55">