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
function fixCurrentDate(dateString = 'Tue Jan 01 2019 00:00:00 GMT+0800') { | |
let RealDate; | |
// Make sure we keep a reference to the orginal `Date` | |
if (window.Date.isFake && window.Date.RealDate) { | |
RealDate = window.Date.RealDate; | |
} else { | |
RealDate = window.Date; | |
} | |
// If we're fixing the date we'll no doubt be using it, |
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
// Build the asserter | |
let assert = { | |
get modal() { | |
let modal = selector => ({ | |
get exists() { | |
return assert.modalExists(selector); | |
}, | |
}); | |
Object.assign(modal, { | |
get exists() { |
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
@mixin contain($aspect-y, $aspect-x) { | |
$aspect: $aspect-y / $aspect-x; | |
width: 100vw; | |
height: 100vw / $aspect; | |
@media (min-aspect-ratio: #{$aspect-y}/#{$aspect-x}) { | |
width: 100vh * $aspect; | |
height: 100vh; | |
} |
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
/* | |
* let a = 1; | |
* let an = 1; | |
* let some = 2; | |
* | |
* Currently supports: | |
* - a.day.ago | |
* - some.days.ago | |
* - a.week.ago | |
* - some.weeks.ago |
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
:root { | |
--r: 200; | |
--g: 100; | |
--b: 50; | |
--r1: calc(var(--r) / 255); | |
--r2: calc(var(--r1) * 100%); | |
--g1: calc(var(--g) / 255); | |
--g2: calc(var(--g1) * 100%); | |
--b1: calc(var(--b) / 255); |
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
$aspect-y: 16; | |
$aspect-x: 9; | |
$min-height: 80px; | |
$min-width: 160px; | |
$max-height: 900px; | |
$max-width: 1700px; | |
@mixin contain($aspect-y, $aspect-x) { |
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
class Accounting { | |
static largestNumber = 10e9; // America's annual budget is ~4tn | |
static accuracy = (function() { | |
let accuracy = 1; | |
while (Accounting.largestNumber * accuracy < Number.MAX_SAFE_INTEGER) { | |
accuracy *= 10; | |
} | |
return accuracy; | |
}()); // to change to #accuracy when support rises |
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
/** | |
* Used like: | |
* dealWithPromisesAsTheyResolve([ | |
* new Promise((res, rej) => setTimeout(res, 2000, 2000)), | |
* new Promise((res, rej) => setTimeout(res, 1000, 1000)), | |
* new Promise((res, rej) => setTimeout(res, 4000, 4000)), | |
* new Promise((res, rej) => setTimeout(res, 0, 0)), | |
* new Promise((res, rej) => setTimeout(rej, 3000, 3000)), | |
* ], num => console.log(num), err => console.log(`error: ${err}`)); | |
* |
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
(function() { | |
const BASE_64_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/'.split(''); | |
Number.prototype._toString = Number.prototype.toString; | |
window._parseInt = window.parseInt; | |
Number.prototype.toString = function(base) { | |
if (base < 37 && base >= 2) { | |
return Number.prototype._toString.call(this, ...arguments); |
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
console.log(` ‾‾‾‾ | |
Paint time for ${location}:${ | |
performance.getEntriesByType("paint").map(({ name, startTime }) => ` | |
• ${name}: ${startTime}ms`)} | |
____`); |