Skip to content

Instantly share code, notes, and snippets.

View JohnLouderback's full-sized avatar

John Louderback JohnLouderback

View GitHub Profile
@JohnLouderback
JohnLouderback / fix-sourcemaps-loader.js
Created March 3, 2023 23:37
An example of editing source maps through a Webpack loader.
sourceMap.sources.forEach((sourceFile, i) => {
// Get the source code for the current source file.
const source = sourceMap.sourcesContent[i];
// Keep track of the number of blank lines that have been encountered.
let currentBlankLineCount = 0;
// Split the source into lines so we can adjust the line numbers. For each line, we'll
// need count the number of "blank" lines that preceded it.
const sourceFileLineDetails = source.split('\n').map((line) => {
@JohnLouderback
JohnLouderback / console-clear.js
Last active August 29, 2015 14:17
Make the JS console "clear" function act the terminal "clear" command
(function(){
if (typeof clear !== 'undefined') {
var oldClear = clear;
Object.defineProperty(window, 'clear', {
get: function() {
oldClear();
return oldClear;
}
});
}
$('.some-els').bind('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function(){
// Do something!
$(this).removeClass('animation-class');
})
.addClass('animation-class');
// One works, too
$('.some-els').one('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function(){
// Do something once!
console.log('this would show once');