Skip to content

Instantly share code, notes, and snippets.

View mallardduck's full-sized avatar
🦑
Rockin the suburbs

Dan mallardduck

🦑
Rockin the suburbs
View GitHub Profile
@mallardduck
mallardduck / static.php
Created November 19, 2021 15:34 — forked from ezimuel/static.php
Swoole HTTP static file server example
<?php
// Simple HTTP static file server using Swoole
$host = $argv[1] ?? '127.0.0.1';
$port = $argv[2] ?? 9501;
$http = new swoole_http_server($host, $port);
// The usage of enable_static_handler seems to produce errors
// $http->set([
@mallardduck
mallardduck / SomeResource.php
Created April 23, 2021 16:17
SpatieTagsInput for filament
public static function form(Form $form)
{
return $form
->schema([
SpatieTagsInput::make('form_tags')
->relationship('tags', 'name')
]);
}
@mallardduck
mallardduck / TextFileStream.php
Last active December 15, 2020 05:08
TextFileStream - An implementation of the Parsica Stream interface for text files.
<?php
namespace MallardDuck\ConfigParser;
use Verraes\Parsica\Internal\EndOfStream;
use Verraes\Parsica\Internal\Position;
use Verraes\Parsica\Internal\TakeResult;
use Verraes\Parsica\Stream;
class TextFileStream implements Stream
@mallardduck
mallardduck / checkSession.php
Last active March 27, 2020 01:33 — forked from lukas-buergi/checkSession.php
Check whether sessions work in php
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1);
define('TEST_KEY', 'test');
define('TEST_VAL', 'test42');
$fileName = basename(__FILE__);
@mallardduck
mallardduck / email_jail
Last active February 15, 2020 23:09
An Exim System Filter to create a Domain Jail for Emails
# Block example.com from sending to any other domain
if first_delivery
and ("$h_from:" contains "@example.com")
and ("$h_to:" matches "@(?!example.com)[a-z0-9_.]+")
or ("$h_cc:" matches "@(?!example.com)[a-z0-9_.]+")
or ("$h_bcc:" matches "@(?!example.com)[a-z0-9_.]+")
then
headers add "X-Org-Subject: $h_subject"
headers remove Subject
headers add "Subject: EmailJail'd: $h_x-org-subject"
@mallardduck
mallardduck / functions-mu-encryption.php
Created April 24, 2019 14:21 — forked from muhammad-naderi/functions-mu-encryption.php
Wordpress encrypt usermeta data database
<?php
/**
* Created by PhpStorm.
* User: Muhammad
* Date: 05/07/2016
* Time: 01:20 PM
*/
add_filter('get_user_metadata', 'decrypt_user_meta',10,4);
@mallardduck
mallardduck / XhguiValetDriver.php
Created December 11, 2018 16:41
A valet driver for the Xhgui tool
<?php
class XhguiValetDriver extends BasicValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@mallardduck
mallardduck / OutputPrefixTrait.php
Last active October 18, 2018 20:56
A PHP trait for use in Laravel console commands to enable output prefixing via a command flag. Uses the `time()` a command starts at to add a unique identifier for distinguishing each invocation in logs.
<?php
namespace App\Console\Commands;
trait OutputPrefixTrait
{
/**
* The string used to prefix command output.
*
@mallardduck
mallardduck / bay-thumb.svg
Last active July 10, 2018 13:46
Statewide Regions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mallardduck
mallardduck / php-serenata.sh
Created May 28, 2018 22:27
A simple bash script that ensures Xdebug is not loaded. May only work on Arch Linux as PHP configurations are OS dependant.
#!/usr/bin/env bash
`which php` -n \
-c /etc/php/php.ini \
"$@";