Skip to content

Instantly share code, notes, and snippets.

View stefanjudis's full-sized avatar
🙉
Jo!

Stefan Judis stefanjudis

🙉
Jo!
View GitHub Profile
@stefanjudis
stefanjudis / script.sh
Created July 29, 2019 20:36
create-dirs-recursively.sh
mkdir -p new-dir/{foo,baz}/whatever-{1,2}/{a,b};
exa --tree new-dir;
# new-dir
# ├── baz
# │ ├── whatever-1
# │ │ ├── a
# │ │ └── b
# │ └── whatever-2
@stefanjudis
stefanjudis / README.md
Last active August 6, 2019 13:38
Twilio CLI snippets

Useful Twilio CLI snippets. :)

@stefanjudis
stefanjudis / console.js
Last active July 31, 2019 17:09
Suprising replacement patterns in String.prototype.replace
const msg = 'This is a great message';
msg.replace('great', 'wonderful');
// "This is a wonderful message"
//
// -> 'great' is replaced by 'wonderful'
msg.replace('great', '$&-$&');
// "This is a great-great message"
// '$&' represents the matched substring
@stefanjudis
stefanjudis / index.html
Last active July 17, 2019 07:14
Tweet for image preload
<link rel="preload" as="image" href="640.png"
imagesrcset="640.png 640w, 800.png 800w, 1024.png 1024w"
imagesizes="100vw">
<!-- preload the correct image for the following element -->
<img src="640.png"
srcset="640.png 640w, 800.png 800w, 1024.png 1024w"
sizes="100vw">
@stefanjudis
stefanjudis / gatsby-node.js
Created April 30, 2019 06:24
Change URL to file node in Gatsby
const { createRemoteFileNode } = require(`gatsby-source-filesystem`);
exports.onCreateNode = async ({
actions,
node,
createNodeId,
store,
cache
}) => {
const { createNode } = actions;
@stefanjudis
stefanjudis / index.html
Last active December 6, 2018 16:24
Preloading ES6 modules?
<html>
<head>
<title>ES6 modules tryout</title>
<!-- does this make sense for es module supporting browsers -->
<!-- this works fine for Safari Preview but -->
<!-- this will now trigger downloads for browsers that don't understand type="module" :( -->
<link rel="preload" href="./dist/modules/dep-1.js" as="script">
<link rel="preload" href="./dist/modules/dep-2.js" as="script">
<!-- is there instead a way to detect ES module support and inject these with an inline script? -->
@stefanjudis
stefanjudis / detailedMetrics.js
Created November 10, 2013 14:39
Chrome snippet to show performance of document
javascript:( function() {
console.group( 'Performance Information for all entries of ' + window.location.href );
console.log( '\n-> Duration is displayed in ms\n ' )
var entries = window.performance.getEntries();
entries = entries.sort( function( a, b ) {
return b.duration - a.duration;
} );
@stefanjudis
stefanjudis / migration.js
Created February 14, 2018 20:52
Content model migration
module.exports = function (migration) {
// create a new content type “Conference”
const conference = migration.createContentType('conference')
.name('Conference/Meetup')
.displayField('name')
// set up the new fields
conference.createField('name').type('Symbol').required(true).name('Conference/Meetup name')
conference.createField('country').type('Symbol').required(true).name('Country Code')
conference.createField('city').type('Symbol').required(true).name('City')
@stefanjudis
stefanjudis / dep-1.js
Last active March 17, 2017 00:14
How to make JS files prod ready without bundling
import dep2 from './dep-2.js';
export default function() {
return dep2();
}