Skip to content

Instantly share code, notes, and snippets.

@arsonus
arsonus / storagePolyfill.js
Created May 10, 2016 18:38 — forked from jarrodirwin/storagePolyfill.js
LocalStorage/SessionStorage Polyfill with Safari Private Browsing support.
// Refer to https://gist.github.com/remy/350433
try {
// Test webstorage existence.
if (!window.localStorage || !window.sessionStorage) throw "exception";
// Test webstorage accessibility - Needed for Safari private browsing.
localStorage.setItem('storage_test', 1);
localStorage.removeItem('storage_test');
} catch(e) {
(function () {
var Storage = function (type) {
@arsonus
arsonus / mime_content_type.php
Created May 9, 2016 23:47
PHP mime_content_type() adapter.
/**
* mime_content_type
* Check for the PHP function and define if it isn't available.
*
* @param f The file name for which to determine MIME type
* @return A standard MIME type string: genus/species
*/
if( function_exists( 'mime_content_type' ) == false ) {
if( function_exists( 'finfo_file' ) == true ) {
function mime_content_type( $f ) {
@arsonus
arsonus / gist:903b03f0c53404127cacb134427dbecd
Created April 25, 2016 22:29 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@arsonus
arsonus / umd-script-boilerplate.js
Last active March 20, 2016 14:19 — forked from cferdinandi/umd-script-boilerplate.js
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@arsonus
arsonus / formatDate.js
Created March 7, 2016 04:09 — forked from cstipkovic/formatDate.js
A simple format Date function using Javascript prototype
/*
Based on Rick Strahl code
http://www.west-wind.com/weblog/posts/2008/Mar/18/A-simple-formatDate-function-for-JavaScript
Contributors:
Clauber Stipkovic - @clauberhalic
Mário Rinaldi - @MarioRinaldi
*/
Date.prototype.formatDate = function (format) {
@arsonus
arsonus / rebuld_nginx_with_pagespeed.sh
Created March 2, 2016 21:03 — forked from gottaloveit/rebuld_nginx_with_pagespeed.sh
This is a script for Debian/ Ubuntu that will rebuild the latest Nginx deb package from nginx.org with Google Pagespeed. There are a couple other modules the script will prompt you to ask if you want to remove them. They are http-dav, http-flv, http-mp4, mail, mail_ssl. Will prompt to add http-geoip and ask if you want to change the nginx user t…
#!/bin/bash
echo "This script will rebuild a Debian style package (deb) of latest stable"
echo "Nginx. The original deb is from nginx.org apt repository."
echo
echo "This will prompt you yes or no on a few changes to the build as well as"
echo "it will compile and package the latest Google NGX Pagespeed module."
echo
echo "This is built and tested on Ubuntu 14.04 LTS, fresh OS install."
echo "There are no guarantees, and I take no liability if it breaks, but it"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Using AlloyEditor as an Angular directive</title>
<style type="text/css">
.container {
margin-left: 30px;
margin-top: 30px;
}
@arsonus
arsonus / Command.php
Created November 4, 2015 02:57 — forked from drslump/Command.php
PHP Command runner class
<?php
/**
* Command building and execution
*
* Most methods implement a "fluent interface" for easy method call chaining.
*
* @see http://pollinimini.net/blog/php-command-runner/
* @author Iván -DrSlump- Montes <[email protected]>
* @license BSD
@arsonus
arsonus / class-search.php
Created October 16, 2015 17:19
A PHP script to search a MySQL database
<?php
/**
* Performs a search
*
* This class is used to perform search functions in a MySQL database
*
* @version 1.0
* @author John Morris <[email protected]>
*/
class search {
<?php
/**
* This class will cause WP_Query to ignore a 'post_type' parameter when 'post_type__not_in' is set.
*
* Class Post_Type__Not_In
*/
class Post_Type__Not_In {
/**
*