Skip to content

Instantly share code, notes, and snippets.

View N8-B's full-sized avatar

Nathan Burkiewicz N8-B

View GitHub Profile
@N8-B
N8-B / createXHR.js
Last active August 29, 2015 14:13
Create XHR function
// Function for creating an XHR object which is compatible in all browsers.
// This implementation is compatible with the original Internet Explorer version.
// So, it can be used to create an XHR object in any browser.
// Example usage:
// var xhr = createXHR();
// xhr.onreadystatechange = function() {
// if(xhr.readyState == 4) {
// if((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
// alert(xhr.responseText);
// } else {
@N8-B
N8-B / xhr-ie6.js
Last active August 29, 2015 14:13
XMLHttpRequest in IE6
// An alternative implementation to the createXHR function for creating
// an XHR object in all modern browsers as well as emulating IE5 and IE6.
if (window.XMLHttpRequest === undefined) {
window.XMLHttpRequest = function() {
try {
// Use the latest version of the ActiveX object if available
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
}
catch(e1) {
// Atom.io Synch Settings
@N8-B
N8-B / WPDM-login-fix.php
Last active September 4, 2015 06:24
Login Fix for Wordpress Download Manager
/**
* WooCommerce Account Page Login Fix for Wordpress Download Manager.
* Prevents wpdm_login hook from loading and fixes the conflict with WooCommerce login.
* Add this code to the functions.php file
**/
<?php
add_action('plugins_loaded','remove_wpdm_hook');
@N8-B
N8-B / html5_template.html
Created September 30, 2012 12:58 — forked from KennetPL/html5_template.html
HTML: Starting template
<!doctype html><!-- simplified doctype works for all previous versions of HTML as well -->
<!-- Paul Irish's technique for targeting IE, modified to only target IE6, applied to the html element instead of body -->
<!--[if lt IE 7 ]><html lang="en" class="no-js ie6"><![endif]-->
<!--[if (gt IE 6)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<!-- simplified character encoding -->
<meta charset="utf-8">
@N8-B
N8-B / padLeft.js
Last active June 18, 2016 17:21
padLeft - Function for padding strings on the left side
/**
* Pads `string` on the left side if it's shorter than `length`. Padding
* characters are truncated if they exceed `length`.
*
* @param {string} [string=''] The string to pad.
* @param {number} [length=0] The padding length.
* @param {string} [chars='0'] The string used as padding.
* @returns {string} Returns the padded string.
* @example
*
@N8-B
N8-B / remove-diacritics.js
Created November 23, 2016 20:35
Remove diacritics
var defaultDiacriticsRemovalMap = [
{'base':'A', 'letters':'\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F'},
{'base':'AA','letters':'\uA732'},
{'base':'AE','letters':'\u00C6\u01FC\u01E2'},
{'base':'AO','letters':'\uA734'},
{'base':'AU','letters':'\uA736'},
{'base':'AV','letters':'\uA738\uA73A'},
{'base':'AY','letters':'\uA73C'},
{'base':'B', 'letters':'\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181'},
{'base':'C', 'letters':'\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E'},
@N8-B
N8-B / gulpfile.js
Last active March 11, 2018 02:24
Gulp tasks for my Harp configuration and workflow. Automates, server, build and publish tasks.
var gulp = require('gulp');
var harp = require('harp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var deploy = require('gulp-gh-pages');
var cp = require('child_process');
var clean = require('gulp-rimraf');
/**
* Serve the Harp Site
@N8-B
N8-B / gist:4353531
Created December 21, 2012 15:40
Amazon s3 Bucket Policy for preventing hotlinking. Yes!
{
"Version": "2008-10-17",
"Id": "0c762de8-f56b-488d-a4a4-20d1cb31df2f",
"Statement": [
{
"Sid": "Allow in my domains",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},