Skip to content

Instantly share code, notes, and snippets.

View jackgrant87's full-sized avatar

Jack jackgrant87

  • London
View GitHub Profile
@jackgrant87
jackgrant87 / index.html
Created May 28, 2014 14:28
A Pen by Jack Shepherd.
<section class="product-card">
<div class="product-toggle">
<div><span class="icon-plus2"></span></div>
</div>
<div class="product-menu">
<div><span class="icon-menu"></span></div>
</div>
<div class="product-image">
<img src="http://localhost/ri-flats/images/products/1.jpg" alt="" />
</div>
@jackgrant87
jackgrant87 / gist:9483103
Created March 11, 2014 10:26
AngularJS directive to fire a CSS animation once on click
// General purpose 'animate' directive.
//
// Takes these arguments:
// animate-once-target="{css selector}" animate-once-animation="{name of css animation}" animate-once-on="{event type}"
//
// Requires CSS set up as here: http://codepen.io/jackshepherd/pen/vkFad
App.directive('animateOnce', function() {
return {
restrict: 'A',
link: function(scope, element, attr) {
@jackgrant87
jackgrant87 / gist:9482577
Last active April 27, 2016 07:56
AngularJS sticky element directive.
// General purpose sticky directive
app("sticky", ['$window', function ($window) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var $win = angular.element($window);
if (scope._stickyElements === undefined) {
scope._stickyElements = [];
#!/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 12.04 LTS, fresh OS install."
echo "There are no guarantees, and I take no liability if it breaks, but it"
<div id="container">
<div id="cell1" class="cell"><p>blah</p></div>
<div id="cell2" class="cell"><p>blah</p></div>
<div id="cell3" class="cell"><p>blah</p></div>
<div class="clear"></div>
<div id="cell4" class="cell"><p>blah</p></div>
<div id="cell5" class="cell"><p>blah</p></div>
<div id="container">
<div id="cell1" class="cell"><p>blah</p></div>
<div id="cell2" class="cell"><p>blah</p></div>
<div id="cell3" class="cell"><p>blah</p></div>
<div class="clear"></div>
<div id="cell4" class="cell"><p>blah</p></div>
<div id="cell5" class="cell"><p>blah</p></div>
@jackgrant87
jackgrant87 / numbers-js-humanise.js
Created July 17, 2012 17:47
A few JS functions for humanising numbers
//put thousand commas in
$.fn.digits = function(){
return this.each(function(){
$(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
})
}
//add a suffix to a digit, eg 2nd, etc
$.fn.digitsuffix = function(){
@jackgrant87
jackgrant87 / js-addslashes.js
Created July 17, 2012 17:44
Javascript 'PHP addslashes'
function addslashes (str) {
return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}
@jackgrant87
jackgrant87 / jquery-rainbow-CSS.js
Created July 17, 2012 17:43
jQuery to add crazy rainbow CSS style
$('<style type="text/css"> .crazy-rainbow {background:-webkit-gradient(linear, right top, left bottom, color-stop(0.01,purple), color-stop(0.1,indigo), color-stop(0.2,blue), color-stop(0.4,green), color-stop(0.5,yellow), color-stop(0.7,orange), color-stop(0.8,red), color-stop(0.99,purple)); -webkit-background-size: 100% 100%;}</style>').appendTo("head");