Skip to content

Instantly share code, notes, and snippets.

@jonjack
jonjack / cloudfront-function-to-block-distribution-url.md
Last active August 6, 2024 12:45
CloudFront function that blocks access to a CloudFront distribution's public URL

By default, CloudFront distribution URLs (eg. https://d2kl2vxl3xne45.cloudfront.net) are publicly accessible. So if you are using CloudFront to serve a static website out of S3, for example, then your site shall also be accessible via the CF URL as well as any custom domain you are using. If you are using Signed URLs or Signed Cookies to restrict access to your content then this is not an issue, but if you are serving your content publicly then it might bother you.

I am not sure if CloudFront URLs are easily discoverable (probably not) but if we want to ensure that our web application cannot be accessed via the CF URL then we need to block access to it.

AWS Docs Tutorial: Create a simple function with CloudFront Functions

WAF - an alternative solution may be to use AWS WAF custom rules (assuming you are using WAF that is). You would also only probably want to explore this option if you are using WAF at the C

@jonjack
jonjack / functional-programming-glossary.md
Created July 29, 2024 23:09
Functional Programming Glossary

Glossary

An evolving glossary of terms used in functional programming, mathematics and computing in general.

An understanding of many mathematical terms is fundamental to get an understanding of many of the principles embodied in functional programming.

A few other glossaries that may come in handy:-

Reactive Manifesto
Programming in Scala

This file has been truncated, but you can view the full file.
@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

Assumes you have brew installed.

Install pyenv.

brew install pyenv

Check what versions of python are available.

@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 / osx-brew-install-not-symlinked-chown-user-local.md
Last active November 24, 2020 12:43
cannot complete brew install, not symlinked into /usr/local, requires me to chown /usr/local

While installing some formula I get:-

The formula built, but is not symlinked into /usr/local

Running brew as root is not allowed.

sudo brew install awscli