Skip to content

Instantly share code, notes, and snippets.

View brand-it's full-sized avatar

Brandt Lareau brand-it

View GitHub Profile
@brand-it
brand-it / logger.rb
Last active March 5, 2024 19:59
logger for scripting
# A nice way to add color to strings
class PrettyString < String
# https://no-color.org/
NO_COLOR = ENV.key?('NO_COLOR') || `tput colors`.chomp.to_i < 8
ANSI_COLORS = {
white: 0,
red: 31,
green: 32,
yellow: 33,
blue: 34,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brand-it
brand-it / geo.json
Last active November 12, 2021 21:51
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
set -e
# Instructions:
#
# This script is a Git pre-commit hook that spell checks any content you are about to commit.
#
# Place this script into the ".git/hooks/" directory in your repository. It must be called "pre-commit" and be
# executable. A Git hook only works in a single repository. You need to copy this hook into every repository you wish to
# use it in manually. Optionally, you can set up a symlink in the ".git/hooks/" directory pointing to the script.
@brand-it
brand-it / Dockerfile
Created August 16, 2021 15:36
Rails Template ruby 2.7.3 with nodejs
# Choose a version of Ruby
FROM ruby:2.7.3-slim
ARG APP_NAME=lentille
ARG BUNDLER_ARGS
ARG BUNDLE_WITH
ARG BUNDLE_WITHOUT
ARG BUNDLE_DEPLOYMENT
ENV APP_NAME=${APP_NAME}
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'pry'
def files
@files ||= begin
`git diff --staged --name-only --cached`.split("\n").reject do |file|
!File.exists?(file)
end
@brand-it
brand-it / rspec_hook
Last active April 15, 2021 22:04
A tool to test in a effect way by only testing the min amount. .git/hooks/pre-commit.d/rspec
#!/usr/bin/env ruby
class ExampleStatusParser
def self.parse(string)
new(string).parse
end
def initialize(string)
@header_line, _, *@row_lines = string.lines.to_a
end
@brand-it
brand-it / transfer_gems_from_geminaox.rb
Last active January 12, 2021 19:49
Lazy code to move gems from one gem inabox to another. requires the gem inabox to be installed
#!/usr/bin/env ruby
require 'net/http'
require 'open-uri'
require 'tempfile'
require File.expand_path('ruby_bash', __dir__).to_s
options = {}
parser = OptionParser.new do |opts|
opts.banner = 'Usage: replicate gem inabox'
---
backtrace: false
bulk_threshold: 1000
sources:
- https://gems.rubyforge.org/
- https://rubygems.org/
update_sources: true
verbose: true
concurrent_downloads: 8
gem: --no-document
# Use `bundle --gemfile Gemfile.local` to activate
# Use `eche -e "Gemfile.local\nGemfile.local.lock" >> ~/.gitignore` to ignore it from all repos
# Use `eche -e "*.local*" >> ~/.gitignore` That or just ignore all files that have .local
gem 'dotenv-rails', require: 'dotenv/rails-now'
# Include global Gemfile
eval File.read('Gemfile')
# Gems for local host (same syntax as for Gemfile)