Skip to content

Instantly share code, notes, and snippets.

View marcveens's full-sized avatar

Marc Veens marcveens

View GitHub Profile
@marcveens
marcveens / NetlifyCmsConfig.ts
Last active February 28, 2023 12:09
Typescript used to generate a Netlify CMS config.yml
// See https://www.marcveens.nl/netlify-cms-generate-config-yml
// https://www.netlifycms.org/docs/configuration-options/
type PublishMode = 'simple' | 'editorial_workflow';
type ExtensionType = 'yml' | 'yaml' | 'toml' | 'json' | 'md' | 'markdown' | 'html';
type FormatType = 'yml' | 'yaml' | 'toml' | 'json' | 'frontmatter' | 'yaml-frontmatter' | 'toml-frontmatter' | 'json-frontmatter';
type WidgetType = 'boolean' | 'date' | 'datetime' | 'file' | 'hidden' | 'image'
| 'list' | 'map' | 'markdown' | 'number' | 'object' | 'relation'
| 'select' | 'string' | 'text' | string;
type MapType = 'Point' | 'LineString' | 'Polygon';
@marcveens
marcveens / es6.md
Created April 21, 2017 07:35
ES6 intro

Variable hoisting

var foo = 2;
if (true) {
    var bar = 1;
}

will be compiled to

@marcveens
marcveens / design-patterns.md
Last active December 2, 2023 02:16
Practical Design Patterns in Javascript
@marcveens
marcveens / default-plugin.html
Created March 22, 2017 15:09
Default JS plugin
<!DOCTYPE>
<html>
<head>
<script src="lodash.min.js"></script>
</head>
<body>
<div class="js-player"></div>
@marcveens
marcveens / chain-methods.js
Last active March 22, 2017 14:50
Chaining methods
;(function () {
function utils() { }
utils.prototype.customString = function(str) {
this.value = str;
return this;
};
utils.prototype.toLower = function() {
this.value = this.value.toLowerCase();
@marcveens
marcveens / requestAnimationFrame.html
Created March 21, 2017 15:36
requestAnimationFrame example
<!DOCTYPE>
<html>
<head>
<style>
body {
height: 4000px;
}
.fixed {
@marcveens
marcveens / maps-plugin.js
Last active March 21, 2017 14:41
Google Maps jQuery plugin
(function ($) {
'use strict';
function Maps($root, options) {
this.options = options;
this.$root = $root;
this.map = null;
this.markerCluster = null;
this.infoWindow = null;
this.markers = [];
@marcveens
marcveens / map-loop.js
Created December 15, 2015 21:01
Use .map instead of a for loop
// WRONG
var mixedEmails = ['JOHN@ACME.COM', 'Mary@FooBar.com', 'monty@spam.eggs'];
var tempList = [];
for (var i = 0; i < mixedEmails.length; i++) {
tempList.push(mixedEmails[i].toLowerCase());
}
document.getElementsByTagName('body')[0].innerHTML += 'Old method: ' + tempList;