Skip to content

Instantly share code, notes, and snippets.

View simonrjones's full-sized avatar

Simon R Jones simonrjones

View GitHub Profile
@simonrjones
simonrjones / hash_examples.php
Created April 26, 2024 07:07
Output example hashed values from different hash algorithms
array_walk(hash_algos(), function($algo) {
echo $algo . ': ' . hash($algo, 'TEST123') . PHP_EOL;
});
@simonrjones
simonrjones / .gitignore
Last active August 5, 2022 10:00
Global gitignore settings.
# Standard ignore rules
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Keybase proof

I hereby claim:

  • I am simonrjones on github.
  • I am simonrjones (https://keybase.io/simonrjones) on keybase.
  • I have a public key ASByeWwYfViAGNL4E1h9deMit0iU4VK6gVWdiCyoR9SaRAo

To claim this, I am signing this object:

@simonrjones
simonrjones / Get package version
Created April 16, 2021 19:05
Return package version dynamically from Composer 2
<?php
declare(strict_types=1);
namespace MyNamespace;
use Composer\InstalledVersions;
/**
* Simple class to return package version from Composer 2
@simonrjones
simonrjones / gist:8783515
Created February 3, 2014 13:09
Sub-modules in Zend Framework. See blog post at http://simonrjones.net/2010/06/sub-modules-in-zend-framework/
<?php
/**
* Studio 24 Application
*
* @category Studio 24
* @package S24_Application
* @copyright Copyright (c) 2009-2010 Studio 24 Ltd (www.studio24.net)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @author Simon R Jones <simon@studio24.net>
* @version 1.1
function excerpt(string $string, $length = 50): string
{
$string = explode("\n", wordwrap($string, $length));
return (string) $string[0];
}
@simonrjones
simonrjones / rename_db
Last active May 11, 2018 10:32
Shell script to rename a database, based on https://www.percona.com/blog/2013/12/24/renaming-database-schema-mysql/ - Please note you need to ensure you have access to MySQL via your ~/.my.cnf file
#!/bin/bash
# Copyright 2013 Percona LLC and/or its affiliates
# @see https://www.percona.com/blog/2013/12/24/renaming-database-schema-mysql/
set -e
if [ -z "$3" ]; then
echo "rename_db <server> <database> <new_database>"
exit 1
fi
db_exists=`mysql -h $1 -e "show databases like '$3'" -sss`
if [ -n "$db_exists" ]; then
<h1 data-wp-block="h1">My title</h1>
<p data-wp-block="p">Some text</p>
<div data-wp-block="custom-collapsable" class="faqs-component">
<ul class="accordion">
<li data-wp-block-item="1" class="accordion-navigation active">
<a data-wp-block-field="title" aria-expanded="true" href="#panel691">My FAQ question title here</a>
<div data-wp-block-field="contents" id="panel691" class="content active">
<ul>
@simonrjones
simonrjones / security-scanning
Last active October 17, 2016 15:48
Series of shell commands to help detect a PHP security exploit
# Find all Apache-owned PHP files
find /var/www -user apache -type f -name '*.php' > suspicious_files.txt
# Find all non-binary files owned by Apache that are not named .php but contain PHP parser tags
find /var/www -user apache -type f -not -name '*.php' | xargs egrep -ilI "(<\?php|<\?=|<\? *(?!(xml)))" > suspicious_files2.txt
# Find all files containing PHP parser tags in global tmp folder
egrep -ilIr "(<\?php|<\?=|<\? *(?!(xml)))" /tmp > suspicious_files3.txt
# You can inspect all the PHP files for certain strings to find potentially dodgy code. Yes, they often contain the word hack!
#!/bin/bash
# Copyright 2013 Percona LLC and/or its affiliates
# @see https://www.percona.com/blog/2013/12/24/renaming-database-schema-mysql/
set -e
if [ -z "$3" ]; then
echo "rename_db <server> <database> <new_database>"
exit 1
fi
db_exists=`mysql -h $1 -e "show databases like '$3'" -sss`
if [ -n "$db_exists" ]; then