Skip to content

Instantly share code, notes, and snippets.

Sam Richard Snugug

Block or report user

Report or block Snugug

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
@Snugug
Snugug / performance.js
Last active Mar 15, 2019
A Chrome DevTools Snippet to get page performance numbers. Returns interesting Navigation Timings and Resource Sizing. Unfortunate workaround for content types until https://github.com/w3c/resource-timing/issues/203 hits
View performance.js
function getExt(filename, opts) {
if (!opts) opts = {};
if (!filename) return "";
var ext = (/[^./\\]*$/.exec(filename) || [""])[0];
return opts.preserveCase ? ext : ext.toLowerCase();
};
async function typeMap () {
const db = await fetch('https://unpkg.com/mime-db/db.json').then(t => t.json());
@Snugug
Snugug / instance.js
Last active Jun 20, 2018
Need a way to type provider:SOMETHING so I can `new` its children
View instance.js
import { validate, IsInt, IsEmail, IsIn, IsNotEmpty } from 'class-validator';
import { Provider } from './provider';
export class InstanceConfig {
[key:string]: number | string;
@IsEmail()
@IsNotEmpty()
email: string;
@Snugug
Snugug / README.md
Last active Feb 12, 2018
Progressively Enhanced Lazy Loading Images in 40 lines of code
View README.md

Lazy Load Images in 40 Lines of Code

Behold! Intersection Observers at work!

Usage

First, update your source code to move your image sources in to data attributes.

<!-- Image tags get `src` -->
@Snugug
Snugug / detect.js
Last active Jan 24, 2017
Feature Detection!
View detect.js
(function () {
'use strict';
var detect = function detect(property, value) {
if (window.CSS && window.CSS.supports) {
return window.CSS.supports(property, value);
}
else {
return false;
}
@Snugug
Snugug / SassMeister-input-HTML.html
Created Jan 4, 2016
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<div id="container">
<div class="first">First</div>
<div class="second">Second</div>
<div class="third">Third</div>
<div class="fourth">Fourth</div>
</div>
@Snugug
Snugug / SassMeister-input.scss
Created Nov 29, 2015
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// libsass (v3.2.5)
// ----
@import "breakpoint";
@import "toolkit";
@import "singularitygs";
@include sgs-change('debug', true);
@include sgs-change('mobile first', true);
@Snugug
Snugug / SassMeister-input-HTML.html
Created Oct 10, 2015
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<div class="grid-4">
<h3>Item 1</h3>
</div>
<div class="grid-4">
<h3>Item 2</h3>
</div>
<div class="grid-4">
<h3>Item 3</h3>
</div>
<div class="grid-4">
@Snugug
Snugug / SassMeister-input.scss
Created Sep 9, 2015
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
$a: 'test';
$b: test;
.foo {
content: is-quoted($a); // true
content: is-quoted($b); // false
@Snugug
Snugug / SassMeister-input.scss
Created Sep 6, 2015
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
/**
* Hello World
**/
/*!
@Snugug
Snugug / SassMeister-input.scss
Created Sep 1, 2015
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// libsass (v3.2.5)
// ----
@function foo {
@return 'bar';
}
@mixin bar {
content: 'baz';
You can’t perform that action at this time.