Skip to content

Instantly share code, notes, and snippets.

View jumichot's full-sized avatar
🏠
Working from home

julien michot jumichot

🏠
Working from home
View GitHub Profile
@benoittgt
benoittgt / file.vim
Last active April 6, 2024 10:28
iamaputsemojidebugger
function! IAmAPutsEmojiDebugger()
ruby <<EOS
separator = rand(0x1F601..0x1F64F).chr('UTF-8')
VIM::command("normal! oputs '#{separator}' * (`tput cols`.to_i / 2)")
VIM::command('normal! oputs "#{__FILE__}:#{__LINE__}"')
VIM::command("normal! oputs '#{separator}' * (`tput cols`.to_i / 2)")
EOS
@jvillarejo
jvillarejo / retry_until_timeout_spec.rb
Created January 7, 2022 22:38
A timeout for failing specs when using turbo frames and hotwire
# This is how we use it
retry_until_timeout do
expect(page).to have_button('Add comment')
expect(page).to have_text('Cancell')
end
def retry_until_timeout(seconds = 10, message: 'Failed with timeout')
Timeout.timeout(seconds) do
loop do
yield
# mailboxes/concerns/mail_params.rb
module MailParams
extend ActiveSupport::Concern
def mail_params
attachments = build_attachments
body = build_rich_body(attachments)
{ subject: mail.subject, body: body, attachments: attachments.map { |a| a[:blob] } }
end
@adrienpoly
adrienpoly / application.html.erb
Last active November 3, 2024 13:14
Capybara / Stimulus test helper to ensure JS is ready when test starts
<!DOCTYPE html>
<html>
<head>
...
</head>
<body data-controller="js">
<%= yield %>
</body>
</html>
@lazaronixon
lazaronixon / dropzone_controller.js
Last active September 25, 2024 14:28
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
@pcreux
pcreux / format_bundle_outdated.rb
Created May 31, 2019 18:30
Format 'bundle outdated' into a CSV file ordered by version delta
#!/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))
@thbar
thbar / reloading.exs
Created October 29, 2016 11:32
Live code reloading with Elixir
# mix run --no-halt reloading.exs
# in music.exs, put:
#
# defmodule Music do
# def version do
# "3"
# end
# end
#
@wesbos
wesbos / gist:d7877929def4368cdb8abc12c5d3e38b
Last active September 9, 2020 15:21
"Out Of Office" Filter
Trying to filter "out of office" emails from my inbox as I receive a lot of them when I send a blast.
I need help - what do your "out of office" emails say in your langauge? Comment Below!
## Gmail Filter
("Automatische Antwort" OR "Automatic reply" OR "AutoReply" OR "Out of Office" OR "Xesc Duran" OR "Abwesend" OR "Absence" OR "Absence du bureau" OR "À l'extérieur du bureau" OR "Réponse automatique" OR "Abwesenheitsnotiz" OR "Resposta automática" OR "Automaattinen vastaus" OR "Automatisch antwoord" OR "Afwezig" OR "Afwezigheid" OR "Niet aanwezig" OR "Poza zasięgiem" OR "Na wakacjach" OR "Poza biurem" OR "Automatyczna odpowiedź" OR "Z dala od komputera" OR "Αυτόματη απάντηση" OR "Εκτός γραφείου" OR "na dovolenké" OR "mimo kancelárie" OR "automatická odpověď" OR "Autosvar" OR "Fora do escritório" OR "na dovolené" OR "mimo kancelář")
## List
Automatische Antwort
Automatic reply
@josevalim
josevalim / watcher.sh
Last active May 22, 2024 10:06
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | mix test --stale --listen-on-stdin