Skip to content

Instantly share code, notes, and snippets.

And Finally andfinally

Block or report user

Report or block andfinally

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gulpfile.babel.js
import gulp from 'gulp';
import sass from 'gulp-sass';
import babel from 'gulp-babel';
import sourcemaps from 'gulp-sourcemaps';
import es from 'event-stream';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
const sassOpts = {outputStyle: 'compressed', errLogToConsole: true};
andfinally / sample.js
Last active Feb 4, 2017 — forked from gfazioli/old_version_event.js
WordPress actions and filters in Javascript Forked from gfazioli/old_version_event.js.
View sample.js
// Add action
wpdk_add_action( 'test_action', test_action );
// Action function
function test_action()
console.log( 'Fires test_action' );
wpdk_do_action( 'test_action' );
andfinally / index.html
Last active Apr 11, 2016
Breakpoint watcher - when a page has crossed a CSS breakpoint, calls a callback, passing an object representing the breakpoint you've left and an object representing the breakpoint you've entered
View index.html
<title>-- == TEST == --</title>
body {
background: #FF1493;
andfinally / font.js
Last active Jun 8, 2018
Cache webfont in localStorage
View font.js
* Adapted from
* This version tries to load the font from localStorage. If it's not there it simply adds a link to the stylesheet
* and ajaxes the contents in on load. This makes an extra request. But adding the stylesheet link renders quicker than
* waiting for a response to the ajax request and then injecting the contents into a style tag, hopefully minimising the
* FOUT you get when you view and
(function () {
"use strict";
// Once cached the css file is stored on the client forever. To invalidate the cache change this URL.
andfinally / .htaccess
Last active Jan 21, 2018
Barebones Backbone Router example for an Apache site with a local URL like http://local5/backbone-router.
View .htaccess
# html5 pushstate (history) support:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L,QSA]
andfinally / normalise-url.js
Created Oct 8, 2013
Turn a URL into just the path + querystring
View normalise-url.js
// normalizeUrl('');
// returns "/sport/?page=1"
var normalizeUrl = function (url) {
var a = document.createElement('a');
a.href = url;
a = a.pathname +;
a = a.indexOf('/') === 0 ? a : '/' + a; // because IE doesn't return a leading '/'
return a;
andfinally / adjust_page_height.js
Created Oct 2, 2013
Periodically check the height of the main content container and reset its height to accommodate any increase in the height of its children that might've happened. Content container has overflow hidden. Content like FB comments can increase in height after page load.
View adjust_page_height.js
// Make the contentArea height equal to the paneVisible height. (We view the latter through the former.)
var updateHeight = function(){
var height = $(paneVisible).children().height();
if (height) {
$(contentArea).height(height + paneVisibleMargin);
// Set a periodic height adjustment for the content area. Necessary to account for diverse heights of side-panes as they slide in, and dynamic page elements.
andfinally / ping_google_analytics.js
Created Oct 1, 2013
Ping Google Analytics "Log" and the time in hh:mm:ss at intervals - Stephan's code. Seems to log custom event with GA every 1 or 1.5 seconds, with seconds elapsed since the analytics JS started running.
View ping_google_analytics.js
// Converts number of seconds to hh:mm:ss
if( typeof Number.prototype.toHHMMSS !== 'function' ) {
Number.prototype.toHHMMSS = function (){
var hours = Math.floor(this / 3600);
var minutes = Math.floor((this - (hours * 3600)) / 60);
var seconds = this - (hours * 3600) - (minutes * 60);
var str;
str = ( hours === 0 ? '' : (hours < 10 ? '0' + hours : hours ) + ':' );
str += ( minutes < 10 ? '0' + minutes : minutes ) + ':';
str += ( seconds < 10 ? '0' + seconds : seconds );
You can’t perform that action at this time.