Skip to content

Instantly share code, notes, and snippets.

View ptasker's full-sized avatar
:fishsticks:

Peter Tasker ptasker

:fishsticks:
View GitHub Profile
@ptasker
ptasker / redis.md
Last active April 27, 2023 14:35
Redis commands

Get all keys

keys *

Get all data for key

XRANGE "kl:stream:github.actions.v0.JobCanceledEvent:0" - +

Delete event/value at key

<?php
/**
* Returns uploads info for given subsite or primary site.
*
* @param int $blog_id Optional, defaults to primary.
*
* @return array
*
* NOTE: Must be run from primary site.
@ptasker
ptasker / rules.php
Created January 18, 2019 19:57
Wordfence firewall rules
<?php
if ( ! defined( 'WFWAF_VERSION' ) ) {
exit( 'Access denied' );
}
/*
This file is generated automatically. Any changes made will be lost.
*/
$this->failScores['sqli'] = 100;
$this->failScores['xss'] = 100;
@ptasker
ptasker / shelljs.js
Created November 29, 2017 19:19
Shell JS example
const shell = require( 'shelljs' );
shell.echo(
shell.cat('./src/wp-migrate-db-pro/wp-migrate-db-pro.php').grep( /.*\['version'] = '(.*)';/ )
.replace(/.*\['version'] = |'|;|\./g, '')
);
@ptasker
ptasker / backtick-function.js
Created November 23, 2017 18:48
Invoke function with backticks
const myfunc = () {
console.log('WAT');
}
myfunc``
// WAT
@ptasker
ptasker / kickvalet.sh
Created November 15, 2017 19:44
Kick Valet
#!/bin/sh
sudo brew services stop nginx
sudo brew services stop php71
sudo brew services stop dnsmasq
sudo brew services stop mysql
sudo brew services start nginx
sudo brew services start php71
sudo brew services start dnsmasq
sudo brew services start mysql
@ptasker
ptasker / zip-test.php
Created July 20, 2017 18:26
PHP Zip times
<?php
$PATH = '/your/folder/path';
//ZipArchive
//Test 1
$time_start = microtime( true );
@ptasker
ptasker / curl-test.php
Created July 20, 2017 13:50
Test PHP cURL connections to the DBI API
<?php
$url = 'https://api.deliciousbrains.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
$result = curl_exec($ch);
curl_close($ch);
@ptasker
ptasker / wp-remove-media.sh
Created May 11, 2017 18:01
WP CLI remove all media
#!/usr/bin/env bash
DIR="$1"
if [ -z "$1" ]
then
echo "Usage: $0 {WP install dir path}"
exit 1
fi
@ptasker
ptasker / pre-commit.sh
Created May 10, 2017 18:24
ESLint pre-commit hook
#!/bin/bash
lint=$(./node_modules/eslint/bin/eslint.js src/**.js $a)
echo $lint
if [[ "$lint" != *""* ]]; then
echo "ERROR: ESLint failed, check hints"
exit 1 # reject
fi