Skip to content

Instantly share code, notes, and snippets.

@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
@leemartin
leemartin / spotify-client-credentials.js
Created Jan 5, 2019
Generate Spotify client credentials
View spotify-client-credentials.js
const axios = require('axios')
let CLIENT_ID="YOUR_CLIENT_ID"
let CLIENT_SECRET="YOUR_CLIENT_SECRET"
let auth = Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString('base64')
axios({
method: 'post',
url: 'https://accounts.spotify.com/api/token',
View create-apple-music-playlist.js
// initialize axios instance
let apple = axios.create({
baseURL: 'https://api.music.apple.com/v1',
headers: {
'Authorization': `Bearer ${developerToken}`,
'Music-User-Token': `${musicUserToken}`
}
})
// create playlist
You can’t perform that action at this time.