Skip to content

Instantly share code, notes, and snippets.

Jon Catmull JonCatmull

Block or report user

Report or block JonCatmull

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 lighthouse-compose-import.sh
curl -o lightsail-compose.sh https://raw.githubusercontent.com/JonCatmull/docker/master/lightsail-compose.sh
chmod +x ./lightsail-compose.sh
./lightsail-compose.sh
@JonCatmull
JonCatmull / line-height.plugin.js
Last active Nov 26, 2018 — forked from aaerofeev/line_height.js
Froala Editor line-height plugin
View line-height.plugin.js
/*!
* Froala Line Height plugin
* froala_editor v2.7.1 (https://www.froala.com/wysiwyg-editor)
*/
!function (a) {
"function" == typeof define && define.amd ? define(["jquery"], a) : "object" == typeof module && module.exports ? module.exports = function (b, c) {
return void 0 === c && (c = "undefined" != typeof window ? require("jquery") : require("jquery")(b)), a(c), c
} : a(jQuery)
}(function (a) {
@JonCatmull
JonCatmull / ordinal.pipe.ts
Last active Nov 18, 2019
Appends ordinal (st, nd ,rd ,th) to number or turns number into ordinal. Typescript Angular2 Pipe
View ordinal.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
const ordinals: string[] = ['th','st','nd','rd'];
/*
* Append ordinal to number (e.g. "1st" position)
* Usage:
* value | ordinal:keepNumber
* Example:
* {{ 23 | ordinal}}
@JonCatmull
JonCatmull / smart-date.pipe.ts
Created Dec 21, 2016
Relative date Pipe for Angular2 + TypeScript . Convert date or timestamp into relative date string e.g. "5 days ago" or to local date string e.g. "11/12/2016"
View smart-date.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
import { RelativeDatePipe } from './relative-date.pipe'; // https://gist.github.com/JonCatmull/e00afb1c96298a4e386ea1b5d091702a
const secondsInAday = 86400;
/*
* Turn Date into realtive date (e.g. "5 days ago") unless date is
* more than relativeMax days ago.
@JonCatmull
JonCatmull / relative-date.pipe.ts
Created Dec 21, 2016
Relative date Pipe for Angular2 + TypeScript . Convert date|timestamp into relative date string e.g. "5 days ago", "1 minute ago" etc.
View relative-date.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
// Epochs
const epochs: any = [
['year', 31536000],
['month', 2592000],
['day', 86400],
['hour', 3600],
['minute', 60],
['second', 1]
@JonCatmull
JonCatmull / file-size.pipe.ts
Last active Oct 31, 2019
Angular2 + TypeScript file size Pipe/Filter. Convert bytes into largest possible unit. e.g. 1024 => 1 KB
View file-size.pipe.ts
/**
* @license
* Copyright (c) 2019 Jonathan Catmull.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
View harlem-konami.js
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ) {
$(document).unbind('keydown',arguments.callee);
@JonCatmull
JonCatmull / angular-pagination.directive.js
Last active Feb 17, 2016
Angular directive to generate pagination numbers. Allows setting of max numbers to display and it will keep the first and last page visible.
View angular-pagination.directive.js
(function() {
'use strict';
angular
.module('fcp')
.directive('pagination', pagination);
/** @ngInject */
function pagination() {
var directive = {
@JonCatmull
JonCatmull / itemFirst.filter.js
Created Jan 28, 2016
Angular filter - Move an array item to first position but preserve the rest of the lists order (only set up for basic array of either integers or strings)
View itemFirst.filter.js
(function() {
'use strict';
angular
.module('fcp')
.filter('itemFirst', itemFirst);
/** @ngInject */
function itemFirst($filter) {
View redactor-chrome-span-fix.js
// Place inside setEvents: function() { on line 1361
// Check for chrome span bug
this.$editor.on("DOMNodeInserted", $.proxy(function(e) {
if (e.target.tagName == "SPAN" ) {
console.log('clean spans');
var helper = $("<b>helper</b>");
$(e.target).before(helper);
You can’t perform that action at this time.