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> | |
<head> | |
<title>Home</title> | |
<script src="redirect.js"></script> | |
</head> | |
<body> | |
<div>Blah</div> | |
</body> | |
</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
function anchorLinkHandler(e) { | |
const distanceToTop = el => Math.floor(el.getBoundingClientRect().top); | |
e.preventDefault(); | |
const targetID = this.getAttribute("href"); | |
const targetAnchor = document.querySelector(targetID); | |
if (!targetAnchor) return; | |
const originalTop = distanceToTop(targetAnchor); | |
window.scrollBy({ top: originalTop, left: 0, behavior: "smooth" }); |
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
# Dictionary to store stream responses in | |
responses = { | |
"123": [], | |
"456": [], | |
} | |
# Dummy stream | |
port_123_stream = ["I am a line", "I like cake", "Turtles too"] | |
port_456_stream = ["Some other line", "Pizza party", "Puppy power"] |
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
// Simple Markdown Parser | |
// Write a function that accepts a string containing a simplified | |
// version of markdown-formatted text, and returns a string | |
// containing the corresponding HTML text. We only need to support | |
// headers, paragraphs, and unordered lists. | |
// For example, this markdown: | |
// # This is a title! |
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 main | |
import ( | |
"embed" | |
"fmt" | |
"io/fs" | |
) | |
//go:embed template/* | |
var template embed.FS |
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 main | |
import ( | |
"gorm.io/driver/sqlite" | |
"gorm.io/gorm" | |
) | |
type Product struct { | |
gorm.Model | |
// gorm.Model adds ID, CreatedAt, UpdatedAt, DeletedAt |