Skip to content

Instantly share code, notes, and snippets.

View mattantonelli's full-sized avatar

Matt Antonelli mattantonelli

  • 03:46 (UTC -04:00)
View GitHub Profile
@mattantonelli
mattantonelli / new_mog_station.rb
Created August 13, 2021 14:54
Bulk update for new Mog Station sources #ffxivcollect
Armoire.where('name_en like ?', "Summer's Flame%").each { |armoire| armoire.sources.create!(type: SourceType.find_by(name: 'Premium'), text: 'Mog Station', premium: true) }
@mattantonelli
mattantonelli / reaction_contest.rb
Last active June 20, 2021 12:59
Generate a unique list of users who provided any reaction on a given Discord message
reactions = message.reactions.values.map(&:to_s)
reactions.flat_map { |reaction| message.reacted_with(reaction, limit: nil) }.map(&:distinct).uniq
@mattantonelli
mattantonelli / regex.md
Created June 10, 2021 14:32
Multilingual regex stuff (works in Ruby)
Alphabetical
\A[\p{L}]+\z
Alphabetical (with spaces)
\A[\p{L} ]+\z
@mattantonelli
mattantonelli / install_ngingx_passenger_centos8.md
Last active June 17, 2021 18:02
Basic setup for NGINX + Passenger + Rails/Sinatra on CentOS 8 w/ SELinux considerations

1. Set up the basics

sudo yum group install "Development Tools"
sudo yum install openssl-devel libcurl-devel
sudo mkdir -p /opt/rails/mycoolapp/shared
sudo chcon -R -h -t httpd_sys_content_t /opt/rails/
sudo useradd nginx
sudo chown -R nginx:nginx /opt/rails
sudo su - nginx
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
@mattantonelli
mattantonelli / automysqlbackup.md
Created April 7, 2021 18:15
Set up automatic MySQL/MariaDB backups with AutoMySQLBackup

1. Download and configure AutoMySQLBackup

mkdir /opt/automysqlbackup
cp /opt/automysqlbackup
wget https://sourceforge.net/projects/automysqlbackup/files/latest/download -O automysqlbackup.tar.gz
tar -xvf automysqlbackup.tar.gz
vim myserver.conf # Configure as needed

2. Create a script for running the backups

@mattantonelli
mattantonelli / archive_log.sh
Created February 18, 2021 14:23
Archive a logfile with a timestamped filename and gzip it
#!/usr/bin/env sh
#
# Purpose:
# Archive a logfile with a timestamped filename and gzip it
#
# Configuration:
# 1. Set the input and output paths below
# 2. Schedule a cron to execute this script
input=/my/log/alerts.log
@mattantonelli
mattantonelli / discord_interactions_webhook_rails.md
Created December 16, 2020 18:33
Discord interactions webhook implementation for Ruby on Rails

app/controllers/discord_controller.rb

class DiscordController < ApplicationController
  skip_before_action :verify_authenticity_token

  def interactions
    # Request signature verification
    begin
      verify_request!
 rescue Ed25519::VerifyError
@mattantonelli
mattantonelli / patch_5_4.log
Created December 8, 2020 13:13
FFXIV Collect update log for Patch 5.4.
Creating instances
Found new data for Akh Afah Amphitheatre (Hard) (20024):
name_en: Akh Afah Amphitheatre (Hard) → The Akh Afah Amphitheatre (Hard)
Found new data for Akh Afah Amphitheatre (Extreme) (20025):
name_en: Akh Afah Amphitheatre (Extreme) → The Akh Afah Amphitheatre (Extreme)
Created 13 new instances
Creating quests
Created 33 new quests
Creating achievement types
Creating achievement categories
@mattantonelli
mattantonelli / reverse_range.rb
Created November 13, 2020 00:23
A totally acceptable way of producing a reverse range in Ruby.
#!/usr/bin/env ruby
class CoolNum
attr :x
def initialize(x)
@x = x
end
def succ
@mattantonelli
mattantonelli / patch_5_35.log
Last active October 28, 2020 19:20
FFXIV Collect update log for Patch 5.35.
Creating instances
Created 0 new instances
Creating quests
Created 17 new quests
Creating achievement types
Creating achievement categories
Creating achievements
Created 53 new achievements
Creating titles
Created 8 new titles