Skip to content

Instantly share code, notes, and snippets.

@axeloz
axeloz / Generate Image Placeholder
Last active January 17, 2024 16:52
This function creates a placeholder preview image that shows original image dominant colors. Easy to use with a small and storable `data:image/gif` base64 string. Check comments for a screenshot of the ending result.
<html>
<body>
<img
width="300"
src="data:image/gif;base64,<?php echo generateImagePreview('./image/myimage.png'); ?>"
/>
<!--
THIS IS THE ACTUAL SIZE OF THE BASE64 USED TO DISPLAY THE IMAGE. SHORT ENOUGHT TO BE STORED INTO A DATABASE FIELD
@axeloz
axeloz / .drone.yml
Last active November 2, 2022 07:44
DroneCI Laravel app Back and Front Testing and Deployment
#####
#
# Because it took me a sh*tload of time to make this work (and I mean it), I'm sharing with you my config file.
# There aren't that many .drone.yml samples around working with PHP / Laravel / MySQL ...
# So I had to do everything from scratch. Hope you'll find this useful
#
#####
#
# DroneCI (https://www.drone.io) is an open source CI/CD written in Go. It comes with a server and a runner started in Docker containers
# The following pipelines are:
[{{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ commit.branch }} - {{ truncate commit.sha 8 }})
@axeloz
axeloz / romanToArabic.php
Last active June 25, 2022 14:17
Simple PHP function to convert Roman numbers to Arabic numbers
<?php
/**
* ROMAN TO ARABIC NUMBERS
* @author Axel @mabox.eu
* @param string $input
* @return int
*/
function romanToArabic(String $input):int {
@axeloz
axeloz / checkconnection
Created November 11, 2021 23:19
Script used to monitor the VPN Tunnel for Transmission
#!/usr/bin/php
<?php
#################
# SOME SETTINGS #
#################
/**
* You must either define the PUBLIC_IPV4 constant if you have a static address
@axeloz
axeloz / checkDisposableEmail.php
Last active June 25, 2022 14:09
Check whether email address is temporary (disposable) using MX check (best option)
<?php
/**
* This function checks whether the email address
* is a temporary email address
* @param string $email The email address to check
* @return boolean
*/
function isTemporaryAddress(String $email):bool {
// TODO: that should maybe stored elsewhere
@axeloz
axeloz / PHPTreeFormatter.md
Last active November 6, 2017 11:10
PHP method to display a nicely formatted tree with levels and sublevels and clean HTML output

PHP Tree formatter

This Gist provides a PHP function used for displaying nicely formatted tree using CSS only. It supports multiple levels (no limit).

The HTML output is clean and indented. For example :

<ul class="tree level-0">
	<li class="folder">John: <span class="comment">John's home directory</span>
		<ul class="level-1">