Skip to content

Instantly share code, notes, and snippets.

View tylerforesthauser's full-sized avatar

Tyler Forest-Hauser tylerforesthauser

View GitHub Profile
@wobsoriano
wobsoriano / auth.js
Last active February 29, 2024 07:37
nuxtServerInit like implementation for Pinia
import { defineStore } from 'pinia'
export const useAuthStore = defineStore({
id: 'auth',
state: () => ({
isAuthenticated: false,
user: null
}),
actions: {
async nuxtServerInit() {
@leeroybrun
leeroybrun / deploy-pm2.md
Last active August 6, 2024 03:53 — forked from hoangmirs/deploy-pm2.md
Deploy pm2 guide
@tspvivek
tspvivek / directus_mover.sh
Last active June 27, 2023 03:09
Directus postgres DB - Script to move schema changes between different servers without replacing data
#!/bin/sh
start=`date +%s.%N`
SRC_CONNECTION_STRING="postgresql://src_username:src_password@src_host/src_dbname"
DST_CONNECTION_STRING="postgresql://dst_username:dst_password@dst_host/dst_dbname"
rm src_schema.sql
rm src_data.sql
rm dst_data.sql
@BrianHung
BrianHung / codemirror-syntax-highlight.ts
Last active March 19, 2024 19:53
ProseMirror CodeBlock Syntax Highlighting using CM6
import {LanguageDescription, LanguageSupport} from "@codemirror/language"
import {languages} from "@codemirror/language-data"
import {highlightTree} from "@codemirror/highlight"
import {highlightStyle} from "./highlight-style"
export function syntaxHighlight(text: string, support: LanguageSupport, callback: (token: {text: string; style: string; from: number; to: number}) => void, options = {match: highlightStyle.match}) {
let pos = 0;
let tree = support.language.parseString(text);
highlightTree(tree, options.match, (from, to, classes) => {
from > pos && callback({text: text.slice(pos, from), style: null, from: pos, to: from});
@workatease
workatease / index.js
Last active May 4, 2025 20:56
directus - Google reCaptcha v2 using auth.login.before api hook for validation for custom login
// extensions/hooks/google-recaptcha-v2/index.js
module.exports = function registerHook({ env, exceptions }) {
const querystring = require("querystring");
const axios = require("axios");
const { BaseException } = exceptions;
const VERIFY_ENDPOINT = "https://www.google.com/recaptcha/api/siteverify";
return {
"auth.login.before": async function (input) {
const captcha = input["g-recaptcha-response"];
if (captcha) {
@ben-rogerson
ben-rogerson / twin.code-snippets
Last active June 16, 2023 02:22
Twin Code Snippits for use in vscode - Shortcuts that make working with Twin a little easier
{
// Snippits that make working with Twin a little easier
// https://github.com/ben-rogerson/twin.macro
"Add react import": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "react",
"body": "import React from 'react'",
"description": "Add react import"
},
"Add twin imports": {
@jengel3
jengel3 / auth.js
Last active November 2, 2025 20:26
Vue/Nuxt JWT Authentication Implementation
// store/auth.js
// reusable aliases for mutations
export const AUTH_MUTATIONS = {
SET_USER: 'SET_USER',
SET_PAYLOAD: 'SET_PAYLOAD',
LOGOUT: 'LOGOUT',
}
export const state = () => ({
@RaddishIoW
RaddishIoW / RelativeTime.jsx
Last active April 1, 2023 00:01
A React Hooks-based component using Luxon to format a date to a relative string representation, updating that string once a minute.
import React from 'react'
import PropTypes from 'prop-types'
import { DateTime } from 'luxon'
const RelativeTime = (props) => {
const dt = DateTime.fromJSDate(props.time)
const [relTime, setRelTime] = useState(dt.toRelative())
const [intervalID, setIntervalID] = useState()
useEffect(() => {
@GavinRay97
GavinRay97 / guide.md
Last active January 4, 2022 05:38
Configuring Nuxt for Composition API and TSX Support

Main

EDIT: DO NOT USE THIS. THIS WAS FROM WHEN ALL OF THIS WAS NEW/EXPERIMENTAL AND NOT OFFICIALLY SUPPORTED. PLEASE SEE THE LINK BELOW FOR THE PROPER, EASIER INTEGRATION NOWADAYS =)

Use create-nuxt-app and enable the Typescript related options to scaffold a new boilerplate TS Nuxt repo:

yarn create nuxt-app 

Converting Tailwind UI Alpine transitions to Vue transitions

After you copy a component from the Tailwind UI library and begin to adapt it from Vue JS to Alpine JS .. you may wonder what to do about the transitions. As I'm exploring this myself, I am documenting it for others in the same boat.

Things to be aware of:

  • Alpine calls the beginning and ending states "start" & "end"
  • Vue calls the beginning and ending states "from" and "to"
  • Alpine has inline "directives" ie x-transition:enter="classes"
  • Vue has a wrapper component that applies classes to the child
  • Alpine applies the classes you pass it for each state, :enter-start="class"