Read a filtered list of files from a directory and ask the user to choose one (Bash)
One of the most powerful aspects of Docksal is how easy it is to extend base functionality with Bash scripts. A common use-case is to automate importing databases when initializing projects. The snippet below reads all DB files from a directory and presents the user with a choice about which file to import:
How to Install Python with Brew in Mac OSX
OSX ships with an older version of Python. Install using Homebrew:
brew install python
This installs Python alongside the version in OSX. To access this version, it's necessary to run:
➜ python --version
Python 2.7.16 # <- Still the old OSX version!
➜ python3 --version
Python 3.7.4 # <- This is the version we want
Similarly, use `pip3` (instead of `pip`):
How to Downgrade Postgresql from 11 to 9 to fix "pg_dump: aborting because of server version mismatch" error
Gitlab Omnibus ships with Postgres 9.6. Unfortunately for me, several online references suggest using an external Postgres database container when using the Docker-based release of Gitlab but fail to mention the extremely important requirement: Gitlab only supports the same v
How to use the AWS CLI to list IP Addresses and other Instance Information
A common request from security officers (ISSO's), managers, or other stakeholders is a high-level summary of instances in their hosting infrastructure. Sometimes this is best delivered as a visualization, but often it's necessary to export the raw data. The AWS CLI has a tool to do this: describe-instances.
The basic usage is well documented, it goes like this:
Taming Google Search Results with uBlock Origin
Web advertising is a cancer. What purportedly began as a way to fund the production of quality content has metastasized into a privacy-invading, kludgy, bloated weight that is at direct odds with the highest ideals of the internet. Luckily, great tools exist to inoculate us against this threat. uBlock Origin is a self-described "wide spectrum" content blocker that happens to be good at blocking ads, but can do much more.
Force OSX Finder to Always Show Hidden Files
By default Mac OSX coddles the user by hiding system and "hidden" files (beginning with a period). This is counter-production to the power user in all of us, and an insult to our intelligence! End this madness with:
defaults write com.apple.finder AppleShowAllFiles YES
Then "Relaunch" Finder by option+right-clicking on the Finder icon.
To change this back, do:
defaults write com.apple.finder AppleShowAllFiles NO
Easy!
Changing the Key Repeat Rate in OSX
Mac OSX ships with very slow key repeat rates (how quickly a key repeats after it is first pressed, and how quickly a key input repeats after holding it down). Changing these effectively is not possible in System Settings, we instead use the command line.
First, read the two relevant values in case you want to go back:
defaults read -g InitialKeyRepeat
and
defaults read -g KeyRepeat
changing these values is similarly easy:
Install and Enable GIT Large File Support in OSX
Install GIT large file support:
brew install git-lfs
Then browse to your repository directory and run
git lfs install
You'll see the message "Git LFS initialized."
Find your top 10 largest files with
find ~/Documents/path/to/repo -type f -exec du -h {} + | sort -rh | head -n 10
Then add the types that make sense, e.g.
git lfs track '*.mp4'
(git lfs track to see a list of all tracked paths, files, and types)
How to fix file permissions in Mac OSX and Linux (files to 644 and directories to 755)
I run into this problem when developing on a GIT repository where file permissions change and GIT (correctly) warns of hundreds of changes. I see this most commonly when importing files from Windows, but it can happen in many different ways. The fix is to recursively update file permissions.
To fix all the directories starting from the current one, run:
find . -type d -exec chmod 775 {} \;
To do the same for files, run:
The Best Way to Block Image Hotlinking
"Image Hotlinking" is when another website embeds an image from your site (usually without permission). This increases your bandwidth bill, is a potential security concern, and is generally a pretty rude thing to do. To prevent this in Drupal, add the code below to your sites/all/files/.htaccess file: