Skip to content

Instantly share code, notes, and snippets.

View steve8708's full-sized avatar
😄

Steve Sewell steve8708

😄
View GitHub Profile
const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
/**
* Convert a date to a relative time string, such as
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc.
@steve8708
steve8708 / intercom-facade.tsx
Created November 12, 2021 17:46
Intercom Facade - render a placeholder of the intercom button that doesn't load the heavy widget JS until clicked. Boosted our lighthouse score ~15 points
const INTERCOM_KEY = /* YOUR KEY HERE */;
export function IntercomFacade() {
return (
<div className="intercom-lightweight-app" aria-live="polite">
<style>{INTERCOM_STYLE}</style>
<div
className="intercom-lightweight-app-launcher intercom-launcher"
role="button"
tabIndex={0}
@steve8708
steve8708 / BuilderCloudinaryImage.tsx
Created November 15, 2019 20:30
Example Cloudinary Image rendering component in Builder.io
import React from 'react';
import { withBuilder } from '@builder.io/react';
class CloudinaryImageComponent extends React.Component {
render() {
return <img src={this.props.image} />
}
}
export const CloudinaryImage = withBuilder(CloudinaryImageComponent, {
@steve8708
steve8708 / ractive-backbone-accociations-adaptor.js
Last active December 22, 2015 02:08
Bind nested Bacbone models and collections to Ractive views!
// An adaptor for binding Ractive.js views with nested Backbone models and collections via
// backbone-associations (https://github.com/dhruvaray/backbone-associations)
//
// Based on the original Backbone adaptor for Ractive by Rich Harris:
// https://github.com/Rich-Harris/Ractive/blob/master/src/Ractive/Ractive.adaptors/backbone.js
Ractive.adaptors.backboneAssociatedModel = function ( model, path ) {
var settingModel, settingView, setModel, setView, pathMatcher, pathLength, prefix, modelChangeEventHandler;
if ( path ) {
{ "entities" : [
{
"key" : "http://hostname/test1.jpg",
"media_key": null,
"origin_urls" : ["http://hostname/page.html"]
},
{
"key" : "http://hostname.test2.jpg",
"media_key": null,
"origin_urls" : ["http://hostname/page2.html"]
@steve8708
steve8708 / grunt.js
Created June 12, 2012 19:30
My current grunt configuration
// My current grunt.js file, includes examples for compiling less,
// handlebars templates, file watching, etc
//
// My most used task is the "watch-serve" task for linting/testing
// my files as I work, has been amazingly helpful
//
// Comments below are the boilerplate comments from the original gruntfile
// I modified
//
// NOTE: for this to work you need to install the below npm tasks