Skip to content

Instantly share code, notes, and snippets.

The $C2:$C13 for the COUNTIF should actually be the selection for the entire set of computed month.
In my example, it should really be $C2:$C3.
| tool | start date | computed month | | month | count |
|--------+-----------------+----------------+---+---------+---------------------------|
| drill | Sept 15, 2019 | 2019-09 | | 2018-10 | =COUNTIF($C$2:$C$13, E2) |
| hammer | October 8, 2018 | 2018-10 | | 2018-11 | =COUNTIF($C$2:$C$13, E3) |
| | | | | 2018-12 | =COUNTIF($C$2:$C$13, E4) |
@ajvargo
ajvargo / strategy.rb
Created May 2, 2018 16:18
Strategy pattern w/ namespaces
module API
module Vendor
class Client
def hello!
puts "Vendor Client Hello!"
end
end
class Helper
def hello!
@ajvargo
ajvargo / term-repeat-last-command.el
Created April 4, 2018 14:07
Repeat the last terminal command from any buffer (in Emacs)
;; I use it for other things, but in this case, its used to give you a
;; list of terminal buffers to choose from. FWIW, you could hard-code
;; the buffer name.
(defun ajv-ido-completing-read-for-mode (prompt the-mode)
(ido-completing-read prompt
(save-excursion
(delq
nil
(mapcar (lambda (buf)
(when (buffer-live-p buf)
@ajvargo
ajvargo / git.org
Last active May 26, 2017 18:56
blame et al

git

blame

Or, why you should write good commit messages.

maligned commands

Or, writing good commit messages is easier than you think

Forgotten commands

Your own commands

git blame

@ajvargo
ajvargo / rspec-mode-extensions.el
Created October 18, 2016 16:44
Add before and after verification hooks to RSpec mode. Includes example to update modeline based on # of failures.
;; Define some before and after hooks
(defcustom rspec-after-verification-hook nil
"Hooks run after `rspec-verify' and its variants. They
execute after failures have been stored in
`rspec-last-failed-specs'."
:type 'hook
:group 'rspec-mode)
(defcustom rspec-before-verification-hook nil
"Hooks run before `rspec-verify' and its variants."
@ajvargo
ajvargo / work_it.txt
Created August 24, 2016 18:49
Work it chorus
Is it worth it, let me work it
I put my thing down, flip it and reverse it
Ti esrever dna ti pilf nwod gniht ym tup I
Ti esrever dna ti pilf nwod gniht ym tup I
@ajvargo
ajvargo / case_and_proc.rb
Created June 29, 2016 18:35
Show how proc aliases === to call
# On procs, Ruby aliases `===` to `call`
# The comparator that a case statement uses is `===`
# This means that you can use procs as when clauses
a_proc = proc { "I'm a proc" }
b_proc = proc {|x| "I'm a proc that says '#{x}'"}
a_proc.call # => I'm a proc
b_proc.call # => I'm a proc that says ''
b_proc.call "Hello!" #=> I'm a proc that says 'Hello!'
@ajvargo
ajvargo / bb-execute.el
Last active August 24, 2016 15:23
elisp for sending commands to a vagrant instance
;; This send a given command to a vagrant machine
;; The project is an important convention. Its used to:
;; - temporarily cd into the directory for sending the command
;; In my case, my work is in ~/dev/, so it'd be ~/dev/project-name/
;; - its used in the name of the output buffer
;; - its used in the ssh command
;; You'll need an alias to the VM in your ~/.ssh/
;; You can get it with `vagrant ssh-config'.
;; I'd not use 'default', if you've got more than 1.
;;
@ajvargo
ajvargo / rspec-mode-bb-overrides.el
Created May 3, 2016 22:35
Get RSpec mode working w/ Vagrant
(defun vagrant-rspec-spec-file-for (orig-fun a-file-name)
"Convert file name from local to vagrant"
(apply orig-fun (list (replace-regexp-in-string "^.+/spec" "/vagrant/spec" a-file-name))))
(with-eval-after-load 'rspec-mode
(setq rspec-spec-command "vrspec"
rspec-command-options "--format=progress --no-profile"
rspec-use-bundler-when-possible nil
rspec-use-opts-file-when-available nil)
@ajvargo
ajvargo / interleave.rb
Created April 19, 2016 14:39
Testing different ways to `zip` arrays when the first isn't longest
require "benchmark"
def interleave(*arrays)
result = []
current_positions = Array.new(arrays.length) { 0 }
completed_arrays = Array.new(arrays.length) { false }
while true
arrays.each_with_index do |array, index|
current_position = current_positions[index]