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 / LimitedErrorActivationStrategy.php
Last active August 8, 2023 09:38
Monolog activation strategy to ignore 403, 404, and 405 errors
<?php
namespace Acme\Monolog;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Symfony\Component\HttpKernel\Exception\HttpException;
class LimitedErrorActivationStrategy extends ErrorLevelActivationStrategy
{
public function __construct()
@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 / 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 / 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 / gist:7592631
Created November 22, 2013 00:37
TinyMCE 4.0.11 - Automatically remove width and height attributes from img elements inserted via the img plugin
setup: function (editor) {
editor.on('init', function(args) {
editor = args.target;
editor.on('NodeChange', function(e) {
if (e && e.element.nodeName.toLowerCase() == 'img') {
tinyMCE.DOM.setAttribs(e.element, {'width': null, 'height': null});
}
});
}
@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 / 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;