Skip to content

Instantly share code, notes, and snippets.

View brand-it's full-sized avatar
💭
I may be slow to respond.

Brandt Lareau brand-it

💭
I may be slow to respond.
View GitHub Profile
# 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)
---
backtrace: false
bulk_threshold: 1000
sources:
- https://gems.rubyforge.org/
- https://rubygems.org/
update_sources: true
verbose: true
concurrent_downloads: 8
gem: --no-document
@brand-it
brand-it / rubocop_pre_commit_hook
Last active July 21, 2020 15:50 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
def files
@files ||= begin
`git diff --staged --name-only --cached`.split("\n").reject do |file|
!File.exists?(file)
end
end
#!/bin/bash
brew install postgresql
set -e
pg_directory='/usr/local/var'
username='postgres'
mkdir $pg_directory/data
printf "\033[1;32mcreated $pg_directory/data\033[0m\n"
mkdir $pg_directory/log
@brand-it
brand-it / code-climate-pre-hook-git.rb
Last active July 26, 2019 01:58
just a script to check code climate stuff on git commit or what ever
#!/usr/bin/env ruby
files = []
waiting = true
threads = []
lines = []
ignore = [
'db/schema.rb'
]
@brand-it
brand-it / branch_cleaning.rb
Last active July 25, 2019 15:53
This lets you destroy branches that are older then a given amount of time.
#!/usr/bin/env ruby
# frozen_string_literal: true
require File.expand_path('ruby_bash', __dir__).to_s
require 'date'
class ProcessData
attr_accessor(
:all, :debug, :changes_stashed, :primary_remote_name, :remotes, :current_branch, :git_logs,
:min_print_length, :since, :list_branches, :dry_run, :remote_branch_list, :local_branches
@brand-it
brand-it / grouping_rspec_test
Created January 30, 2019 16:06
Grouping Rspec Tests
#!/usr/bin/env ruby
require 'optparse'
options = { group: 0, total_groups: 0, pattern: 'spec/**/*_spec.rb' }
OptionParser.new do |opts|
opts.banner = "Usage: bin/rspec [options]"
opts.on('-t', '--total-groups NUMBER', 'Total number of rspec groups') do |t|
options[:total_groups] = t.to_i
end
opts.on('-g', '--group NUMBER', 'Execute group number out of total groups') do |g|
temp = Tempfile.new(['document_content', '.html'])
temp.write(options[:document_content])
temp.close
prince_cmd = "docker run --network host -v /var/folders:/var/folders -v #{logfile}:#{logfile} --rm conga/prince prince -v --javascript --log=#{logfile} --baseurl=http://host.docker.internal:3000 #{option_str} #{temp.path} - -o #{outfile.path}"
class << self
protected
def gsub_text_nodes_only!(html:, placeholder_name:, placeholder_value:)
fragment = Nokogiri::HTML.fragment(html)
fragment.traverse do |node|
next unless node.text?
# Can't use normal gsub! because it makes a copy of the content memory that is not attached
# to the node. Have to use the setter provided by nokogiri to update the node
class Config
attr_accessor :total_threads, :files_per_second, :logger
class << self
def info
@info ||= Config.new
end
end