This file contains hidden or 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
| async function nextFrame() { | |
| return new Promise((resolve) => { | |
| requestAnimationFrame(resolve) | |
| }) | |
| } | |
| async function randomDelay(min, max) { | |
| const delay = Math.random() * (max - min) + min; | |
| const startTime = performance.now() | |
| while (performance.now() - startTime < delay) { |
This file contains hidden or 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> | |
| <meta charset="utf-8"> | |
| <title>Example</title> | |
| <style> | |
| div { | |
| width: 100px; | |
| height: 100px; | |
| background: black; | |
| animation-duration: .5s; |
This file contains hidden or 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
| // Only using native browser features (no jQuery). | |
| // Uses `fetch`, `DOMParser` and `querySelectorAll`. | |
| const getTitle = (url) => { | |
| return fetch(`https://crossorigin.me/${url}`) | |
| .then((response) => response.text()) | |
| .then((html) => { | |
| const doc = new DOMParser().parseFromString(html, "text/html"); | |
| const title = doc.querySelectorAll('title')[0]; | |
| return title.innerText; |
This file contains hidden or 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
| /** | |
| * Converts an RGB color value to HSL. Conversion formula | |
| * adapted from http://en.wikipedia.org/wiki/HSL_color_space. | |
| * Assumes r, g, and b are contained in the set [0, 255] and | |
| * returns h, s, and l in the set [0, 1]. | |
| * | |
| * @param Number r The red color value | |
| * @param Number g The green color value | |
| * @param Number b The blue color value | |
| * @return Array The HSL representation |
This file contains hidden or 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
| # SSL self signed localhost for rails start to finish, no red warnings. | |
| # 1) Create your private key (any password will do, we remove it below) | |
| $ openssl genrsa -des3 -out server.orig.key 2048 | |
| # 2) Remove the password | |
| $ openssl rsa -in server.orig.key -out server.key |