Skip to content

Instantly share code, notes, and snippets.

View kevinjalbert's full-sized avatar

Kevin Jalbert kevinjalbert

View GitHub Profile
@kevinjalbert
kevinjalbert / enhanced-vim-searching.md
Last active September 1, 2017 15:49
Enhanced Vim Searching

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
kevinjalbert / bluetooth_headphones.scpt
Last active June 27, 2020 02:49
AppleScript to connect bluetooth headphones and show its battery level
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
click
set deviceMenuItem to (menu item deviceName of menu 1)
@kevinjalbert
kevinjalbert / Coronavirus.js
Last active August 17, 2021 15:04 — forked from planecore/Coronavirus.js
Coronavirus Scriptable Widget (For Canadian Provinces)
// 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 https://gist.github.com/planecore/e7b4c1e5db2dd28b1a023860e831355e
const province = "ON" // change this to your province
const url = "https://api.covid19tracker.ca/summary/split"
const req = new Request(url)
const res = await req.loadJSON()
@kevinjalbert
kevinjalbert / readme.md
Last active December 31, 2021 03:49
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.

@kevinjalbert
kevinjalbert / git_dig.rb
Last active August 1, 2022 03:06
Git Dig (find deleted files whose content matches a regex)
#!/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")
end
def grep_over_file(sha, file, search_query)
@kevinjalbert
kevinjalbert / git-bisect-branch.sh
Last active September 1, 2022 03:34
Git Bisect: Only the Current Branch
#!/usr/bin/env bash
while getopts 'b:dh' OPTION; do
case "$OPTION" in
b)
divergent_branch=$OPTARG
;;
d)
debug=true
;;
h)
@kevinjalbert
kevinjalbert / mirror.scpt
Last active September 16, 2022 10:42
AppleScript to Mirror iPhone to QuickTime
set deviceName to "Kevin’s iPhone"
activateScreenKeepAwake()
readyQuickTime()
setVideoInput(deviceName)
setAudioInput(deviceName)
setVolume(1.0)
setScreenSize("maximize")
# ----- Functions -----
@kevinjalbert
kevinjalbert / import-raindrop-highlights-into-readwise.rb
Last active March 23, 2024 20:13
Import Raindrop.io Highlights into Readwise
#!/usr/bin/env ruby
require "httparty"
require "nokogiri"
require "open-uri"
require "uri"
RAINDROP_AUTH_TOKEN="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
READWISE_AUTH_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
LAST_SAVED_HIGHLIGHT=000000000 # <- Keeps track of import position (Updates automatically)