Skip to content

Instantly share code, notes, and snippets.

View dennzo's full-sized avatar
🎯
Focusing

Dennis Barlowe dennzo

🎯
Focusing
View GitHub Profile
@dennzo
dennzo / run-oscap.sh
Last active April 17, 2024 13:09
oscap wrapper for rhel/centos machines
#!/bin/env bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# todo: pass email as argument, then this can also run regularly as cronjob to generate reports each serverino
# set bash settings
@dennzo
dennzo / run-server-investigator.sh
Last active April 23, 2024 12:35
Script to summarize Server information regarding Security concerns (for RHEL or CentOS)
#!/bin/env bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
FILE_PATH=/tmp/server-information.md
touch $FILE_PATH
@dennzo
dennzo / order-by-type-and-date.php
Last active December 11, 2023 06:10
usort - prioritize a specific type (always keep on top and order these by date) and the rest only by date
<?php
// Prepare data
$input = [
['type' => 'order_2', 'date' => new DateTimeImmutable('+2 days')],
['type' => 'order_3', 'date' => new DateTimeImmutable('+3 days')],
['type' => 'order_1', 'date' => new DateTimeImmutable('+1 days')],
['type' => 'order_7', 'date' => new DateTimeImmutable('+8 days')],
['type' => 'always_after_2', 'date' => new DateTimeImmutable('+105 days')],
@dennzo
dennzo / dump-plugins.php
Created July 26, 2023 19:47
Wordpress - Get CSV List of all Plugins
<?php
include_once ('wp-admin/includes/plugin.php');
echo "<pre>";
echo "Name;URL;Version;" . PHP_EOL;
foreach (get_plugins() as $plugin) {
echo $plugin['Name'] . ';';
echo $plugin['PluginURI'] . ';';
echo $plugin['Version'] . ';' . PHP_EOL;
}
echo "</code>";
@dennzo
dennzo / gist:dd66c69215fa646c100f18d3c90386f2
Last active July 26, 2023 08:09
phpstorm union return types (null|string instead of ?null)
// for velocity template (setters/getters)
#set( $longTypeHint = "$SCALAR_TYPE_HINT" )
#set( $longTypeHint = $longTypeHint.replace("?", "null|") )
@dennzo
dennzo / convert-woff-to-inline-base64.php
Last active March 22, 2023 22:01
PHP - convert woff files from google webfont helper to inline base64 css
<?php
// I know this is very ugly, but good enough for my use case.
// this is highly dependent on fonts from https://gwfh.mranftl.com/fonts/ because of the file names.
$files = glob(__DIR__ . '/fonts/*.woff');
foreach ($files as $file) {
$baseDirectory = pathinfo($file, PATHINFO_DIRNAME);
$fileName = basename($file);
@dennzo
dennzo / IPRestriction.php
Last active November 24, 2021 13:28
Restrict Things to specific IP's
<?php
namespace Dennzo\IPRestriction;
use Psr\Log\LoggerInterface;
/**
* Don't forget, this (the logging part) is not GDPR compliant, since the IP is logged fully.
* This should only be used for debugging purposes! If used in live environments the logging part should be commented or removed.
*
@dennzo
dennzo / style.css
Created November 15, 2020 15:24
CSS - HTML anchor offset
:target:before {
content: "";
display: none;
height: 120px; /* fixed header height*/
margin: -120px 0 0; /* negative fixed header height */
}
@dennzo
dennzo / ControllerTrait.php
Created November 13, 2020 14:44
Symfony - Automatic Serialization of Response to JSON with jms serializer
<?php
namespace App\Controller;
use InvalidArgumentException;
use JMS\Serializer\SerializerInterface;
use Psr\Container\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
@dennzo
dennzo / .env
Last active November 12, 2020 13:53
Symfony - Monolog - Passing ENV variables to monolog in a symfony environment
LOG_LEVEL=debug