Skip to content

Instantly share code, notes, and snippets.

View toggenation's full-sized avatar

James McDonald toggenation

View GitHub Profile
@toggenation
toggenation / TurnOffSmartQuotes.php
Created September 9, 2024 00:14
Plugin to turn off Wordpress smart quotes
<?php
/*
Plugin Name: TurnOffSmartQuotes
Plugin URI:
Description: Stops WordPress from converting your quote symbols into smartquotes. The three lines below stop the smartquote conversion in 1) your post content, 2) your comments, and 3) your post excerpts.
Version: 0.1
Author: Katja Stokley
Author URI:
*/
remove_filter('the_content', 'wptexturize');
@toggenation
toggenation / .bashrc
Last active April 21, 2024 21:32
Start ssh-agent
# add to ~/.bashrc
# checks for the ssh-agent running as the current user and starts it if not
# SSH Agent should be running, once
runcount=$(ps -ef | grep "ssh-agent" | grep ^`whoami` | grep -v "grep" | wc -l)
if [ $runcount -eq 0 ]; then
echo Starting SSH Agent
eval $(ssh-agent -s)
fi
@toggenation
toggenation / pre-commit
Created April 21, 2024 06:47 — forked from mariovalney/pre-commit
Pre-commit hook to check code with PHPCS, fix with PHPCBF and check mess with PHPMD
#!/bin/sh
#########################
# #
# Initializing #
# #
#########################
##
# You should add all tools as composer dependencies or change this path
@toggenation
toggenation / check_phpseclib3_supported_client_algorithms.php
Last active February 12, 2024 21:44
A script to print phpseclib3 supported client algorithms
<?php
include './vendor/autoload.php';
use phpseclib3\Net\SFTP;
$sftp = new SFTP('localhost');
$methods = [
"getSupportedCompressionAlgorithms",
@toggenation
toggenation / software_assistant_backup.ps1
Last active February 11, 2024 21:40
Running 7-zip using Powershell
# Use 7zg.exe for GUI or just 7z.exe for none
$7zipPath = "$env:ProgramFiles\7-Zip\7zg.exe"
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
throw "7 zip file '$7zipPath' not found. Contact Toggen"
}
Set-Alias Start-SevenZip $7zipPath
$Source = "$env:ProgramData\Software Assistant\Assistant\Data"
@toggenation
toggenation / README.md
Last active October 17, 2023 20:02 — forked from magnetikonline/README.md
Creating a 'run once' systemd unit.
@toggenation
toggenation / UpdateCounterCacheCommand.php
Last active April 19, 2022 00:08 — forked from chopstik/UpdateCounterCachesShell.php
CakePHP Command to make use of UpdateCounterCache.php
<?php
declare(strict_types=1);
namespace App\Command;
use Cake\Command\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
@toggenation
toggenation / UpdateCounterCache.php
Created April 19, 2022 00:06 — forked from hmic/UpdateCounterCache.php
Cake3 update counter caches for association
<?php
namespace App\Model\Table\Behavior;
trait UpdateCounterCacheTrait {
public function cleanupBelongsToMany($return_count = null) {
if($return_count) {
return $count;
}
return $this;
@toggenation
toggenation / mysql_workbench_to_php_array_converter.php
Last active April 2, 2022 11:47 — forked from ilmarin/mysql_workbench_to_php_array_converter.php
Mysql Workbench "Copy row (with names)" to PHP array format converter
<?php
// this is my cludge to use phinx with CakePHP 2
// bootcake is webroot/index.php copied and the Dispatcher call removed:
// comment out the following in bootcake.php (which is a copy of webroot/index.php)
// loading this gets you the ability to us App::uses to load the model you need
// // App::uses('Dispatcher', 'Routing');
// // $Dispatcher = new Dispatcher();
@toggenation
toggenation / UpdateCounterCache.php
Last active November 8, 2020 22:37 — forked from chopstik/UpdateCounterCache.php
CakePHP 4 update counter caches for association
<?php
declare(strict_types=1);
namespace App\Model\Table\Traits;
use Cake\ORM\Query;
trait UpdateCounterCacheTrait
{
/**