Tagphp

My first PHP package: the Discord Table Builder

Something has been bothering me for a long time. I’ve got a ton of good, kind of modular PHP code, and I’ve failed to make time to publish any of it for a long time. But today, I published my first PHP package on Packagist. 😊

Discord Table Builder

For WhatPulse, we wanted to publish the weekly leaderboard on our Discord server for some community rivalry. But, the Discord API doesn’t have built-in support for tables or any easy way to format tabular data. I wanted something like this:

Discord table builder in action

After searching for an existing solution and coming up empty, … Read more

Exporting your Amazon Kindle Highlights & Notes to MySQL

As a wise man said; now for something completely different. This post is going to be just that.

I received a Amazon Kindle on christmas and absolutely love it. It has replaced hauling around a bunch of physical books and made my life a lot easier when it comes to managing highlights and notes about the topics in the books (I read a lot of educational text).

Previously I had a physical notebook with me that I translated into electronic notes by hand. I use Evernote for all my note taking purposes. With the Kindle, all your highlights and notes … Read more

Introducing the VMware NSX for vSphere PHP Framework

Over the last few weeks, I have been working on a VMware NSX integration with one of my existing PHP applications. This application is tied into a development process with a new testing schematic which needed to use a the NSX features to test the code inside a tiered network setup. Of course, this needed to be automated and available on demand; enter the NSX API. Using the NSX API, I’ve been able to integrate network deployment and configuration inside the existing application (with not a lot of effort).

After getting a few requests from fellow NSX enthusiasts, I’ve decided … Read more

PHP4 IPv6 validation

Incase you don’t have the luxury of PHP5’s filter_ functions, this is a handy regexp:

function validate_ipv6($ip)
{
$hex = ‘[A-Fa-f0-9]’;
$h16 = “{$hex}{1,4}”;
$dec_octet = ‘(?:25[0-5]|2[0-4]d|1dd|[1-9]d|[0-9])’;
$ipv4 = “$dec_octet.$dec_octet.$dec_octet.$dec_octet”;
$ls32 = “(?:$h16:$h16|$ipv4)”;
$ipv6 = “(?:(?:{$IPv4address})|(?:”.
“(?:$h16:){6}$ls32” .
“|::(?:$h16:){5}$ls32” .
“|(?:$h16)?::(?:$h16:){4}$ls32” .
“|(?:(?:$h16:){0,1}$h16)?::(?:$h16:){3}$ls32” .
“|(?:(?:$h16:){0,2}$h16)?::(?:$h16:){2}$ls32” .
“|(?:(?:$h16:){0,3}$h16)?::(?:$h16:){1}$ls32” .
“|(?:(?:$h16:){0,4}$h16)?::$ls32” .
“|(?:(?:$h16:){0,5}$h16)?::$h16” .
“|(?:(?:$h16:){0,6}$h16)?::” .
“)(?:/(?:12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9]))?)”;

$regex = “/^$ipv6$/”;
return preg_match($regex, $ip);
}

Read more

© 2024 Lostdomain

Theme by Anders NorénUp ↑