This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Return a normalized threshold value (floats are converted to ints) | |
* | |
* @param string $thresh The threshold specification | |
* @return string The normalized threshold | |
* @throws Exception In case of invalid format | |
*/ | |
function parse_threshold(string $thresh): string | |
{ | |
if (preg_match("/^[0-9]+$/", $thresh)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Rules; | |
use Closure; | |
use Illuminate\Contracts\Validation\ValidationRule; | |
use const FILTER_FLAG_IPV4; | |
use const FILTER_FLAG_IPV6; | |
use const FILTER_VALIDATE_INT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |