Skip to content

Instantly share code, notes, and snippets.

View icelander's full-sized avatar

Paul Rothrock icelander

View GitHub Profile
@icelander
icelander / azure_sync.rb
Created March 21, 2022 20:20
An example of how you could sync users to specific channels using the Azure Graph API results NOT FOR USE IN PRODUCTION
#!/usr/bin/env ruby
## About
#
# This is an example of how you could sync users via the Azure Graph API
# to teams and channels
#
## LICENSE
#
# Copyright © 2022 Paul Rothrock
@icelander
icelander / mattermost-sync-api.rb
Created March 21, 2022 20:07
A Ruby Mattermost API that does just enough to sync users
require 'httparty'
require 'uri'
require 'cgi'
class MattermostApi
include HTTParty
format :json
# debug_output STDOUT
@icelander
icelander / docker-compose.yml
Created March 21, 2022 17:29
Example Mattermost docker-compose file
version: '3.7'
volumes:
mmst_data:
mmst_logs:
mmst_config:
mmst_plugins:
mmst_client:
networks:
@icelander
icelander / irc-test.rb
Created March 15, 2022 18:30
Sends IRC messages as quickly as possible, used for testing Matterbridge relays
#!/usr/bin/env ruby
require 'socket'
require 'net/http'
require 'uri'
require 'json'
num_messages=100
@icelander
icelander / mm_auth_example.py
Created March 9, 2022 05:28
Creating a user and then authenticating as that user using the Python standard library
#!/usr/bin/env python
from urllib.request import urlopen, Request
from urllib.parse import quote
from urllib.error import URLError
import json
ADMIN_TOKEN = "6n7faf61b4o8ukcornejciyx7e"
BASE_URL = "https://mattermost.example.com/api/v4" # <= No slash!
@icelander
icelander / remove_line.sh
Created January 21, 2022 20:01
This is a simple script that removes a specific line from a file
#!/bin/bash
##
# remove_line.sh
##
# About
#
# This is a simple script that removes a given line from a file. When run it
# will create a file named
@icelander
icelander / find_invalid_lines.sh
Last active January 25, 2022 20:02
This script removes invalid JSON and posts longer than 16,383 characters from Mattermost bulk export files
#!/bin/bash
##
# find_invalid_lines.sh
#
## About
#
# This script will process a Mattermost bulk export file and remove any lines
# with post messages longer than the allowable 16383 characters
@icelander
icelander / remove-attachments.rb
Last active January 5, 2022 21:08
Removes attachments and emoji from Mattermost bulk export file
#!/usr/bin/env ruby
require 'json'
## How to use
#
# 1. Generate a Mattermost bulk export file with attachments
# 2. Unzip the file and find the .jsonl file with the post contents and put its filename on the next line
filename = 'import.jsonl'
# 3. Run it and direct the output to a new file, e.g.
#
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Update & Upgrade
apt-get update
apt-get upgrade -y

Mattermost Load Testing - The Complete Instructions

Problem

You want to see how many users a free tier AWS instance can support

Solution

You can use mattermost-load-test-ng to run load tests of tens of thousands of users, but it can be difficult to set up. This is a step