Skip to content

Instantly share code, notes, and snippets.

@jonnott
jonnott / Cidr.php
Created June 12, 2023 13:16 — forked from miken32/Cidr.php
Laravel CIDR validation rule
<?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;
@jonnott
jonnott / strictmode.php
Created April 14, 2019 09:47
mysql-strictmode
<?
include "common.inc.php";
include "header.inc.php";
?>
<h2>MySQL Strict Mode Column Compatiblility</h2>
<?
$r_resultTables = dbQuery("SHOW TABLES");
echo '<textarea style="width: 95%; height: 80vh;">';
while ($a_rowTable = dbFetchRow($r_resultTables)) {
# with symlink following
grep -r -n "match" . --include "*.php"
# no symlink following
find . -name "*.php" -exec grep -n -H "match" {} \;
# files without match
find . -name "*.php" -exec grep -L "match" {} \;
@jonnott
jonnott / shorthand async google analytics code.js
Last active October 5, 2015 21:48
shorthand async google analytics code
var _gaq=[['_setAccount','UA-XXXXXX-X'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'));
@jonnott
jonnott / gist:2663318
Created May 12, 2012 00:28
mediaAliases
<head>
<!-- using meta tags? -->
<meta name="mediaalias:mobile" content="min-width: 300px" />
<meta name="mediaalias:tablet" content="min-width: 600px, min-device-pixel-ratio: 1.5" />
<!-- or a new element altogether -->
<media alias="mobile" query="min-width: 300px" />
<media alias="tablet" query="min-width: 600px, min-device-pixel-ratio: 1.5" />
</head>
<!-- what's the easiest way to do this w/o jQuery? -->