Skip to content

Instantly share code, notes, and snippets.

@leemartin
leemartin / meta-share.js
Last active Feb 11, 2021
Dynamic Meta Share Function
View meta-share.js
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">
@leemartin
leemartin / spotify-waveform.js
Last active Feb 21, 2021
Spotify Waveform Data Generation from Audio Analysis API
View spotify-waveform.js
const fs = require('fs')
const data = require('./track.json')
let duration = data.track.duration
let segments = data.segments.map(segment => {
return {
start: segment.start / duration,
duration: segment.duration / duration,
loudness: 1 - (Math.min(Math.max(segment.loudness_max, -35), 0) / -35)
@leemartin
leemartin / concert.json
Created Jun 23, 2020
Tour Data Concert
View concert.json
{
"id": "",
"artist_id": "",
"datetime": "",
"description": "",
"venue": {
"id": "",
"name": "",
"latitude": "",
"longitude": "",
@leemartin
leemartin / Scan.js
Created May 16, 2020
Basic Javascript hooks of Shelter In Space "Scanner" transition
View Scan.js
methods: {
beforeEnter(el) {
el.style.cssText = "clip-path: inset(0 0 100% 0)"
},
enter(el, done) {
let scan = { percent: 100 }
anime({
targets: scan,
percent: 0,
@leemartin
leemartin / Typer.vue
Last active May 16, 2020
The "Hitchhiker Typer" component used on Shelter In Space
View Typer.vue
<template>
<p><span class="start">{{ start }}</span><span class="end">{{ end }}</span></p>
</template>
<script>
export default{
props: {
phrase: {
type: String,
required: true
@leemartin
leemartin / countdown.vue
Created Oct 6, 2019
Luxon Vue Countdown
View countdown.vue
<template>
<time>{{ remaining }}</time>
</template>
<script>
import { DateTime, Duration } from 'luxon'
export default{
data() {
return {
@leemartin
leemartin / msToTime.js
Created Sep 14, 2019
Milliseconds to Timecode
View msToTime.js
let msToTime = (milliseconds) => {
let ms = milliseconds % 1000
let s = (milliseconds - ms) / 1000
let secs = s % 60
if (secs < 10) {
secs = `0${secs}`
}
@leemartin
leemartin / forecast.js
Created Aug 21, 2019
A Dark Sky serverless function for Netlify
View forecast.js
const fetch = require('node-fetch');
exports.handler = async (event, context) => {
try{
const latitude = event.queryStringParameters.latitude;
const longitude = event.queryStringParameters.longitude;
const response = await fetch(`https://api.darksky.net/forecast/${process.env.DARK_SKY_KEY}/${latitude},${longitude}`);
const data = await response.json();
@leemartin
leemartin / sign.js
Created Aug 10, 2019
Get presigned upload url for S3 compatible with Uppy and Netlify Functions
View sign.js
const AWS = require('aws-sdk')
const s3 = new AWS.S3({
accessKeyId: process.env.AWS_KEY,
secretAccessKey: process.env.AWS_SECRET,
useAccelerateEndpoint: true
})
const getSignedUrlPromise = (operation, params) => {
return new Promise((resolve, reject) => {
@leemartin
leemartin / Static.vue
Last active Aug 8, 2019
Vue Static Component
View Static.vue
<template>
<canvas ref="canvas"></canvas>
</template>
<script>
export default{
methods: {
generateNoise() {
this.noise = document.createElement('canvas')
this.noise.height = window.innerHeight * 2