Skip to content

Instantly share code, notes, and snippets.

View CJ-Hurc's full-sized avatar

Chris CJ-Hurc

View GitHub Profile
@dg
dg / html.regex
Last active April 9, 2025 23:22
Regular expression for parsing HTML
~
(?(DEFINE)
(?<entity>
&
(
[a-z][a-z0-9]+ # named entity
|
\#\d+ # decimal number
|
<?php
// INTERFACES
interface WriterFactory
{
public function createCsvWriter(): CsvWriter;
public function createJsonWriter(): JsonWriter;
}
@vielhuber
vielhuber / HOWTO.md
Last active April 5, 2025 08:02
pwa progressive web apps service worker add to home push notifications #js

add to head

<!-- pwa -->
<link rel="manifest" href="_pwa/manifest.json" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="_pwa/icon-192x192.png" />
<script>
  	// register service worker
    window.addEventListener('load', () => {
@vijinho
vijinho / memoize.php
Created October 30, 2017 22:26
php memoize()
<?php
// https://www.youtube.com/watch?v=M3_xnTK6-pA?t=44m18s
// http://eddmann.com/posts/implementing-and-using-memoization-in-php/
//$memoize = function ($function) {
function memoize($function) {
return function () use ($function) {
static $cache = [];
$args = func_get_args();
$key = md5(serialize($args));
if (empty($cache[$key])) {
@coolaj86
coolaj86 / sms-for-free.md
Last active June 19, 2022 03:48
Send text messages for free via email via xminder cell phone carrier lookup
@zaus
zaus / FormRepo.js
Last active January 13, 2023 01:38
Preserve form values across page loads -- i.e. persistent forms. Uses `localStorage` to persist, `jQuery` for utilities.
var FormRepo = function (namespace) {
/// <summary>Persistent form values, saves to localStorage</summary>
/// <param name="namespace" type="String">the namespace to store values in localStorage</param>
// should also protect per page, since we could have the same forms in various places
this.N = namespace + '.' + window.location.pathname;
};
$.extend(FormRepo.prototype, {
namespace: function (key) {
return this.N + '.' + key;
@Jamesking56
Jamesking56 / ErrorHandler.class.php
Created November 10, 2012 20:57
PHP: Simple PHP error handler with extra features.
<?php
/*
ErrorHandler Class
By James King
v0.1 Alpha
WARNING: This class is still in ALPHA phase. Not recommended for production.
Manages and handles any PHP errors found in your script.
@mindplay-dk
mindplay-dk / migrator.php
Created June 16, 2012 19:11
Migrate a PHP codebase to use namespaces.
<?php
/**
* Namespace Migration Script
*
* @author Rasmus Schultz <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*
* This script will scan through an entire PHP codebase and rewrite the
* scripts, adding a namespace clause based on the directory structure,