View index.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>HTML</title> | |
</head> | |
<body> |
View index.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Kieran Barker</title> | |
</head> | |
<body> |
View serializeJSON.js
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
/** | |
* Serialize all form data into a JSON string. | |
* https://gist.github.com/kieranbarker/98f8dadbf824236e42820419b1da58eb | |
* @param {HTMLFormElement} form The form to serialize. | |
* @returns {string} The serialized form data. | |
*/ | |
function serializeJSON (form) { | |
// Create a new FormData object | |
const formData = new FormData(form); |
View toTitleCase.js
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
/** | |
* Convert a string to title case. | |
* https://gist.github.com/kieranbarker/293b74f1b3b46272315d2e1719786b03 | |
* @param {string} str The string to convert. | |
* @returns {string} The converted string. | |
*/ | |
function toTitleCase(str) { | |
return str | |
.toLowerCase() | |
.split(" ") |
View file_exists.js
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
// | |
// Callback API | |
// | |
import { access, constants } from 'fs'; | |
const file = 'package.json'; | |
access(file, constants.F_OK, error => { | |
if (error) { |
View xss.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>XSS</title> | |
</head> | |
<body></body> | |
<script> |
View getJSON.js
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
/** | |
* Get the JSON data from a Response object. | |
* @param {Response} response The Response object. | |
* @returns {Promise} The JSON data or an Error. | |
*/ | |
async function getJSON(response) { | |
if (response.ok) { | |
const data = await response.json(); | |
return Promise.resolve(data); | |
} |
View index.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Users</title> | |
</head> | |
<body> | |
<h1>Users</h1> | |
<p>Check the JavaScript console.</p> |
View inspect.js
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 { inspect } = require('util'); | |
const restaurants = [ | |
{ | |
name: 'Nando\'s', | |
menus: { | |
starters: [ | |
{ name: 'Halloumi Sticks & Dip', price: 425 }, | |
{ name: 'Houmous with PERi-PERi Drizzle', price: 425 }, | |
{ name: 'Sweet Potato Wedges with Garlic PERinaise', price: 425 } |
View getTodaysDate.js
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
/** | |
* Get today's date. | |
* https://gist.github.com/kieranbarker/2c300d73059697a4417e12bd40cdef75 | |
* @returns {Date} A Date object representing today's date at midnight in UTC. | |
*/ | |
function getTodaysDate() { | |
const dateString = new Date().toISOString().slice(0, 10); | |
return new Date(dateString); | |
} |
NewerOlder