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 generate = () => { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { | |
let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8) | |
return v.toString(16) | |
}) | |
} | |
console.log(generate()) |
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 Tuno { | |
constructor() { | |
this.axes = { | |
mercury: 0.387, | |
venus: 0.723, | |
earth: 1, | |
mars: 1.524, | |
jupiter: 5.20, | |
saturn: 9.04, | |
uranus: 18.33, |
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="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Web App Template</title> | |
</head> | |
<body> | |
<header id="header" class="header"> | |
<nav id="nav" class="nav"> |
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 slope = (p1, p2) => { | |
let y2 = p2[1] | |
let y1 = p1[1] | |
let x2 = p2[0] | |
let x1 = p1[0] | |
let coords = `(${x1}, ${y1}) (${x2}, ${y2})` | |
let slope = (y2 - y1) / (x2 - x1) | |
return slope | |
// If you want the function to return the coordinates instead, replace slope with coords. (return coords) | |
} |
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 getIp = request => { | |
let ip = request.headers['x-forwarded-for'] | |
|| request.connection.remoteAddress | |
|| request.socket.remoteAddress | |
|| request.connection.socket.remoteAddress; | |
ip = ip.split(',')[0]; | |
ip = ip.split(':').slice(-1) | |
return ip[0]; | |
} |
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 characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
let result = '' | |
let length = 10 // Customize the length here. | |
for (let i = length; i > 0; --i) result += characters[Math.round(Math.random() * (characters.length - 1))] | |
console.log(result) |