Skip to content

Instantly share code, notes, and snippets.

View mickmister's full-sized avatar
🔨
Building

Michael Kochell mickmister

🔨
Building
View GitHub Profile
@mickmister
mickmister / zero_sync_schema.ts
Created February 13, 2025 19:19
Zero Sync schema example
import {
createSchema,
definePermissions,
relationships,
string,
table,
type ExpressionBuilder,
} from "@rocicorp/zero";
const User = table("User")
@mickmister
mickmister / arduino_bluetooth_midi.ino
Created June 7, 2024 23:23
arduino_bluetooth_midi.ino
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <Arduino.h>
#include <BLEMidi.h>
// Fill these in for OTA updates
const char* ssid = "";
const char* password = "";
@mickmister
mickmister / github_pr_view_changes_between_commits.md
Last active May 20, 2024 15:16
Bookmarklet to emulate "View Changes" button in GitHub PR review

I find the "View Changes" feature on GitHub PRs really useful - the button that essentially says "open the 'Files Changed' tab, comparing the current HEAD with the last commit I reviewed". This allows you to comment on exact changes that were made between now and the previous review. This button disappears after clicking it though, and (AFAIK) there's no easy way to access this functionality after the button disappears.

image

The URL format from clicking this button can be created manually, so you can choose to compare two different commits in the context of a PR review. The URL looks something like this:

https://github.com/mattermost/mattermost-plugin-github/pull/779/files/14c9e8b..0dfcb28

https://github.com/mattermost/mattermost-plugin-github/pull/779/files/14c9e8b..HEAD
@mickmister
mickmister / scrape_new_plugins.sh
Last active November 2, 2024 05:03
This bash script checks if there are any new plugins added to the Mattermost plugin marketplace, and creates a new post through a Mattermost incoming webhook request. See the comment below for more details.
#!/usr/bin/env bash
if [ -z "$MM_WEBHOOK_URL" ]
then
echo "Please set the MM_WEBHOOK_URL environment variable"
exit 0
fi
LOCAL_PLUGINSJSON_PATH="plugins.json"
REMOTE_PLUGINSJSON_PATH="new_plugins.json"
@mickmister
mickmister / mattermost_theme_switcher_bookmarklet.md
Last active February 22, 2024 16:55
Mattermost Theme Switcher Bookmarklet

A Bookmarklet to easily switch between themes in Mattermost.

The following pieces of code can be used as a bookmark URL to change your user's theme. You can copy each of these scripts into individual bookmarks in your browser. Clicking the bookmark will then change your user's theme to that value, and you should immediately see the changes in the UI.

For ease of use, you can create a folder in your bookmarks to store these, and have a bookmark for each of the following themes.

javascript: (() => {const bookmarkletTheme = 'Indigo'; fetch("/api/v4/users/me", {"headers": {"x-requested-with": "XMLHttpRequest"},"referrerPolicy": "no-referrer","mode": "cors","credentials": "include"}).then(r => r.json()).then(user => fetch("/api/v4/users/" + user.id + "/preferences", {"headers": {"x-requested-with": "XMLHttpRequest"},"body": "[{\"user_id\":\"" + user.id + "\",\"category\":\"theme\",\"name\":\"\",\"value\":\"{\\\"type\\\":\\\"" + bookmarkletTheme + "\\\",\\\"side
@mickmister
mickmister / mock_kv_store.go
Last active February 15, 2024 08:07
Mock KVStore for Mattermost plugin unit testing
package main
import (
"github.com/mattermost/mattermost/server/public/plugin/plugintest"
"github.com/stretchr/testify/mock"
)
type testKVStore map[string][]byte
func makeTestKVStore(api *plugintest.API, initialValues testKVStore) testKVStore {

You'll need to unmute the video to hear the audio

create-post-with-buttons.mp4

Uploads a plugin CI artifact to a Mattermost server. You can modify the plugin-install-gh-artifact.sh how you see fit, to connect with your MM admin account.

First you'll need to install and configure the GitHub CLI tool https://cli.github.com

Usage:

./plugin-install-gh-artifact.sh (MM site URL) (actions workflow run URL)
@mickmister
mickmister / go.mod
Last active May 18, 2023 14:50
Mattermost - Remove user from all teams and channels
module remove-channel-members
go 1.19
require (
github.com/mattermost/mattermost-server/server/public v0.0.4
github.com/pkg/errors v0.9.1
)
require (
@mickmister
mickmister / how_to_debug_playwright_logs.md
Last active February 15, 2024 08:14
Debugging Playwright tests in CI using verbose logging

Sometimes a Playwright test will run and pass correctly locally, but will fail when running in CI. We can debug the test using Playwright's verbose logging, and compare the output from both environments.

By setting the DEBUG env var to pw:api, Playwright runs the tests in verbose logging mode:

DEBUG=pw:api npm test

which produces output like this: