| button { | |
| background-image: linear-gradient(#5187c4, #1c2f45); | |
| background-size: auto 200%; | |
| background-position: 0 100%; | |
| transition: background-position 0.5s; | |
| /* ...and various other button styles */ | |
| } | |
| button:hover { |
| /*------------------------------------------ | |
| Responsive Grid Media Queries - 1280, 1024, 768, 480 | |
| 1280-1024 - desktop (default grid) | |
| 1024-768 - tablet landscape | |
| 768-480 - tablet | |
| 480-less - phone landscape & smaller | |
| --------------------------------------------*/ | |
| @media all and (min-width: 1024px) and (max-width: 1280px) { } | |
| @media all and (min-width: 768px) and (max-width: 1024px) { } |
| /** | |
| * ECMA2015 | |
| */ | |
| function convertHex(hexCode, opacity = 1){ | |
| var hex = hexCode.replace('#', ''); | |
| if (hex.length === 3) { | |
| hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | |
| } |
| { | |
| // http://eslint.org/docs/rules/ | |
| "ecmaFeatures": { | |
| "binaryLiterals": false, // enable binary literals | |
| "blockBindings": false, // enable let and const (aka block bindings) | |
| "defaultParams": false, // enable default function parameters | |
| "forOf": false, // enable for-of loops | |
| "generators": false, // enable generators | |
| "objectLiteralComputedProperties": false, // enable computed object literal property names |
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
| function HEX2RGB (hex) { | |
| "use strict"; | |
| if (hex.charAt(0) === '#') { | |
| hex = hex.substr(1); | |
| } | |
| if ((hex.length < 2) || (hex.length > 6)) { | |
| return false; | |
| } | |
| var values = hex.split(''), | |
| r, |
| // Updated on 16th May, 2024 based on @chamie's suggestion. | |
| const response = await fetch("http://path/to/audio.wav"); | |
| const data = await response.arrayBuffer(); | |
| const blob = new Blob([data], { type: "audio/wav" }); | |
| const blobUrl = URL.createObjectURL(blob); | |
| const audio = new Audio(); | |
| audio.src = blobUrl; | |
| audio.controls = true; | |
| document.body.appendChild(audio); |

