Skip to content

Instantly share code, notes, and snippets.

View rolandtoth's full-sized avatar

Roland Toth Pal rolandtoth

View GitHub Profile
@eligrey
eligrey / insertAdjacentHTML.js
Created October 10, 2011 18:06
insertAdjacentHTML polyfill
/*
* insertAdjacentHTML.js
* Cross-browser full HTMLElement.insertAdjacentHTML implementation.
*
* 2011-10-10
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@cjthompson
cjthompson / arrayDifference.php
Last active April 7, 2024 00:30
PHP: Compare two arrays and find the differences between them. Supports items that are arrays by serializing them for comparison. Returns an array of insertions (only in the second array) and deletions (only in the first array).
<?php
/**
* Compare two arrays and return a list of items only in array1 (deletions) and only in array2 (insertions)
*
* @param array $array1 The 'original' array, for comparison. Items that exist here only are considered to be deleted (deletions).
* @param array $array2 The 'new' array. Items that exist here only are considered to be new items (insertions).
* @param array $keysToCompare A list of array key names that should be used for comparison of arrays (ignore all other keys)
* @return array[] array with keys 'insertions' and 'deletions'
*/
public static function arrayDifference(array $array1, array $array2, array $keysToCompare = null) {
@tlongren
tlongren / example.php
Last active December 23, 2020 13:32
PHP Clean URL (SLUG) Generator
<?php
$slug = slugit("thank you for visiting");
echo $slug;
// returns: thank-you-for-visiting
?>
@dciccale
dciccale / README.md
Last active May 22, 2018 09:14
Cross-browser triggerEvent function done with 127 bytes of JavaScript

triggerEvent

Cross-browser function to trigger DOM events.

@hofmannsven
hofmannsven / README.md
Last active May 3, 2024 15:30
Git CLI Cheatsheet
@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
})
@Robyer
Robyer / live-form-validation.js
Last active July 27, 2021 14:39 — forked from pavelplzak/live-form-validation.js
Live Form Validation for Nette 2.3
Source moved to: https://github.com/Robyer/nette-live-form-validation
@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active February 23, 2024 04:30
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');
@abbotto
abbotto / polyfill.insertAdjacentHTML.js
Last active April 27, 2018 08:39
polyfill.insertAdjacentHTML.js
/*!
* polyfill.insertAdjacentHTML.js
* Author: Jared Abbott
* Description: A Cross-browser implementation of HTMLElement.insertAdjacentHTML
* Copyright 2015 Jared Abbott
* Distributed under the MIT license
*/
if (!("insertAdjacentHTML" in document.createElementNS("http://www.w3.org/1999/xhtml", "_"))) {
HTMLElement.prototype.insertAdjacentHTML = function(position, html) {
@adamreisnz
adamreisnz / package.json
Last active January 19, 2024 13:01
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",