Skip to content

Instantly share code, notes, and snippets.


Matthew Miner mminer

View GitHub Profile
mminer / KeepWindowsSessionAlive.ps1
Created Oct 2, 2020
PowerShell script to keep Windows session alive by repeatedly toggling numlock.
View KeepWindowsSessionAlive.ps1
$wshell = New-Object -ComObject WScript.Shell
while ($true) {
Write-Output "$(Get-Date) Toggling numlock"
Start-Sleep -Seconds 10
mminer /
Created Aug 10, 2020
Converts .mov files to image sequences using FFmpeg.
#!/usr/bin/env bash
for filename in "$@"; do
base=$(basename "$filename" .mov)
mkdir "$base"
ffmpeg -i "$filename" "$base/$base-%03d.png"
mminer / storageArray.ts
Created Mar 9, 2020
Utility class to read and write arrays in localStorage / sessionStorage.
View storageArray.ts
class StorageArray {
private storage: Storage;
constructor(storage: Storage) { = storage;
get(key: string): string[] | null {
const jsonString =;
mminer / VerticalCollapse.tsx
Created Jan 2, 2020
React component for expanding and collapsing container with dynamic height.
View VerticalCollapse.tsx
import React, {forwardRef, useImperativeHandle, useRef} from 'react';
interface Props {
children: React.ReactNode;
className?: string;
collapsedHeight: number;
isCollapsed: boolean;
transitionDuration?: string;
mminer /
Created Dec 10, 2019
Basic Bash script to test equality of two inputs with coloured output.
#!/usr/bin/env bash
RESET='\033[0m' # No Color
mminer /
Created Aug 21, 2019
Servlet request wrapper that allows reading request body multiple times.
package com.matthewminer;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
mminer / lruCache.ts
Created Jul 4, 2019
Simple least-recently inserted cache.
View lruCache.ts
export default class LeastRecentlyInsertedCache<T> implements Iterable<T> {
private maxSize: number;
// Set objects maintain insertion order, making them appropriate for keeping track of when values
// are added relative to each other.
private set = new Set<T>();
constructor(maxSize: number) {
this.maxSize = maxSize;
mminer / basicAuthMiddleware.js
Created Dec 12, 2018
Express middleware for HTTP Basic Authentication.
View basicAuthMiddleware.js
function basicAuthMiddleware(request, response, next) {
const { authorization = '' } = request.headers;
const [, credentials] = authorization.split(' ');
const decoded = new Buffer(credentials || '', 'base64').toString();
const splitIndex = decoded.indexOf(':');
const username = decoded.substring(0, splitIndex);
const password = decoded.substring(splitIndex + 1);
// TODO: supply valid values for username and password
if (username !== USERNAME || password !== PASSWORD) {
mminer / InactivityReset.js
Created Dec 11, 2018
React component that runs an action after no user activity is detected.
View InactivityReset.js
import PropTypes from 'prop-types';
import { Component } from 'react';
const eventListenerOptions = { capture: true, passive: true };
// Events that signify that the user is still active.
const eventNames = ['keydown', 'mousedown', 'touchstart'];
class InactivityReset extends Component {
constructor(props) {
mminer / RelativeTime.js
Created Dec 11, 2018
React component that displays an auto-updating relative time.
View RelativeTime.js
import moment from 'moment';
import PropTypes from 'prop-types';
import { Component, createElement as h } from 'react';
class RelativeTime extends Component {
constructor(props) {
this.intervalId = null;
this.state = { output: moment(props.time).fromNow() };
this.updateOutput = this.updateOutput.bind(this);
You can’t perform that action at this time.