Skip to content

Instantly share code, notes, and snippets.

View justin-schroeder's full-sized avatar
🏗️

Justin Schroeder justin-schroeder

🏗️
View GitHub Profile
@justin-schroeder
justin-schroeder / closeJSON.ts
Last active December 4, 2023 15:52
JSON Completer (closeJSON)
/**
* Given an incomplete JSON string, return the string with the missing
* closing characters.
* @param str - An incomplete json string
*/
export function closeJSON(incompleteJson: string) {
let char = ''
let lastChar = ''
let chars = [...incompleteJson]
let isQuoted = false
@justin-schroeder
justin-schroeder / externalRedirect.ts
Created July 12, 2022 19:36
Perform an external redirect in Nuxt 3 router middleware
import { useNuxtApp } from '#app'
import { sendRedirect } from 'h3'
/**
* Performs an external redirect in a Nuxt3 route middleware. Once this Nuxt3
* pull request is merged, this function can be removed in favor of navigateTo:
*
* https://github.com/nuxt/framework/pull/5022
*
* @param url - An external url to redirect to
@justin-schroeder
justin-schroeder / index.html
Last active January 9, 2023 13:02 — forked from mdixon4/index.html
Using FormKit Via CDN
<!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>Sign up form</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@formkit/themes@next/dist/genesis/theme.css"
@justin-schroeder
justin-schroeder / token.ts
Created January 25, 2021 21:10
Random id, token, uuid generator (or whatever you want to call it)
/**
* Prouces a random token like token(5) = 1a4c9
* @param n {number} The length of the token
* @returns {string}
*/
const token = (n: number) =>
String.fromCharCode(
...new Array(n)
.fill(0)
.map(
@justin-schroeder
justin-schroeder / date-format.js
Last active January 20, 2020 15:58
JavaScript moment-js style date formatting function
/**
* Given a date, return a format. I've always wanted a cheap way to do this
* without installing a full library.
*
* Credit: https://gist.github.com/justin-schroeder/41505a6be88bfa25467e4ed5161608c2
*
* @param {Date} date
* @return {string}
*/
export function format (date, format) {
@justin-schroeder
justin-schroeder / gist:d3ef404e80a7ae658a8d
Last active August 10, 2018 19:54
Installing X-Sendfile on Mac OS X Yosemitee

Installing mod_xsendfile on Mac OS X (Yosemite) [Update: El Capitan]

Update: El Capitan follows the same procedures, but you may have some difficulty with the compile/install, see the secation at the bottom for specific help with El Capitan

Installing mod_xsendfile for apache is atually quite simple, however I could find very little documentation out there. Here's my attempt to help out. In order to proceeed you'll need: