Skip to content

Instantly share code, notes, and snippets.

View DarkMatterMatt's full-sized avatar

Matt Moran DarkMatterMatt

  • Sydney, Australia
  • 08:29 (UTC +10:00)
View GitHub Profile
@DarkMatterMatt
DarkMatterMatt / xrandr.sh
Created October 4, 2023 00:39 — forked from chirag64/xrandr.sh
Added license on user request
#!/bin/bash
# Copyright © 2021 Chirag Bhatia
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOF
/**
* Usage: add a bookmarklet to the following link. Then, open Calven and click the bookmark to load the extension.
* javascript:fetch('https://gist.githubusercontent.com/DarkMatterMatt/5f45b7e0d84dc1ce535edf2b0750f1d7/raw').then(r => r.text()).then(eval)
*/
(async () => {
if (!window.location.hostname.endsWith('.calven.com')) {
alert('Please run this bookmarklet on *.calven.com');
return;
}
@DarkMatterMatt
DarkMatterMatt / panopto.tamper.js
Last active February 28, 2022 08:07
Fix Panopto annoyances
// ==UserScript==
// @name Panopto
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.panopto.com/Panopto/Pages/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=panopto.com
// @grant none
// ==/UserScript==
@DarkMatterMatt
DarkMatterMatt / gtfs.d.ts
Last active November 15, 2021 04:29
TypeScript definitions for the gtfs library (github.com/BlinkTagInc/node-gtfs)
// Type definitions for gtfs 3.1.4
// Project: https://github.com/BlinkTagInc/node-gtfs
// Definitions by: Matt Moran <https://github.com/DarkMatterMatt>
import parse from "csv-parse";
import { Database } from "sqlite";
declare module "gtfs" {
type SqlValue = undefined | null | string | number | boolean | Date | SqlValue[];
@DarkMatterMatt
DarkMatterMatt / affineTransform.ts
Created September 15, 2021 02:04
Minimal code to calculate an affine transformation to match three source points to three destination points. Has no dependencies.
type Point = {
x: number;
y: number;
}
type Vector = number[];
type Matrix = Vector[];
type Vector2D = [number, number];
@DarkMatterMatt
DarkMatterMatt / DragAndResizeHelper.java
Last active September 15, 2020 22:50
Allows JavaFX stage movement and resizing by dragging edges.
package win.mattm.java;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
@DarkMatterMatt
DarkMatterMatt / showCrosshair.js
Last active March 30, 2020 04:51
Shows a crosshair at specific coordinates
function toPx(a) {
return a.toString() + "px";
}
function showLine(x, y, width, height, color) {
const $a = document.createElement("div");
document.body.append($a);
$a.style.width = toPx(width);
$a.style.height = toPx(height);
@DarkMatterMatt
DarkMatterMatt / pre-commit
Created March 21, 2020 11:37
A pre-commit hook to prevent uploading secrets (API keys) by accident
#!/bin/bash
#
# A pre-commit hook to prevent uploading secrets (API keys) by accident
read -r -d "" SECRETS <<"EOF"
YOUR_API_KEY
SECRET2
EOF
# find changed files
@DarkMatterMatt
DarkMatterMatt / reorderCSS.js
Last active February 12, 2023 11:21
Reorder CSS attributes according to the LINE_ORDER defined below
const fs = require("fs");
const path = require("path");
/**
* Reorders CSS attributes according to the LINE_ORDER defined below.
* - Existing line breaks and whitespace is preserved
* - Attributes must on a single line
* - Opening braces must be at the end of their line
* - Closing braces must be on a newline
* - The original file is renamed with a .bak file extension
@DarkMatterMatt
DarkMatterMatt / discord_url_handling.csv
Last active February 25, 2020 02:49
Discord URL handling
Backend Mobile Desktop Web
Displays the user:pass N/A N N N
Link contains the user:pass Y N Y Y
Accepts percent encoded symbols (%78) Y Y Y Y
Accepts unicode percent encoding (%u0078) Y Y N N