Skip to content

Instantly share code, notes, and snippets.

View nbish11's full-sized avatar

Nathan nbish11

View GitHub Profile
@nbish11
nbish11 / example1.php
Created May 28, 2022 09:30
Removing reliance on nulls in PHP
<?php
declare(strict_types=1);
// IMPLEMENTATION using DDD...
final class ItemIdentity
{
public function __construct(public readonly int $number) {}
public function equals(self $other): bool
{
@nbish11
nbish11 / pollDom.js
Last active September 18, 2016 05:56
Promise based DOM poller.
/**
* Poll the DOM until a condition has been met, or a timeout occurs.
* @copyright 2016 Nathan Bishop
* @license MIT http://choosealicense.com/licenses/mit/
* @param {Number} timeout How long to poll the dom for, in milliseconds.
* @param {Function} condition The condition to test for. Must return a boolean.
* @return {Promise} A `Promise` object.
*/
function pollDom(timeout, condition) {
var expiry = Date.now() + Number(timeout);
@nbish11
nbish11 / $$.js
Last active August 29, 2015 14:14
/**
* The "Double Dollar" function - version 1.1.1 - 16/06/15
*
* Copyright (c) 2015 Nathan Bishop
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@nbish11
nbish11 / README.md
Last active August 29, 2015 14:12 — forked from jonathantneal/README.md

EventListener Polyfill

Is IE8 your new IE6? Level the playing field with polyfills.

This script polyfills addEventListener, removeEventListener, and dispatchEvent. It is less than half a kilobyte minified and gzipped.

addEventListener

addEventListener registers a single event listener on a single target.

<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@nbish11
nbish11 / $.js
Last active August 29, 2015 13:59
The "Dollar" function.
/**
* The "Dollar" function - version 0.2.0 - 06/02/15
*
* Copyright (c) 2014 Nathan Bishop
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@nbish11
nbish11 / .htaccess
Created September 18, 2013 03:55
Advanced Redirect: Pass the requested path to index.php.
## Advanced Redirect
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
@nbish11
nbish11 / .htaccess
Created September 18, 2013 03:50
Simple Redirect: If a file or folder does not exist, redirect to index.php.
## Simple Redirect
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]