This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run in console: | |
const images = document.querySelectorAll('img'); | |
images.forEach(image => { | |
image.style.filter = "blur(5px) grayscale(1)"; | |
}); | |
// Or, make a bookmarklet: | |
javascript:const images = document.querySelectorAll('img'); images.forEach(image => { image.style.filter = "blur(5px) grayscale(1)"; }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Recursive function example"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Recursion 101</title> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isToday(d) | |
{ | |
var date_param = new Date(d).toDateString(); | |
var date_today = new Date().toDateString(); | |
var is_today = (date_today == date_param); | |
return is_today; | |
} | |
// Example use: console.log(isToday("01/01/2014")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get URL parameters | |
* @return array of URL parameters | |
*/ | |
function getUrlParams() | |
{ | |
var params = [], hash; | |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | |
for(var i = 0; i < hashes.length; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exercism.io exercise | |
// This function takes a date and returns a new date set one billion seconds (or gigasecond; ~31.558 years) in the future. | |
var Gigasecond = function(birthdate) { | |
this.birthdate = birthdate; | |
}; | |
Gigasecond.prototype.date = function() { | |
var gigasecondBirthday = new Date( this.birthdate.setSeconds( this.birthdate.getSeconds() + Math.pow(10, 9) ) ); | |
var gigasecondBirthdayMidnight = gigasecondBirthday.setHours( 0, 0, 0, 0 ); | |
var getDate = new Date(gigasecondBirthdayMidnight); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exercism.io exercise | |
var toRna = function (dna) { | |
'use strict'; | |
var rnaMap = { | |
'G' : 'C', | |
'C' : 'G', | |
'T' : 'A', | |
'A' : 'U' | |
}; | |
var rna = dna.replace(/G|C|T|A/gi, function(match){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var links = document.getElementsByTagName('a'); | |
var linkArray = Array.prototype.slice.call(links); | |
for (var i = 0; i < linkArray.length; i++) { | |
console.log(linkArray[i].href); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ref 1: http://toddmotto.com/mastering-the-module-pattern/ | |
// ref 2: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText | |
// create basic diagram module (w/ "revealing module" pattern from ref 1) | |
var D_ = (function() { | |
// draw container | |
var draw = function(label) { | |
var canvas = document.getElementById('canvas'); | |
if (canvas.getContext) { | |
var ctx = canvas.getContext('2d'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Lazy Loading without JavaScript</title> | |
<style type="text/css"> | |
/* Hide images on page load. */ | |
#img1, #img2, #img3 { | |
display: none; | |
} | |
/* Show images when targeted. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Close Amazon Preview with Esc Key | |
// @namespace http://www.therobbiedshow.com/ | |
// @version 0.1 | |
// @description Close Amazon preview window when clicking the Esc key! | |
// @match http://www.amazon.com | |
// @include http://*/* | |
// @copyright 2014+, Robert Dawson | |
// @require http://code.jquery.com/jquery-latest.min.js | |
// ==/UserScript== |
NewerOlder