Skip to content

Instantly share code, notes, and snippets.

@simshaun
simshaun / cf.ps1
Created November 14, 2023 06:31
PowerShell script to set up CloudFlare redirect domains in bulk. Use at own risk.
# Cloudflare API credentials
$email = "AAAAAAAA"
$apiKey = "BBBBBBBB"
# List of domains to be created
$domains = @(
"example.com",
"example2.com"
)
@simshaun
simshaun / profile.ps1
Last active August 6, 2021 19:18
PowerShell git skip-worktree aliases
<#
Command: gitskipped
Description: List skipped files in git
Usage: gitskipped
#>
function gitskipped {
(git ls-files -v $args) -split "\r\n" | Select-String -Pattern '^S ' | ForEach-Object {
Write-Output $_.Line.Substring(2)
}
}
@simshaun
simshaun / profiles.json
Last active April 9, 2020 20:07
Windows Terminal settings
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
//
// Fonts:
// https://github.com/microsoft/cascadia-code/releases
//
// NOTE: To theme PowerShell:
// https://lazyadmin.nl/powershell/customizing-windows-terminal
// https://www.hanselman.com/blog/HowToMakeAPrettyPromptInWindowsTerminalWithPowerlineNerdFontsCascadiaCodeWSLAndOhmyposh.aspx
// Install Cascadia Code PL font
@simshaun
simshaun / script.ahk
Last active August 16, 2019 19:58
AutoHotKey script that makes Ctrl+Shift+T create a new file while in Windows Explorer
; Ctrl + Shift + T //// When Windows Explorer active, create new file
#IfWinActive, ahk_exe Explorer.EXE ahk_class CabinetWClass
^+t::
WinGetTitle, currentWinTitle, A
if InStr(currentWinTitle, "\") ; If the full path is displayed in the title bar (Folder Options)
currentPath := currentWinTitle
else if InStr(currentWinTitle, ":") ; If the title displayed is something like "DriveName (C:)"
{
currentPath := SubStr(currentWinTitle, -2)
currentPath := SubStr(currentPath, 1, -1)
@simshaun
simshaun / gist:b93ddef48a9c5ab1b697c0ef6051eb3b
Created July 18, 2019 18:50
Stylus browser extension stylesheet — "Checkerboard" when viewing PNGs
/*
* Stylus "Applies to" rule:
* URLs matching the regexp .*\.png
*
* Tested in Firefox and Edge Dev (Chromium)
*/
body {
background:
linear-gradient(45deg, #eee 25%, transparent 25%),
@simshaun
simshaun / Reddit.user.js
Created December 1, 2018 06:29
Greasemonkey/Violentmonkey Userscript to force redirect to https://old.reddit.com
// ==UserScript==
// @name Reddit redirect to old.reddit.com
// @match *://www.reddit.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function () {
window.location.href = 'https://old.reddit.com' + location.pathname;
})();
@simshaun
simshaun / CurrentUserProvider.php
Last active July 24, 2019 17:58
Decoupling App User entity from Symfony Security User. Public props and clipped methods for brevity.
<?php
# src/DataProvider/CurrentUserProvider.php
namespace App\DataProvider;
use App\Entity\User;
use App\Repository\UserRepository;
use App\Security\SecurityUser;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@simshaun
simshaun / CommentNormalizer.php
Created November 9, 2018 08:35
API Platform custom normalizer for object constructor arguments
<?php
// src/Serializer/CommentNormalizer.php
namespace App\Serializer;
use App\DataProvider\CurrentUserProvider;
use App\Entity\Comment;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
@simshaun
simshaun / gist:c982001e4ac5f1d4aa5fe6dbe3d14a57
Created September 28, 2018 18:17
IE11 devtools - add/reload a stylesheet
var existingLink = document.querySelector('link[data-custom-css]');
if (existingLink) { existingLink.parentNode.removeChild(existingLink); }
var link = document.createElement('link');
link.setAttribute('data-custom-css', '1');
link.rel = 'stylesheet';
link.href = '/xxxxxxxxxxxxxxxxxxxxxxxx.css?'+Math.floor(Math.random()*10000);
document.querySelector('head').appendChild(link);
@simshaun
simshaun / Netflix.user.js
Last active December 10, 2017 01:45
Greasemonkey / Violentmonkey userscript to stop Netflix from loading video in the hero area of the browse page.
// ==UserScript==
// @name Netflix /browse hero video preventer
// @author Shaun
// @namespace Violentmonkey Scripts
// @match *://*.netflix.com/browse
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
let observers = [];