Completion types:
- Internal commands and subcommands
- External commands
- Files (executable)
Location(s):
#!/usr/bin/env ruby | |
require 'optparse' | |
module CLI | |
extend self | |
PATHS_TO_CHECK = %w(app bin config engines lib script) | |
EXTENSIONS_TO_CHECK_FOR_DEFINITIONS = %w(.rb .rake) | |
EXTENSIONS_TO_CHECK_FOR_USAGE = EXTENSIONS_TO_CHECK_FOR_DEFINITIONS + %w(.yml .yaml .erb) |
require 'set' | |
libs = Set.new | |
Gem::Specification.reject { |spec| spec.extensions.empty? }.each do |spec| | |
spec.extensions.each do |ext_path| | |
extconf_rb_path = Pathname.new(spec.gem_dir).join(ext_path) | |
makefile_path = extconf_rb_path.dirname.join('Makefile') | |
if makefile_path.readable? | |
last_was_lib_flag = false | |
makefile_path.readlines.map(&:strip).each do |line| |
#!/usr/bin/env python | |
import cv2 | |
import os.path | |
import sys | |
import tqdm | |
def frames(reader, indices=None, desc=None): | |
frame_count = int(reader.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)) | |
if indices is None: | |
indices = xrange(0, frame_count) |
#!/bin/bash | |
profile-curl() { | |
local num_iters=500 | |
local num_warmups=10 | |
local -a times | |
for x in $(seq 1 "${num_warmups}"); do | |
curl -s -o /dev/null "$@" 2>&1 | |
done |
#!/usr/bin/ruby --disable-gems | |
# | |
# # Prerequisites | |
# | |
# - ghostscript | |
# - graphviz | |
# | |
# # Example usage | |
# | |
# graph_mutual_changes --clustering=package --since="6 months ago" && open graph.pdf |
#!/usr/bin/env ruby | |
require "flog" | |
require "open3" | |
def capture_output(cmd, *args) | |
stdout, stderr, status = Open3.capture3(cmd, *args) | |
return stdout if status.success? | |
STDERR.puts("Failed to run git #{args.join(" ")}") |
#!/usr/bin/ruby --disable-gems | |
# | |
# # Prerequisites | |
# | |
# # Example usage | |
# | |
# find_cohesive_changes <file> | |
# | |
require "open3" |
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require "csv" | |
require "set" | |
begin | |
require "erubi" | |
rescue LoadError | |
end |
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# | |
# Output a grouping of methods (within a file) such that for each group G, and any method m ∈ G: | |
# - ∃ x ∈ G such that x calls m, or | |
# - no other method in all groups calls m | |
# | |
# The output is a kind of "function cohesion", where you can find groups of methods that are related. | |
# This is useful when trying to find what you need to extract from a file. |