Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Lance Jordan lacostenycoder

🎯
Focusing
View GitHub Profile
@lacostenycoder
lacostenycoder / sum_redis_call_time_from_log.rb
Created Dec 20, 2019
Sum redis call_time from log file
View sum_redis_call_time_from_log.rb
#!/usr/bin/env ruby
# pass log filename as single argument
filename = ARGV[0]
lines = File.readlines(filename).select{|l| l =~ /call_time/}
puts filename
puts lines.map{|l| l[/\d+.\d+\b/].to_f}.reduce(&:+)
@lacostenycoder
lacostenycoder / clean_branches.rb
Last active Mar 10, 2020
Clean branches by closed issue numbers
View clean_branches.rb
#!/usr/bin/env ruby
unless !!`which gh | grep 'bin/gh'`
abort('Please run brew install github/gh/gh first. exiting now.')
end
Dir.chdir(ENV['HOME'] + '/dev/clients/thoroughcare')
issue_numbers = `gh issue list -s open -L 500 | grep -o '^[[:digit:]]*'`.split("\n")
branches = `git branch --sort=committerdate`.split("\n").map(&:strip)
branch_issue_numbers = branches.select{|b| b[/\/\d+/]}.map{|i| i[/\d+/]}
delete_issue_numbers = branch_issue_numbers.reject{|n| issue_numbers.include? n}.map(&:to_s)
unless delete_issue_numbers.any?
@lacostenycoder
lacostenycoder / snippets.cson
Created Aug 13, 2019
Add ruby benchmark snippet to atom editor
View snippets.cson
# ~/.atom/snippets.cson
".source.ruby":
"Initialize":
prefix: "Benchmark"
body: "Benchmark.bm do |x|\n x.report(:a) {\t$1}\n x.report(:b) {\t$2}\nend"
@lacostenycoder
lacostenycoder / find_use_env_vars.rb
Created Jul 29, 2019
Find used and unused environment variables in .env file
View find_use_env_vars.rb
#!/usr/bin/env ruby
#Run this in the root of your local github repo to find used env vars located in .env file
vars = File.readlines('.env')
keys = vars.map{|e| e[/^\w+/]}.compact.sort
used_keys = keys.select{|k| !`git grep #{k}`.empty? rescue nil}
puts "THESE ARE USED IN THE PROJECT\n\n"
puts used_keys
puts "\nThese env vars NOT used in codebase\n\n"
puts keys - used_keys
View injectJquery.js
function injectJquery(){
var script = document.createElement('script');
script.src = 'https://code.jquery.com/jquery-2.2.4.min.js';
script.type = 'text/javascript';
script.integrity = 'sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44'
script.crossOrigin="anonymous"
document.getElementsByTagName('head')[0].appendChild(script);
}
//for more info or other versions see https://code.jquery.com/
View fix_webpacker_parser.rb
#!/usr/bin/env ruby
# goto the root of your application before running this script
filename = 'node_modules/vue-loader/lib/template-compiler/index.js'
text = File.read(filename)
new_code = %q(code = prettier.format(code, { semi: false, parser: 'babel' }))
old_code = 'code = prettier.format(code, { semi: false })'
replace = text.gsub(old_code, new_code)
@lacostenycoder
lacostenycoder / github-code-review.css
Created Mar 20, 2019
Github Code Review CSS hack
View github-code-review.css
.blob-code, .blob-code-inner {
font-weight: 300;
font-family: Hack Nerd Font; /* maybe */
font-family: Ubuntu Mono;
font-size: 14px;
-webkit-text-stroke-width: 0.4px;
-webkit-text-stroke-color: inherit;
}
.js-details-container:not(.commit-tease) {
@lacostenycoder
lacostenycoder / checkout_branch
Last active Feb 21, 2019
Easily checkout local git branches with a ruby script
View checkout_branch
#!/usr/bin/env ruby
branches = `git branch --sort=committerdate | awk '{print $1}'`.split("\n").reject{|l| l == '*'}
branches.each_with_index{|b, i| puts "#{i < 10 ? ' ' : ''}""#{i} - #{b}" }
puts "\n"
print 'type branch number: '
target_num = gets.chomp
unless target_num.length == 0
@lacostenycoder
lacostenycoder / README.md
Last active Oct 17, 2020 — forked from zaydek-old/bookmark.min.js
A *simple* CSS debugger. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css. Learn more here https://medium.freecodecamp.org/88529aa5a6a3 and https://youtu.be/2QdzahteCCs?t=1m25s (starts at 1:25)
View README.md

In newer versions of chrome you may not be able to just drag the code to your quick shortcuts. As a workaround you can just do:

  1. Copy the raw javascript in bookmark.min.js to your clipboard.
  2. right-click on the the bookmarks bar and add select add page
  3. for the name type DebugCSS
  4. for page type javascript:/ then paste the js you copied in step 1
  5. click save.
  6. Do a happy dance, your done! Happy Dance
@lacostenycoder
lacostenycoder / toggle-tap-click
Created Apr 15, 2018
Apple Script to toggle the tap to click setting for "typing" mode
View toggle-tap-click
tell application "System Preferences"
reveal anchor "trackpadTab" of pane "com.apple.preference.trackpad"
end tell
tell application "System Events" to tell process "System Preferences"
click checkbox 3 of tab group 1 of window 1
end tell
quit application "System Preferences"
You can’t perform that action at this time.