Skip to content

Instantly share code, notes, and snippets.

View christianhanvey's full-sized avatar

Christian Hanvey christianhanvey

View GitHub Profile
@christianhanvey
christianhanvey / app.js
Created April 16, 2014 07:05
angular radio switch directive - an on/off switch
window.app = angular.module('mainApp', []);
app.controller('mainCtrl', function ($scope) {
$scope.include = 'yes';
});
app.directive('radioSwitch', ['analyticsSettings', function (analyticsSettings) {
return {
restrict: 'A',
scope: {
@christianhanvey
christianhanvey / gist:10820339
Created April 16, 2014 06:58
angular safeApply
angular.module('ng').run(['$rootScope', function($rootScope) {
$rootScope.safeApply = function(fn) {
var phase = this.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
if(fn && (typeof(fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
@christianhanvey
christianhanvey / imgtag.html
Created January 24, 2012 09:48 — forked from anselmh/imgtag.html
The New Img Tag (evolved)
<img src="large-default-file.jpg" alt="default alt text describing image" title="default title text">
<source src="smaller.jpg" media="screen and (max-device-width:600px)" alt="this is alternative text for smaller file" title="this is title for smaller file">
<source src="tiny.jpg" media="screen and (max-device-width:320px)" alt="this is alternative text for tiny file" title="this is title for tiny file">
<source src="monochrome.jpg" media="monochrome" alt="this is alternative text for monochrome file" title="this is title for monochrome file">
</img>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Matt Hamm's Page Curl Boxes &middot; CodePen</title>
<link rel="stylesheet" href="http://codepen.io/stylesheets/css/reset.css">
@christianhanvey
christianhanvey / Fullpage.html
Created May 16, 2012 08:18
Green Corner Ribbon
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Green Corner Ribbon &middot; CodePen</title>
<style>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Compass Flag/Ribbon Mixins &middot; CodePen</title>
<style>
@christianhanvey
christianhanvey / snippet.php
Created June 4, 2012 00:08 — forked from Mark-H/snippet.php
MODX Snippet to take a database backup and to email that.
<?php
$mailto = (isset($mailto)) ? $mailto : '@@ DEFAULT EMAIL HERE @@';
$warningMail = '@@ EMAIL TO SEND WARNING TO IN CASE OF A SMALL BACKUP FILE @@';
include MODX_CORE_PATH.'/config/'.MODX_CONFIG_KEY.'.inc.php';
$host = $database_server; // database host
$dbuser = $database_user; // database user name
$dbpswd = $database_password; // database password
$mysqldb = $dbase; // name of database
@christianhanvey
christianhanvey / snippet.md
Created July 2, 2012 02:02 — forked from harthur/snippet.md
console.log() key binding for Sublime Text

Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:

[
    { "keys": ["super+shift+l"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }, "context":
 [

Website Contract

Revised date: 13/03/2013

Between us: Crunch Design

and you: [customer name]

Summary:

@christianhanvey
christianhanvey / jquery.equalHeights.js
Created October 2, 2013 23:04
Ye olde jQuery equal heights plugin
// jQuery plugin to create equal height elements
// Will make all elements that match the seletor the same height - matching the tallest of all of the elements.
//
// usage:
// $('.selector').equalHeights();
(function ( $ ) {
$.fn.equalHeights = function(els) {
var maxHeight = 0;
this.each(function(){