Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
@LiamKarlMitchell
LiamKarlMitchell / block-youtube-ads.js
Created October 14, 2023 03:23
Attempt to block youtube ads, English NZ
// https://www.youtube.com/watch?v=LcmT38ZPTjg
var _STAGE_ = 0;
var _FAIL_COUNT_ = 0;
var __INTERVAL__ = setInterval(function() {
let iframe = null;
let blockAdBtn = null;
let continueElement = null;
let closeBtn = null;
let infoBtn = null;
if (_STAGE_ > 0) {
@LiamKarlMitchell
LiamKarlMitchell / main.dart
Created March 4, 2023 11:01
Flutter Bloc Delayed Event Emit - Restartable
// This example will use Restartable event transformer and cancel/ignore previous events that are emitted only accepting the latest event.
// Can kind of see this in console and added a random color on build of text.
// This code is distributed under the MIT License.
// Copyright (c) 2018 Felix Angelov.
// You can find the original at https://github.com/felangel/bloc.
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
// import 'package:bloc_concurrency/bloc_concurrency.dart'; (Unsupported import on DartPad) so I'll just copy it below.
@LiamKarlMitchell
LiamKarlMitchell / main.dart
Created March 4, 2023 10:33
Flutter Bloc Delayed Event Emit
// This code is distributed under the MIT License.
// Copyright (c) 2018 Felix Angelov.
// You can find the original at https://github.com/felangel/bloc.
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'dart:math';
var rng = Random();
@LiamKarlMitchell
LiamKarlMitchell / AddContentLengthLighthouse.php
Last active July 14, 2022 08:22
Adds content length to Lighthouse POST responses.
<?php
// Thanks to: https://laracasts.com/discuss/channels/general-discussion/add-content-length-header-on-views
// In relation to a bug for graphql code generator in an upstream dependency, I needed to add a Content-Length header.
// Temporary workaround for this.
// See: https://github.com/dotansimha/graphql-code-generator/issues/7934
// See: https://github.com/nodejs/undici/issues/1414
// https://github.com/nodejs/undici/issues/1490
namespace App\Http\Middleware;
@LiamKarlMitchell
LiamKarlMitchell / HealthChecks.sh
Created March 17, 2021 23:45
HealthChecks SH wrapper for Cron Job Notifications/Monitoring.
#!/bin/sh
# Author: Liam Mitchell
# Purpose: Wrap a cron command and ping HealthChecks.io
HEALTHCHECKS_UUID=$1
# Check number of arguments is at least 1 for the Health Checks UUID.
if [ -z "$1" ];
then
echo "Usage: `basename $0` HEALTHCHECKS_UUID command args..."
exit 65
@LiamKarlMitchell
LiamKarlMitchell / Singleton.cs
Created January 10, 2021 21:04
Useful Unity Scripts
using UnityEditor;
using UnityEngine;
namespace UnityTemplateProjects.Misc
{
/// <summary>
/// Inherit from this base class to create a singleton.
/// e.g. public class MyClassName : Singleton<MyClassName> {}
/// </summary>
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
@LiamKarlMitchell
LiamKarlMitchell / Magento2CheckProductImagesOnDisc.sh
Created December 23, 2020 00:14
Check Magento 2 product images on disc.
#!/bin/bash
# Checks if images referenced on products in the DB exist on disc and checks that they are not smaller than 300x300 px.
# Runnable in bash.
# Requirements.
# apk add bash mysql-client imagemagick
# I also had a regexp to get only _1 _2 etc in the query but have removed it now.
# AND g.value REGEXP '_[0-9].(jpg|png)$'
# You can also do a where condition such as WHERE e.sku IN ('A', 'B')
@LiamKarlMitchell
LiamKarlMitchell / leagueoflegendsminionsai.md
Last active June 11, 2020 08:25
League of Legends interesting things.

Archived from http://web.archive.org/web/20200308182225/https://boards.na.leagueoflegends.com/en/c/developer-corner/qRHotV9k-minion-ai-rules-documentation and converted to markdown/niceness to read.

Found archived topic on here: https://www.reddit.com/r/summonerschool/comments/99d6my/riot_minion_ai_behavior_documentation/

Hello! I’m Riot Reinboom and I’m here to drop some Sweet minion AI game documentation on you all.

What? We’re sharing our understanding of how a bunch of weird behaviors of how lane minions work internally and figured it would be informative for you all as well.

So, documentation. Exciting stuff.

@LiamKarlMitchell
LiamKarlMitchell / mysql-backup-windows.bat
Created November 17, 2019 04:04 — forked from sindresorhus/mysql-backup-windows.bat
Backup MySQL databases in separate gzipped sql files on Windows
@echo off
set dbUser=root
set dbPassword=password
set backupDir="C:\Documents and Settings\user\Desktop\backup\mysql"
set mysqldump="C:\Program Files\MySQL\MySQL Workbench 5.2 CE\mysqldump.exe"
set mysqlDataDir="C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data"
set zip="C:\Program Files\7-Zip\7z.exe"
:: get date
#!/bin/bash
SENDGRID_API_KEY="SG.YOUR_SENDGRID_API_KEY_HERE"
EMAIL_TO="someemail@work.co.nz"
FROM_EMAIL="SomeServer@work.co.nz"
FROM_NAME="SomeServer"
SUBJECT="Low Disk Space Email"
bodyHTML="<p>Testing sending email using sendgrid from sh.</p>"
maildata='{"personalizations": [{"to": [{"email": "'${EMAIL_TO}'"}]}],"cc":[{"email": "someccemail@work.co.nz"}],"from": {"email": "'${FROM_EMAIL}'",