Skip to content

Instantly share code, notes, and snippets.

View JMPerez's full-sized avatar

José M. Pérez JMPerez

View GitHub Profile
@JMPerez
JMPerez / web-api-create-playlist.js
Created February 27, 2015 10:08
Web API Support
var refreshToken = 'xxxxxxxxxx'; // obtained using Authorization Code flow
var spotifyApi = new SpotifyWebApi({
scope : ['user-read-private', 'user-read-email', 'playlist-modify-public'],
clientId : 'xxxxxxxxxx',
clientSecret : 'xxxxxxxxxxxxxxx'
});
// we set the refresh token that will be used to obtain a fresh access token
spotifyApi.setRefreshToken(refreshToken);
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../google-map/google-map-search.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@JMPerez
JMPerez / directions-map.js
Last active September 24, 2019 23:17
HTML5 geoposition + Google Geocoder as a fallback, used to show directions from user's current position to a given destination. See http://jmperezperez.com/google-maps-geolocation-directions-specific-destination/
(function() {
'use strict';
var map, //the google map
directionsService, //service that provides directions to reach our destination
directionsDisplay, //renderer that draws directions on map
destinationName = 'Ventorro del Cano, Madrid'; //our destination. Set yours!
// providers
var html5Provider = function() {
return {
@JMPerez
JMPerez / pre-commit
Created January 4, 2013 10:21
Javascript pre-commit hook
#!/bin/sh
files=$(git diff-index --name-only HEAD | grep -l '\.js$')
for file in $files; do
esvalidate $file
if [ $? -eq 1 ]; then
echo "Syntax error: $file"
exit 1
fi
done