Skip to content

Instantly share code, notes, and snippets.

@adactio
adactio / aria-controls.js
Last active March 8, 2024 07:07
Show and hide content with "aria-controls" buttons.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.addEventListener) {
// doesn't cut the mustard.
return;
}
var toggles = doc.querySelectorAll('[aria-controls]');
var togglecount = toggles.length;
@miwebguy
miwebguy / validymd.php
Last active August 29, 2015 14:09
Check Valid Y-m-d
<?php
/**
* Check for Valid Date Entry
*/
public function validDateString($datestring)
{
if(!preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$datestring)
|| date("Y-m-d", strtotime($datestring))!=$datestring)
return false;
else
@miwebguy
miwebguy / number-input-validation.html
Last active August 29, 2015 13:58
Use Pattern for Firefox input[type=number] support.
<input id="HoursEntry"
name="hours"
type="number"
pattern="[-+]?[0-9]*[.]?[0-9]+"
value="${hours}"
maxlength="5"
size="5" />
@joyrexus
joyrexus / README.md
Last active May 3, 2024 10:41 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@adriengibrat
adriengibrat / l.php
Last active January 22, 2024 14:45
Extreme minification of shortest possible PSR-0 compliant autoloader, 5 lines !
<?php
//set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__); // optional
spl_autoload_register(function ($class) {
$file = preg_replace('#\\\|_(?!.+\\\)#','/', $class) . '.php';
if (stream_resolve_include_path($file))
require $file;
});
@jbroadway
jbroadway / Slimdown.md
Last active February 5, 2024 10:43
Slimdown - A simple regex-based Markdown parser.
@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})