Skip to content

Instantly share code, notes, and snippets.

View mattantonelli's full-sized avatar

Matt Antonelli mattantonelli

  • 23:37 (UTC -04:00)
View GitHub Profile
@mattantonelli
mattantonelli / remote_ssh_vagrant_vm.md
Created July 3, 2025 18:19
VSCode Remote - SSH for Vagrant VM

VSCode Remote - SSH for Vagrant VM

  1. Navigate to your Vagrant box directory and run vagrant ssh-config
  2. Copy the output
  3. Navigate to %userprofile%\.ssh
  4. Paste the output in config (rename the host if you prefer)
  5. Navigate to the directory containing the IdentityFile from your config
  6. Open your shell and ensure the permissions are set to 600
  7. Paste the following in your VSCode settings JSON:
"remote.SSH.useLocalServer": true
@mattantonelli
mattantonelli / round_robin_task_assignment.rb
Last active January 30, 2025 13:55
Round robin task assignment. Files are simply line delimited tasks/developers.
tasks = File.readlines('./tasks.txt', chomp: true).sort.freeze
developers = File.readlines('./developers.txt', chomp: true).shuffle.freeze
tasks.each_with_index do |task, i|
puts "#{task} - @#{developers[i % developers.size]}"
@mattantonelli
mattantonelli / mariadb_backup_restore.cnf
Created November 21, 2024 17:05
Configure MariaDB to improve dump restore time
# /etc/my.cnf.d/mariadb-server.cnf
[mysqld]
innodb_buffer_pool_size = 4G # 50% RAM
innodb_log_file_size = 1G
innodb_flush_log_at_trx_commit = 0
innodb_doublewrite = 0
max_allowed_packet = 256M
# Load the dump, skipping uniqueness and foreign key checks
time mysql -u root -p -D my_database --init-command="SET SESSION FOREIGN_KEY_CHECKS=0; SET SESSION UNIQUE_CHECKS=0;" < dump.sql
@mattantonelli
mattantonelli / ruby_gem_passenger_nginx.service
Last active November 24, 2024 21:07
systemd service file for NGNIX installed via Ruby Passenger gem
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
@mattantonelli
mattantonelli / update_aws_cdk_python.sh
Created July 21, 2023 14:47
Update AWS CDK for Python
# We must update both the Python and NPM packages
pip install --upgrade aws-cdk-lib
npm install -g aws-cdk@latest
@mattantonelli
mattantonelli / ruby_322_centos_7.sh
Created July 21, 2023 14:43
Install Ruby 3.2.2 on CentOS 7
# Resolves the following error which occurs when Ruby does not like our GCC version:
#
# vm_core.h:1865:34: error: ‘ruby_current_ec’ undeclared (first use in this function)
# rb_execution_context_t *ec = ruby_current_ec;
#
# Install the Developer Toolset 7 package to obtain a more current version of GCC
sudo yum install centos-release-scl
sudo yum install devtoolset-7
@mattantonelli
mattantonelli / pyenv_311_openssl11.sh
Created February 16, 2023 13:36
Install Python 3.11 via pyenv on CentOS 7 with custom OpenSSL 1.1
sudo yum install gcc make zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl11-devel tk-devel libffi-devel xz-devel
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
CPPFLAGS=-I/usr/include/openssl11 LDFLAGS=-L/usr/lib64/openssl11 pyenv install 3.11
@mattantonelli
mattantonelli / centos_setup
Created January 20, 2023 17:34
Various setup stuff for a fresh CentOS VM
sudo dd if=/dev/zero of=/swapfile count=2048 bs=1MiB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo vi /etc/fstab
/swapfile swap swap defaults 0 0
sudo yum group install -y "Development Tools"
sudo yum install -y gcc-6 patch bzip2 openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel wget libcurl-devel tmux vim
@mattantonelli
mattantonelli / dump_rails_model.rb
Created December 2, 2022 14:05
Simple dump of specified columns for a Rails model
headers = %w(column1 column2 column3)
CSV.open('tmp/output.csv', 'wb') { |csv| csv << headers; MyModel.each { |app| csv << app.attributes.values_at(*headers) } }
@mattantonelli
mattantonelli / youtube-dl-audio-only.sh
Last active December 8, 2022 15:55
youtube-dl audio only
# List all available formats and download specific audio-only format
youtube-dl -F https://www.youtube.com/watch?v=xFjpTF4-PgI
youtube-dl -f 140 https://www.youtube.com/watch?v=xFjpTF4-PgI
# Download and convert to audio-only format
youtube-dl -x --audio-format m4a https://www.youtube.com/watch?v=xFjpTF4-PgI