Skip to content

Instantly share code, notes, and snippets.

Lee Martin leemartin

Block or report user

Report or block leemartin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@leemartin
leemartin / create-spotify-playlist-with-artwork.js
Last active Dec 8, 2018
Create Spotify Playlist with Artwork
View create-spotify-playlist-with-artwork.js
// initialize axios instance
let spotify = axios.create({
baseURL: 'https://api.spotify.com',
headers: {
'Authorization': `Bearer ${token}`
}
})
// get user id for playlist creation
spotify.get('/v1/me').then(res => {
@leemartin
leemartin / Palette.vue
Created Sep 20, 2018
Turn Palette Color Picker
View Palette.vue
<template>
<ul>
<li v-for="color in colors" :style="{ background: `rgb(${color[0]},${color[1]},${color[2]})`}" @click="selectColor(color)"></li>
</ul>
</template>
<script>
export default{
props: ['colors'],
methods: {
@leemartin
leemartin / instagram-dl.js
Created Sep 11, 2018
Download Instagram Videos
View instagram-dl.js
// node instagram-dl.js BnmcJ-tnAey
const rest = require('restler')
const fs = require('fs')
const request = require('request')
rest.get(`https://www.instagram.com/p/${process.argv.slice(2)[0]}/?__a=1`).on('complete', function(data) {
var videoUrl = data.graphql.shortcode_media.video_url
var videoFilename = videoUrl.split("/")[videoUrl.split("/").length - 1]
@leemartin
leemartin / listen.js
Created Sep 7, 2018
Figma x Turn x Codepen
View listen.js
const app = new Vue({
el: '#app',
data() {
return {
figmaToken: '',
baseUrl: 'https://api.figma.com/v1',
fileId: '',
nodeId: '',
images: null,
nodes: null
@leemartin
leemartin / musickit-token-encoder.js
Last active Aug 24, 2019
Apple Music API Token for MusicKit
View musickit-token-encoder.js
"use strict";
const fs = require("fs");
const jwt = require("jsonwebtoken");
const privateKey = fs.readFileSync("AuthKey.p8").toString();
const teamId = "ABCDE12345";
const keyId = "ABCDE12345";
const jwtToken = jwt.sign({}, privateKey, {
You can’t perform that action at this time.