Skip to content

Instantly share code, notes, and snippets.

View goulvench's full-sized avatar

Goulven Champenois goulvench

View GitHub Profile
@goulvench
goulvench / blob_sgid_after_rails_upgrade.rb
Created February 12, 2024 17:45
When migrating a Rails 6.1 app to Rails 7, all calculated SGID change, which causes ActionText attachments to error out. SGIDs are generated using `Rails.application.key_generator.generate_key('signed_global_ids')`, which uses different settings.
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
#gem "rails", "6.1"
@goulvench
goulvench / render_flash_now_for_xhr.rb
Created May 18, 2023 12:46
Force Rails to render flash messages for XHR responses
# To display flash messages inside XHR responses,
# place this file in app/controllers/concerns/
# then include it in ApplicationController
module RenderFlashNowForXhr
extend ActiveSupport::Concern
private
# Flash messages are not directly available for XHR requests
@goulvench
goulvench / bridgetown.automation.rb
Last active September 10, 2023 05:50
Font Awesome automation for BridgetownRB
say_status :font_awesome, "Installing Font Awesome..."
run "yarn add @fortawesome/fontawesome-free esbuild-plugin-copy"
gsub_file "esbuild.config.js", "const esbuildOptions = {}", <<~JS.strip
const path = require("path")
const esbuildCopy = require('esbuild-plugin-copy').default
/**
* @typedef { import("esbuild").BuildOptions } BuildOptions
* @type {BuildOptions}
@goulvench
goulvench / _form.html.erb
Last active April 30, 2023 19:59 — forked from yunusemredilber/_form.html.erb
Auto Growing text-area [Stimulus] [Rails]
<%= text_area_tag :name, content, data: { controller: 'autogrow', action: 'autogrow#resize' } %>
# frozen_string_literal: true
namespace :git do
desc 'Check that local changes have been pushed to the origin repository'
task :check_if_up_to_date do
# skip if no git dir detected
git_dir = `git rev-parse --git-dir`.strip
next if git_dir.empty?
time = fetch(:uptodate_time, 300)
@goulvench
goulvench / dabblet.css
Created December 7, 2012 13:12
Linear-gradient for transparent corners
/**
* Linear-gradient for transparent corners
* Based on http://lea.verou.me/2011/03/beveled-corners-negative-border-radius-with-css3-gradients/
*/
div {
width: 100px;
padding: 2em 0;
margin: 2em auto;
background: black;
@goulvench
goulvench / responsive.html
Created February 5, 2012 15:27 — forked from lensco/responsive.html
Simple responsive design test page. Adapted to reflect major screen layouts.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Responsive Design Testing</title>
<style>
body { margin: 20px; font-family: sans-serif; overflow-x: scroll; width: 4100px; }
.frame { float: left; margin: 0 20px 20px 0; }
small { display: block; color: #888; }
h2 { margin: 0 0 5px 0; }
@goulvench
goulvench / testcase.html
Created November 25, 2010 16:23
[Testcase] Replacing loaded pages with AJAX content: duplicate ID problem
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>[Testcase] Replacing loaded pages with AJAX content: duplicate ID problem</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
</head>
<body>