Skip to content

Instantly share code, notes, and snippets.

View agrberg's full-sized avatar

Aaron Rosenberg agrberg

View GitHub Profile
@agrberg
agrberg / environment.js
Created April 11, 2020 16:40
Getting webp images and autogeneration working in Rails 6
const IMAGE_REGEXP = /\.(?:jpe?g|png)$/; // https://regexper.com/#%2F%5C.%28%3F%3Ajpe%3Fg%7Cpng%29%24%2F
const ImageminWebpWebpackPlugin = require('imagemin-webp-webpack-plugin');
const { environment } = require('@rails/webpacker');
environment.plugins.prepend('ImageminWebpWebpackPlugin', new ImageminWebpWebpackPlugin({
silent: false,
detailedLogs: true,
}));
const manifest = environment.plugins.get('Manifest')
@agrberg
agrberg / ruby_version.sh
Created October 19, 2020 15:17
Ruby Version updating script
function rv() {
new_version=${1};
sed_command_base="^ruby.*\([[:digit:]]\.\)*[[:digit:]]*";
if [[ -z "$new_version" ]]; then
if [[ -e Gemfile ]]; then
echo "Gemfile: $(sed -ne /${sed_command_base}/p Gemfile)";
fi
if [[ -e .ruby-version ]]; then
@agrberg
agrberg / pre-push
Created July 1, 2020 14:52
This simple bash script ensures that bundle-audit is updated and called before a push to Heroku. The goal is to ensure that a developer deploying the site is 100% aware of any vulerable gems and _must_ intentionally use `--no-verify` if they do not want to update gems.
#!/usr/bin/env sh
# This simple bash script ensures that bundle-audit is updated and called before a push to Heroku
# The goal is to ensure that a developer deploying the site is 100% aware of any vulerable gems
# and _must_ intentionally use `--no-verify` if they do not want to update gems.
if [ "$1" = "heroku" ]; then
bundle exec bundle-audit check --update
fi
@agrberg
agrberg / .profile
Created December 5, 2014 16:35
Helpers for `afplay` OS X
function pid_for_name() {
ps -A | grep -m1 $1 | awk '{print $1}'
}
function pause_af {
kill -17 $(pid_for_name afplay)
}
function play_af {
kill -19 $(pid_for_name afplay)
}