Skip to content

Instantly share code, notes, and snippets.


Kevin Jalbert kevinjalbert

View GitHub Profile
kevinjalbert / git_dig.rb
Last active Aug 1, 2022
Git Dig (find deleted files whose content matches a regex)
View git_dig.rb
#!/usr/bin/env ruby
require 'optparse'
require 'open3'
def files_with_search_query(sha, search_query)
`git show --format="" --name-only #{sha} -i --pickaxe-regex -S #{search_query}`.split("\n")
def grep_over_file(sha, file, search_query)
kevinjalbert / import-raindrop-highlights-into-readwise.rb
Last active Jul 26, 2022
Import Highlights into Readwise
View import-raindrop-highlights-into-readwise.rb
#!/usr/bin/env ruby
require "httparty"
require "nokogiri"
require "open-uri"
require "uri"
LAST_SAVED_HIGHLIGHT=000000000 # <- Keeps track of import position (Updates automatically)
kevinjalbert / mirror.scpt
Last active Sep 11, 2021
AppleScript to Mirror iPhone to QuickTime
View mirror.scpt
set deviceName to "Kevin’s iPhone"
# ----- Functions -----
kevinjalbert / Coronavirus.js
Last active Aug 17, 2021 — forked from planecore/Coronavirus.js
Coronavirus Scriptable Widget (For Canadian Provinces)
View Coronavirus.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-green; icon-glyph: user-md;
// heavily inspired by
const province = "ON" // change this to your province
const url = ""
const req = new Request(url)
const res = await req.loadJSON()
kevinjalbert / bluetooth_headphones.scpt
Last active Jun 27, 2020
AppleScript to connect bluetooth headphones and show its battery level
View bluetooth_headphones.scpt
activate application "SystemUIServer"
set deviceName to "Kevin Jalbert's BeatsX"
tell application "System Events"
tell process "SystemUIServer"
set bluetoothMenu to (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
tell bluetoothMenu
set deviceMenuItem to (menu item deviceName of menu 1)

Keybase proof

I hereby claim:

  • I am kevinjalbert on github.
  • I am kevinjalbert ( on keybase.
  • I have a public key ASBaI00PzCjfm33W097j1OlZBBHZahbLTV3TXXSnFT7Jsgo

To claim this, I am signing this object:


Enhanced Vim Searching

Basic Searching

Vim provides rather simple searching capabilities using the following keys while in normal mode:

  • / performs a forward search of the provided pattern
  • ? performs a backward search of the provided pattern
  • * performs a forward search of the word under the cursor
  • # performs a backward search of the word under the cursor
kevinjalbert /
Created Apr 24, 2015
Vim substitution feedback using vim-over

Vim substitution feedback using vim-over

It is common while in vim to perform substitution tasks over the text you are editing. This is often accomplished using the following command:


The %s command will perform substitution over every line within the buffer. The /<find>/<replace> specifies the substitution to perform. Finally the /g indicates that this should apply to multiple occurrences if they are present on the same line.

This works great, although there is little affordance in determining whether the specified <find> will hit the matches you are interested in. The aforementioned command is a all-or-nothing with respect to execution, there is no visual feedback until you execute the command.

Visual Feedback via vim-over

kevinjalbert / record_screen.applescript
Created Apr 10, 2015
Record Screen with Applescript
View record_screen.applescript
on run {input, parameters}
tell application "QuickTime Player" to quit
delay 0.5
tell application "QuickTime Player" to activate
delay 0.5
kevinjalbert /
Last active Dec 31, 2021
Project-Wide Search and Replace with Vim

Project-Wide Search and Replace with Vim

There are many instances where you might want to perform a mass search and replace in Vim. The following are two commands that can help out with such a task.

List of Files

First you need to acquire a list of files in which you want to perform search and replaces on. The following Vim command args allows you to store a set of file names to act on later.

:args `<command which generates a file list>`

Thus we can use the following to store a list of files which match the 'Base::Lol::' . pattern.