Skip to content

Instantly share code, notes, and snippets.

View mager's full-sized avatar
🏠
Working from home

Mager mager

🏠
Working from home
View GitHub Profile
@mager
mager / 3-way-switch.groovy
Created September 22, 2014 18:07
SmartThings SmartApp for 3-Way Switch
/**
* 3-Way Switch
*
* Copyright 2014 Andrew Mager
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@mager
mager / instaspot-03-index.html
Created August 23, 2014 04:05
instaspot-03-index.html
<!doctype html>
<html ng-app="instaspot">
<head>
<title>instaspot</title>
<link href="http://fonts.googleapis.com/css?family=Lato:300,400,700|Karma:400,700" rel="stylesheet" type="text/css" />
<style type="text/css">
body {padding:0;margin:0;font-weight:300;font-family:Lato;}
a {color:#39f;}
header, section {padding:5px 20px;}
@mager
mager / instaspot-02-index.html
Created August 23, 2014 03:47
instaspot-02-index.html
<!doctype html>
<html ng-app="instaspot">
<head>
<title>instaspot</title>
</head>
<body>
<header>
<h1>instaspot<span> Find the most popular photos and videos on <a href="http://www.instagram.com">Instagram</a> (refresh for more)</span></h1>
</header>
<section ng-controller="ShowImages as images">
@mager
mager / instaspot-01-application.js
Created August 23, 2014 03:21
instaspot-01-application.js
(function(){
var client_id = '451cf9fc4a0a44379d699e4ca48d58fb';
var app = angular.module('instaspot', []);
app.factory("InstagramAPI", ['$http', function($http) {
return {
fetchPopular: function(callback){
var endpoint = "https://api.instagram.com/v1/media/popular";
endpoint += "?count=99";
endpoint += "&client_id=" + client_id;
endpoint += "&callback=JSON_CALLBACK";
@mager
mager / instaspot-01-index.html
Last active August 29, 2015 14:05
instaspot-01-index.html
<!doctype html>
<html>
<head>
<title>instaspot</title>
</head>
<body>
<header>
<h1>instaspot<span> Find the most popular photos and videos on <a href="http://www.instagram.com">Instagram</a> (refresh for more)</span></h1>
</header>
<section>
@mager
mager / spotify-apps-tutorial-get_songs_from_playlist.html
Created March 22, 2012 01:13
Spotify Apps API - Get songs from a playlist URL (HTML)
<ul id="playlist"></ul>
@mager
mager / spotify-apps-tutorial-get_songs_from_playlist.js
Created March 22, 2012 01:12
Spotify Apps API - Get songs from a playlist URL
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var playlist_url = 'http://open.spotify.com/user/jkeck99/playlist/21iMSq0jzTie7m7v4UcMlV';
var pl = models.Playlist.fromURI(playlist_url, function(playlist) {
for(i=0;i<playlist.tracks.length;i++){
var link = '<li><a href="' + playlist.tracks[i].uri + '">' + playlist.tracks[i].name + '</a></li>';
$('#playlist').append(link);
@mager
mager / spotify-apps-tutorial-playlist_mosaic.html
Created March 10, 2012 18:59
Spotify Apps API - Show a playlist mosaic image
<div id="image"></div>
@mager
mager / spotify-apps-tutorial-playlist_mosaic.js
Created March 10, 2012 18:56
Spotify Apps API - Show a playlist mosaic image
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var views = sp.require("sp://import/scripts/api/views");
var playlistURL = 'spotify:user:magerleagues:playlist:5CZ3KO3EExplZOzHDMzgym';
var playlist = models.Playlist.fromURI(playlistURL);
playlist.observe(models.EVENT.CHANGE, function() {
var mosaic = new views.Image(playlist.image);
mosaic.node.style.width = '300px';
@mager
mager / spotify-apps-sandbox-top_artists_tracks.js
Created February 25, 2012 22:10
Spotify Apps API - Get the top five tracks from five artists (JS)
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var views = sp.require("sp://import/scripts/api/views");
var artists = ['Frank Sinatra', 'Drake', 'T-Pain', 'The Lonely Island', 'Avan Lava'];
var playlist = [];
var done = 0;