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 __dirname = path.resolve( | |
import.meta.url.replace("file://", "").split("/").slice(0, -1).join("/") | |
) |
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
// Note that this uses the __dirname definition from here: | |
// https://gist.github.com/jrc03c/6fbccd5af3a4d1b61f12e1e620e1c01b | |
import { defineConfig } from "vite" | |
import path from "path" | |
const __dirname = path.resolve( | |
import.meta.url.replace("file://", "").split("/").slice(0, -1).join("/") | |
) |
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 express = require("express") | |
const fs = require("fs") | |
const http = require("http") | |
const https = require("https") | |
// create a basic HTTP app that just redirects requests from HTTP to HTTPS | |
const httpApp = express() | |
httpApp.use((request, response) => { | |
return response.redirect("https://" + request.hostname + request.url) |
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 ABOVE = "above" | |
const BELOW = "below" | |
const EXACTLY_ON = "exactly_on" | |
function getPointRelationToLine(point, pair) { | |
const [p1, p2] = pair | |
// if the pair have the same x-values, then they either lie on a | |
// vertical line or are identical | |
if (p2[0] - p1[0] === 0) { |
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
// 🚨 🚨 🚨 | |
// NOTE: According to MDN, `document.execCommand()` is deprecated. See: | |
// https://developer.mozilla.org/en-US/docs/Web/API/document/execCommand | |
// Instead, use the Clipboard API: | |
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API | |
// 🚨 🚨 🚨 | |
function copy(text) { | |
const input = document.createElement("input") | |
input.type = "text" |
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
################## | |
Basic Git Commands | |
################## | |
git init = turns the current working directory into a repository | |
git clone = downloads a remote repository to your machine | |
Syntax: git clone <source> <destination> | |
Example: git clone https://github.com/willfind/uplift-website /home/josh/projects/uplift.app |
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 downloadText(filename, text){ | |
const a = document.createElement("a") | |
a.href = "data:text/plain;charset=utf-8," + encodeURIComponent(text) | |
a.download = filename | |
a.dispatchEvent(new MouseEvent("click")) | |
} |
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 deepSort(x, fn) { | |
fn = fn || ((a, b) => (a < b ? -1 : 1)) | |
if (typeof x === "object") { | |
if (x === null) return x | |
if (x instanceof Array) { | |
return x.map(v => deepSort(v, fn)).sort(fn) | |
} | |
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 downloadCanvasAsImage(canvas, filename){ | |
let a = document.createElement("a") | |
a.href = canvas.toDataURL() | |
a.download = filename | |
a.dispatchEvent(new MouseEvent("click")) | |
} |
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 process = require("process") | |
const watch = require("@jrc03c/watch") | |
function rebuild() { | |
console.log("-----") | |
console.log(`Rebuilding... (${new Date().toLocaleString()})`) | |
try { | |
// do stuff... | |
console.log("Done! 🎉") |