Skip to content

Instantly share code, notes, and snippets.

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

Chris Habgood chabgood

🏠
Working from home
View GitHub Profile
@chabgood
chabgood / pre-commit
Last active August 2, 2016 01:38
git pre-commit hook prevent pry debug
#!/usr/bin/env ruby
class CheckForDebug
def self.run
@files = `git grep --all-match -e 'binding.pry' --and --not -e 'add binding' --line-number`
exit_and_notify if @files.length > 0
exit 0;
end
def self.exit_and_notify
p @files.strip
@chabgood
chabgood / gist:431271af6f29492348201ddf63a1fe0d
Created April 17, 2017 14:25
Find a the count of a word in a file
def find_word(word)
the_file="#{Rails.root}/app/models/release_asset.rb"
file = File.open(the_file, "r")
index = 0
file.each_line { |line|
if line.include?(word)
index+=1
end
}
@chabgood
chabgood / gist:7b24c5b5463c51f1683319fdcd077308
Created January 2, 2019 18:50
save state db when changing branch
#!/usr/bin/env ruby
require 'yaml'
class UnsupportedDatabaseAdapter < RuntimeError
attr_reader :adapter
def initialize(adapter)
@adapter = adapter
@chabgood
chabgood / eslint config react
Created February 23, 2020 07:00
eslint config react
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"prettier",
"prettier/react"
],
"rules": {
@chabgood
chabgood / React Inspect props
Last active March 1, 2020 18:27
React Inspect props
<pre>
<code>{JSON.stringify(props, null, 4)}</code>
</pre>
BRANCH=$(git rev-parse --abbrev-ref HEAD)
RELEASE=$(git branch -a | grep -Eo 'release/\d{2}.\d{2}.\d{2}' | tail -n 1)
git checkout ${RELEASE} && git pull
git checkout ${BRANCH} && git rebase ${RELEASE}