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
const navigatorErrorMessage = 'Could not find `userAgent` or `userAgentData` window.navigator properties to set `os`, `browser` and `version`' | |
const removeExcessMozillaAndVersion = /^mozilla\/\d\.\d\W/ | |
const browserPattern = /(\w+)\/(\d+\.\d+(?:\.\d+)?(?:\.\d+)?)/g | |
const engineAndVersionPattern = /^(ver|cri|gec)/ | |
const userAgentData = window.navigator.userAgentData | |
const userAgent = window.navigator.userAgent | |
const unknown = 'Unknown' | |
const empty = '' | |
const brandList = ['chrome', 'opera', 'safari', 'edge', 'firefox'] |
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
See comments |
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
.parent-selector { | |
background: lime; | |
> .child-selector { | |
color: crimson; | |
} | |
} |
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
[ | |
{ | |
"id": "5a6ce86d2af929789500e7ca", | |
"author": "Edsger W. Dijkstra", | |
"quote": "The computing scientist’s main challenge is not to get confused by the complexities of his own making." | |
}, | |
{ | |
"id": "5a6ce86f2af929789500e7f3", | |
"author": "Edsger W. Dijkstra", | |
"quote": "If debugging is the process of removing software bugs, then programming must be the process of putting them in." |
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
import { pasteInto } from '../../anti-framework.js' | |
let n = 0 | |
// The view callback prevents conditions and loops and operators at runtime. | |
const counterView = pasteInto('#root', ({ n }) => ` | |
<button value="-">-</button> | |
<button value="+">+</button> | |
<span>${n}</span> | |
`) |
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
package maiimport ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
layout := "2006-01-02T15:04:05Z" | |
t, err := time.Parse(layout, "2022-01-21T05:53:19Z") | |
if err != nil { |
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
//const data = [1.5, 3.8, 6.7, 9.0, 11.2, 13.6, 16] | |
const data = [4, 4, 3, 5, 4, 3, 2, 2, 3, 4, 1, 1, 3] | |
const x = data.map((_, i) => i + 1) | |
const y = data | |
const xy = data.map((value, i) => (i + 1) * value) | |
const xPow2 = data.map((_, i) => (i + 1) ** 2) | |
//const sumOfX =data.reduce((acc, _, i) => acc + 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
const objectPath = { | |
/* | |
Creates an object-path and assigns the value. | |
- object - object - The object to create the path onto | |
- stringLocation - string - The object path as a string. | |
- value - * - The value to assign. */ | |
assign (object, stringLocation, value) { | |
const locationList = stringLocation.split(dot) | |
const locationListLength = locationList.length |
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
const string = "[object Window]"; | |
const pattern = /[^[object ](.*)[^\]]/g; | |
string.match(pattern); |
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
const isEvent0 = prop => 0 === prop.indexOf('on'); | |
const getEventNames0 = (obj) => { | |
const result = []; | |
for (let prop in obj) { | |
if (!isEvent0(prop)) continue; | |
prop = prop.substr(2), result.push(prop); | |
} | |
return result; | |
} |
NewerOlder