Skip to content

Instantly share code, notes, and snippets.

miken32 / Cidr.php
Last active Jul 8, 2022
Laravel CIDR validation rule
View Cidr.php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Cidr implements Rule
* Create a new rule instance.
View acceptrate.user.js
// ==UserScript==
// @name Accept Rate
// @version 0.5
// @description Display a user's Stack Exchange question accept rate
// @namespace k0tFZXXD
// @author Michael Hampton, Michael Newton
// @license GNU GPL v3 or later (
// @include*
// @include*
// @include*
View PHP 7.0 PEAR MacPorts install
sudo port install php-PEAR
# update PATH to include /opt/local/lib/php/pear/bin
pear config-set php_bin /opt/local/bin/php
pear config-set bin_dir /opt/local/lib/php/pear/bin/
pear config-set doc_dir /opt/local/lib/php/pear/docs/
pear config-set ext_dir /opt/local/lib/php
pear config-set ext_dir /opt/local/lib/php70/
View Create Polycom directory from FreePBX
xml_head='<?xml version="1.0" charset="utf-8" standalone="yes"?>\n<directory>\n<itemlist>'
mysql -N -D asterisk -e 'SELECT name, extension FROM users ORDER BY extension' | \
awk -F"\t" -v "xh=$xml_head" -v "xt=$xml_tail" '
BEGIN {print xh}
{printf ("<item><fn>%s</fn><ln>%s</ln><ct>%d</ct></item>\n", substr($1,0,index($1," ")-1), substr($1,index($1," ")+1), $2)}
END {print xt}'
miken32 / BlockCheck.class.php
Last active May 10, 2017
Verify if all characters of a string belong to a given Unicode character block
View BlockCheck.class.php
* BlockCheck 1.0
* Copyright (C) 2017 Michael Newton
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.