Skip to content

Instantly share code, notes, and snippets.

View ashhitch's full-sized avatar
💭
Slinging Divs

Ash Hitchcock ashhitch

💭
Slinging Divs
View GitHub Profile
@ashhitch
ashhitch / Gruntfile.js
Last active August 29, 2015 14:08
Handy less build only grunt build
module.exports = function(grunt) {
"use strict";
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/**\n' +
'* <%= pkg.name %> v<%= pkg.version %> by <%= pkg.author %>\n' +
@ashhitch
ashhitch / rem-font-sizing.css
Created December 3, 2014 16:02
Rem Font Sizing CSS
html { font-size: 62.5%; }
body { font-size: 14px; font-size: 1.4rem; } /* =14px */
h1 { font-size: 24px; font-size: 2.4rem; } /* =24px */
requirejs.config({
baseUrl: 'scripts',
paths: {
'angular': 'lib/angular/angular',
'angular-animate': 'lib/angular/angular-animate',
'angular-aria': 'lib/angular/angular-aria',
'angular-cookies': 'lib/angular/angular-cookies',
'angular-messages': 'lib/angular/angular-messages',
'angular-mocks': 'lib/angular/angular-mocks',
'angular-resource': 'lib/angular/angular-resource',
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

@ashhitch
ashhitch / prototype.example.js
Last active August 29, 2015 14:12
JavaScript Prototype Example
// Establish the Player class-based object
function Player(){
this.name;
this.hitpoints = 100;
this.attack = function attack(opponent){
opponent.hitpoints -= 10;
alert(this.name+" just hit "+opponent.name);
}
}
// Create two new separate Player instances
@ashhitch
ashhitch / javaScript-inheritance.js
Created December 24, 2014 10:50
JavaScript Inheritance Example
// Establish a parent class
function Parentclass(){
this.parent_property1 = "Hola";
this.parentmethod1 = function parentmethod1(arg1){
return arg1+" Parent method 1 return data ...";
}
}
// Establish a child class
function Childclass(){
this.child_property1 = "Adios";
@ashhitch
ashhitch / instagram_oembed_provider.php
Created January 7, 2015 16:52
Register new oEmbed provider for instagram
// Register oEmbed providers
function instagram_oembed_provider() {
wp_oembed_add_provider( 'http://instagram.com/p/*', 'http://api.instagram.com/oembed', false );
wp_oembed_add_provider( 'http://instagr.am/p/*', 'http://api.instagram.com/oembed', false );
}
// Hook into the 'init' action
add_action( 'init', 'instagram_oembed_provider' );
@ashhitch
ashhitch / simple-css-spin.css
Created February 4, 2015 17:18
Super Simple Spin (s3) - Spin element on hover using CSS
.s3{
transition-duration: 0.8s;
transition-property: transform;
overflow:hidden;
}
.s3:hover
{
transform:rotate(360deg);
}
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@ashhitch
ashhitch / validateNI.js
Last active August 29, 2015 14:16
AngularJS Directive to Validate UK National Insurance Number
.directive('validateNi', function() {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, elem, attr, ngModel) {
var validator = function(value) {
if (/^\s*[a-zA-Z]{2}(?:\s*\d\s*){6}[a-zA-Z]?\s*$/.test(value)) {
ngModel.$setValidity('ni', true);
return value;