Skip to content

Instantly share code, notes, and snippets.

@jonjack
jonjack / git-scraps.md
Last active April 25, 2024 19:12
Git scraps

Comparing commits

To compare last two commits.

git diff HEAD^ HEAD

Since comparison with HEAD is the default you can omit it for even shorter syntax.

@jonjack
jonjack / add-update-refresh-github-access-token-on-mac.md
Last active April 24, 2024 10:05
Adding & Updating GitHub Access Token on Mac

Using an Access Token for the first time

Follow the instructions on Github to Create an Access Token in Github

Configure Git to use the osxkeychain

By default, git credentials are not cached so you need to tell Git if you want to avoid having to provide them each time Github requires you to authenticate. On Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account.

You can tell Git you want to store credentials in the osxkeychain by running the following:-

Install MySQL

See what formula are available.

brew search mysql
==> Formulae

scala.collection.Searching provides binary search but you need an Indexed sequence (eg. Array), not a Linear sequence (eg. List). Search will still work on the List but you get linear O(n) behaviour rather than O(Log n).

case class Employee (id: Int, name: String, age: Int)

val emp1 = Employee(1, "Jane Doe", 45)
val emp2 = Employee(2, "Jon Doe", 54)
val emp3 = Employee(3, "Tera Patrick", 38)
val emp4 = Employee(4, "Jenna Jameson", 36)
val emp5 = Employee(5, "Aurora Snow", 34) // not added
This file has been truncated, but you can view the full file.
#!/bin/bash
# create directory for python install
sudo mkdir -p /opt/bin
sudo chown -hR core:core /opt
cd /opt
# check for newer versions at http://downloads.activestate.com/ActivePython/releases/
wget http://downloads.activestate.com/ActivePython/releases/3.6.0.3600/ActivePython-3.6.0.3600-linux-x86_64-glibc-2.3.6-401834.tar.gz
tar -xzvf ActivePython-3.6.0.3600-linux-x86_64-glibc-2.3.6-401834.tar.gz
@jonjack
jonjack / git-show-branch-info.sh
Created April 6, 2022 11:46
Display textual history of all commits in Git branch.
#!/usr/bin/env zsh
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
@jonjack
jonjack / vs-code-command-code-runner-run-not-found-fix.md
Last active September 26, 2021 21:17
Visual Studio code - command 'code-runner.run' not found fix for formulahendry.code-runner-0.9.10

Program: Visual Studio Code
Extension: Code Runner 0.9.10 (code-runner-0.9.10)
Problem: When attempting to run a script/program, VS Code reports error: "command 'code-runner.run'"
Fix: Manually edit extension code.

Edit extension file codeManager.js
On macOS this is usually at ~/.vscode/extensions/formulahendry.code-runner-0.9.10/out/src/codeManager.js

Comment out line 12.

@jonjack
jonjack / mysqlworkbench-8.0.22.rb
Last active June 22, 2021 12:12
Homebrew mysqlworkbench 8.0.22 cask formula for Big Sur
cask "mysqlworkbench-8.0.22" do
version "8.0.22"
sha256 "4e27de82d869043cf80e803f1a57cc041a91cabddf0aa6a6c054d68af1837d48"
url "https://downloads.mysql.com/archives/get/p/#{version.major}/file/mysql-workbench-community-#{version}-macos-x86_64.dmg"
name "MySQL Workbench"
desc "Visual tool to design, develop and administer MySQL servers"
homepage "https://www.mysql.com/products/workbench/"
app "MySQLWorkbench.app"
@jonjack
jonjack / mysqlworkbench-8.0.25.rb
Last active June 22, 2021 12:10
Homebrew mysqlworkbench 8.0.25 cask formula for Big Sur
cask "mysqlworkbench-8.0.25" do
version "8.0.25"
sha256 "8da15d32d0c3cc8d43e49f8d3580ddec0d8dcd718153da7c934acf26f83ea0c5"
url "https://cdn.mysql.com/Downloads/MySQLGUITools/mysql-workbench-community-#{version}-macos-x86_64.dmg"
livecheck do
url "https://dev.mysql.com/downloads/workbench/"
strategy :page_match
regex(/MySQL\s*Workbench\s*(\d+(?:\.\d+)*)/i)
end