Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Newton miken32

View GitHub Profile
@miken32
miken32 / Cidr.php
Last active Jun 5, 2020
Laravel CIDR validation rule
View Cidr.php
<?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 (http://www.gnu.org/copyleft/gpl.html)
// @include https://stackoverflow.com/*
// @include https://serverfault.com/*
// @include https://superuser.com/*
View PHP 7.0 PEAR MacPorts install
#!/bin/bash
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
#!/bin/bash
xml_head='<?xml version="1.0" charset="utf-8" standalone="yes"?>\n<directory>\n<itemlist>'
xml_tail='</itemlist>\n</directory>'
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
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
<?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.
You can’t perform that action at this time.