Skip to content

Instantly share code, notes, and snippets.

View leemartin's full-sized avatar

Lee Martin leemartin

View GitHub Profile
@leemartin
leemartin / ProgressCircle.vue
Created March 24, 2024 15:40
A progress circle Vue component powered by CSS conic gradient
<template>
<div class="h-full rounded-full w-full" :style="conicGradient"></div>
</template>
<script setup>
// Props
const props = defineProps({
color: {
type: String,
default: '#000000'
@leemartin
leemartin / PanelTransition.vue
Created December 20, 2023 16:43
Vue Sci-Fi Blinking Panel Transition
<template>
<Transition :css="false" @before-enter="onBeforeEnter" @enter="onEnter" @before-leave="onBeforeLeave" @leave="onLeave" mode="out-in">
<slot></slot>
</Transition>
</template>
<script>
import gsap from 'gsap'
export default {
@leemartin
leemartin / Marquee.vue
Created August 10, 2023 15:31
Vue Marquee Component
<template>
<div id="marquee">
<div class="inner">
<div class="message">{{ message }}</div>
<div class="message">{{ message }}</div>
</div>
</div>
</template>
<script setup>
@leemartin
leemartin / weather.js
Created June 26, 2022 13:54
Apple WeatherKit REST API Netlify Function
const axios = require("axios")
const jwt = require("jsonwebtoken")
const handler = async (event) => {
try {
// Decode private key
const privateKey = Buffer.from(process.env.WEATHERKIT_KEY, 'base64').toString()
// Get team, key, and app id
const teamId = process.env.WEATHERKIT_TEAM_ID
@leemartin
leemartin / encode.js
Last active June 26, 2022 13:55
Encode Apple Private Key as Base64 String
// Require file system module
const fs = require("fs")
// Read private key from file
const privateKey = fs.readFileSync("AuthKey_0000000000.p8").toString()
// Encode private key into Base64 string
const buff = Buffer.from(privateKey).toString('base64')
@leemartin
leemartin / PanelTransition.vue
Created June 22, 2022 13:22
Planet Zero Observer Panel Blink Transition
<template>
<Transition :css="false" @before-enter="onBeforeEnter" @enter="onEnter" @leave="onLeave" mode="out-in">
<slot></slot>
</Transition>
</template>
<script>
import gsap from 'gsap'
export default {
@leemartin
leemartin / desaturate.js
Created February 21, 2022 18:00
Desaturate Canvas
let desaturate = (canvas) => {
// Get canvas image data
let imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height)
// Get all pixels
let pixels = imageData.data
// Loop through pixels
for (let i = 0; i < pixels.length; i += 4) {
// Adjust lightness
@leemartin
leemartin / AudioSpectrum.vue
Created February 20, 2022 17:53
Vue Paper.js Audio Spectrum Visualizer
<template>
<div id="spectrum">
<canvas ref="canvas"></canvas>
</div>
</template>
<script>
import paper from 'paper'
export default {
@leemartin
leemartin / get-token.js
Created May 25, 2021 15:46
IBM Watson Token Requester
const { IamTokenManager } = require('ibm-watson/auth')
const sttAuthenticator = new IamTokenManager({
apikey: process.env.SPEECH_TO_TEXT_IAM_APIKEY
})
const handler = async (event) => {
try {
let { result } = await sttAuthenticator.requestToken()
@leemartin
leemartin / meta-share.js
Last active February 11, 2021 17:40
Dynamic Meta Share Function
const handler = async (event) => {
const subject = event.queryStringParameters.name || 'Tony'
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">