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
const setup = function() { | |
var body = document.getElementById('body'); | |
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext('2d'); | |
canvas.width = window.innerWidth; | |
canvas.height = window.innerHeight; | |
body.appendChild(canvas); |
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
Intl.DateTimeFormat().resolvedOptions().timeZone |
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> | |
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<meta name="description" content="Page description" /> | |
<meta name="theme-color" media="(prefers-color-scheme: light)" content="white"> | |
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#242424"> | |
<!-- Allow installing the app to the homescreen --> |
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
window.matchMedia('(prefers-color-scheme: dark)') | |
.addEventListener('change',({ matches }) => { | |
if (matches) { | |
console.log("change to dark mode!") | |
} else { | |
console.log("change to light mode!") | |
} | |
}) |
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
unction useWindowSize() { | |
const [windowSize, setWindowSize] = useState({ | |
width: undefined, | |
height: undefined, | |
}); | |
useEffect(() => { | |
// only execute all the code below in client side | |
if (typeof window !== 'undefined') { | |
// Handler to call on window resize |
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
// find duplicate Id's in DOM | |
const allElements = document.getElementsByTagName("*"); | |
const allIds = {}; | |
let found = false; | |
for (let i = 0, n = allElements.length; i < n; ++i) { | |
const id = allElements[i].id; | |
if (id) { | |
if (allIds[id] === undefined) { |
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
// showheaders.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out response headers for current URL. | |
(function() { | |
var request=new XMLHttpRequest(); | |
request.open('HEAD',window.location,true); | |
request.onload = request.onerror = function () { |
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
m=(x,y)-> | |
a=x | |
b=y | |
z=0 | |
for i in [0..99] | |
(return if i>60 then '*' else if i>10 then '-' else if i>5 then '.' else ' ') if z>4 | |
l=y*y | |
z=x*x+l | |
y=2*x*y+b | |
x=x*x-l+a |
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
<template id="html5ElementTemplate"> | |
<style> | |
.outerDiv { | |
border:0.1em solid blue; | |
display:inline-block; | |
padding: 0.4em; | |
} | |
.devText { | |
font-weight: bold; |
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
int main(int argc, char** argv) | |
{ | |
int k = 2; | |
float i,j,r,x,y=-16; | |
while (puts(""), y++<15) | |
for (x=0; x++<84; putchar(" .:-;!/>)|&IH%*#"[k&15])) | |
for (i=k=r=0; | |
j=r*r-i*i-2+x/25,i=2*r*i+y/10,j*j+i*i<11&&k++<111; | |
r=j); | |
return 0; |