Skip to content

Instantly share code, notes, and snippets.

@kevinweber
kevinweber / e.164.phoneNumber.js
Last active April 23, 2021 19:14
Convert string to match E.164 phone number pattern (e.g. +1234567890)
/**
* Convert string to match E.164 phone number pattern (e.g. +1234567890),
* otherwise return empty string.
*/
function enforcePhoneNumberPattern(string) {
let newString = string.match(/[0-9]{0,14}/g);
if (newString === null) {
return '';
}
/*
* Lazy Load for Youtube
* by Kevin Weber
*/
var $lly = jQuery.noConflict();
$lly(document).ready(function() {
function doload_lly() {
@kevinweber
kevinweber / webpack.config.js
Last active September 13, 2019 14:41
AEM Front Webpack Plugin. Part of the AEM Front toolset. Learn more: https://kevinw.de/aem-front/
const path = require('path');
const AEMFrontPlugin = require(path.join(__dirname, './webpack.plugin.aem-front.js'));
//... your Webpack configuration ...
plugins: [
new AEMFrontPlugin({
exclude: '**/webpack.module/**',
watchDir: './../'
}),
@kevinweber
kevinweber / curve-example.png
Last active June 6, 2019 08:56
d3.js: Custom curve with rounded steps. Based on d3.curveStep.
curve-example.png
@kevinweber
kevinweber / this.js
Created June 24, 2017 01:21
JavaScript: Ways to use `this` in callback function
// The old way (before ES6)
var _self = this;
this.element.addEventListener('click', function (event) {
_self.doSomething(event);
});
// The new way (ES6)
this.element.addEventListener('click', (event) => {
this.doSomething(event);
});
@kevinweber
kevinweber / HTML-CSS-JS-editor.js
Last active August 13, 2018 16:59
Bookmarks / Search Input Queries
data:text/html,<body oninput="i.srcdoc=h.value+'<style>'+c.value+'</style><script>'+j.value+'</script>'"><style>textarea,iframe{width:100%;height:50%}body{margin:0}textarea{width:33.33%;font-size:18}</style><textarea placeholder=HTML id=h></textarea><textarea placeholder=CSS id=c></textarea><textarea placeholder=JS id=j></textarea><iframe id=i>
@kevinweber
kevinweber / README.md
Created July 29, 2018 15:56 — forked from spraints/README.md
Set up git-hooks

Install git hooks

git-hooks is a tool that makes it easy to re-use hook scripts across projects.

I installed it by cloning the repo and symlinking it into /usr/local/bin.

git clone git://github.com/icefox/git-hooks.git
cd git-hooks
ln -s `pwd`/git-hooks /usr/local/bin/git-hooks
@kevinweber
kevinweber / aem-grid-v2.less
Last active July 9, 2018 11:32
Collection of AEM CSS/LESS snippets (responsive grid). Get an exemplary grid from the WKND tutorial: https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part3.html
/* 6.3 Path to Responsive Grid */
/* @gridpath : "/etc/clientlibs/wcm/foundation/grid"; */
/* 6.4 Path to Responsive Grid */
@gridpath : "/libs/wcm/foundation/clientlibs/grid";
@import "@{gridpath}/grid_base.less";
/* maximum amount of grid cells to be provided */

AEM 6.2 Authoring Editor to Site messaging API

API

/**
 *
 * @param group {String} group identifier name
 * @param [targetWindow=window.parent]
 * @param [origin='*']
 * @constructor
@kevinweber
kevinweber / debounce.js
Last active April 25, 2018 01:05
Debounce function
/**
* Debounce function
* based on https://davidwalsh.name/essential-javascript-functions
*/
function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this,
args = arguments,