Skip to content

Instantly share code, notes, and snippets.

View defaye's full-sized avatar

Jono Feist defaye

  • England
View GitHub Profile
@defaye
defaye / open_coverage_report.sh
Created February 6, 2024 14:23
open code coverage report
open_coverage_report() {
# Find the coverage/index.html file, excluding node_modules and prioritizing higher-level directories
local file=$(find . -type d -name "node_modules" -prune -o -type f -name "index.html" -path "*/coverage/*" -print | head -n 1)
# Check if the file was found
if [[ -n "$file" ]]; then
# Open the file in the default browser or Firefox if the default is not set
open -a "Firefox" "$file" || open "$file"
else
echo "No coverage/index.html file found in the current directory or its subdirectories."
@defaye
defaye / swap_pg_version.sh
Created January 26, 2024 16:35
Swap Postgres version via Homebrew
swap_pg_version() {
if [ $# -ne 1 ]; then
echo "Usage: swap_pg_version <version>"
return 1
fi
TARGET_VERSION="postgresql@$1"
# List all installed PostgreSQL versions
INSTALLED_VERSIONS=$(brew list --formula | grep 'postgresql@')
@defaye
defaye / install_older_versions_of_ruby_on_ubuntu_22_04.sh
Created May 9, 2022 23:28
Installing Older Ruby Versions on Ubuntu 22.04 with rbenv
# adapted from https://deanpcmad.com/2022/installing-older-ruby-versions-on-ubuntu-22-04/
mkdir ~/.openssl
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar zxvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=/home/$USER/.openssl/openssl-1.1.1g --openssldir=/home/$USER/.openssl/openssl-1.1.1g
make
make test
make install
rm -rf ~/.openssl/openssl-1.1.1g/certs
<template>
<div>
<button
@click="$refs['staged-files'].show()"
class="btn btn-primary w-100"
type="button"
>
Upload Images
</button>
<input
@defaye
defaye / install_aws_cli.sh
Created July 12, 2021 11:18
Install AWS CLI Ubuntu 18.04
mkdir aws_cli_installation_temp
cd aws_cli_installation_temp
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
cd ..
rm -rf aws_cli_installation_temp
@defaye
defaye / without_vue_i18n_translate_helper.js
Created March 11, 2021 12:38
Translation helper to be used with messages in a Vue store
import { at } from 'lodash'
Vue.prototype.$t = function (translationKey, options) {
const rawTranslation = at(this.$store.state.translations.translations, translationKey)
let translation = rawTranslation[0]
for (let key in options) {
translation = translation.replace(`%{${key}}`, options[key])
}
@defaye
defaye / ufw_vpn_killswitch_tutorial.md
Created January 31, 2021 22:43 — forked from Necklaces/ufw_vpn_killswitch_tutorial.md
GNU/Linux UFW VPN kill switch tutorial

GNU/Linux UFW VPN kill switch tutorial

This is a quick guide for setting up a kill switch using UFW (Uncomplicated FireWall). It is assumed you are using OpenVPN and optionally Network-Manager with network-manager-openvpn.

1. (Optional) IP Addresses

Before we can start we're going to need the IP address (or the IP addresses) of your VPN so that we can whitelist those later on, write them down. They are obviously going to be different for every VPN and VPNs with multiple servers, so I'll leave this up to you.

2. Install UFW

On some systems UFW is installed and enabled by default (Ubuntu, for example). Installation procedure is going to be different for every distribution of GNU/Linux, but it's usually something like

@defaye
defaye / install_elasticsearch.sh
Created May 29, 2020 12:02
Install ElasticSearch on Ubuntu 18.04
# https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-elasticsearch-on-ubuntu-18-04
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update && sudo apt install -y elasticsearch
sudo sed -i -E "s/^\#?network\.host:\s+.*$/network.host: localhost/" /etc/elasticsearch/elasticsearch.yml
sudo service elasticsearch start # start as a service
systemctl list-units --type service | grep elasticsearch # check it is active and enabled on boot # https://askubuntu.com/questions/912216/16-04-command-to-list-all-services-started-on-boot
@defaye
defaye / install_postgis.sh
Created May 28, 2020 14:28
Install PostGIS
sudo apt update && sudo apt install -y postgis postgresql-10-postgis-2.4
sudo -u postgres createuser postgis_test
sudo -u postgres createdb postgis_db -O postgis_test
sudo -u postgres psql -d postgis_db -c 'CREATE EXTENSION postgis'
sudo -u postgres psql -d postgis_db -c 'SELECT PostGIS_version()'
@defaye
defaye / install_nvm_node.sh
Created May 26, 2020 12:41
Install Node.js via NVM automatically using the latest LTS
# https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh -o install_nvm.sh
bash install_nvm.sh
{ cat << 'EOT'; cat << EOF; } >> ~/.$(echo $SHELL | grep -o '[^/]*$')rc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
EOT
EOF
source ~/.$(echo $SHELL | grep -o '[^/]*$')rc