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 / resorts.csv
Created June 16, 2011 21:15
All the (good) ski resorts in the US
name is_partner latitude longitude
49 Degrees North 1 48.302353 -117.5640
Afton Alps 0 44.854332 -92.79063
Alpine Meadows 1 39.148201 -120.1509
Alpine Mountain 0 41.114666 -75.22602
Alpine Valley 0 41.526939 -81.25988
Alpine Valley 0 42.653999 -83.56510
Alpine Valley 0 42.735901 -88.42818
Alta 1 40.583828 -111.6372
Alyeska Resort 1 60.961445 -149.1026
@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 / clapper.ino
Last active November 5, 2022 08:26
Smart Clapper Arduino sketch
/*
* SmartThings Clapper
* Author: Gilbert Chan
* Update: 10/18/14
* Contributors: Manoj Kunthu, Andrew Mager
*/
#include <SoftwareSerial.h>
#include <SmartThings.h>
@mager
mager / index.html
Created April 14, 2011 16:55
Polymaps example for shading polygons
<!DOCTYPE html>
<html>
<head>
<title>San Francisco Street Pavement</title>
<script type="text/javascript" src="https://github.com/simplegeo/polymaps/raw/master/lib/protovis/protodata.js"></script>
<script type="text/javascript" src="https://github.com/simplegeo/polymaps/raw/master/polymaps.js"></script>
<style type="text/css">
@import url("https://github.com/simplegeo/polymaps/raw/master/examples/example.css");
@mager
mager / spotify-apps-sandbox-click_to_play.js
Created February 10, 2012 19:30
Spotify Apps API - Play/pause with an HTML element (JS)
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var player = models.player;
$('#play-me').click(function(){
player.playing = !(player.playing);
if (player.playing == true) {
$('#play-me').empty().append('Playing!');
} else {
@mager
mager / sf.json
Created April 12, 2018 17:54
Example SF GeoJSON polygon
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mager
mager / spotify-apps-sandbox-current_track.js
Created February 10, 2012 18:22
Spotify Apps API - Get the currently playing track (JS)
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
// Get the track that is currently playing
var currentTrack = models.player.track;
// If nothing currently playing
if (currentTrack == null) {
$('#now-playing').append('No track currently playing');
@mager
mager / deploy.js
Created February 2, 2018 13:42
Compile & deploy a BigGame contract
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const source = fs.readFileSync(bigGamePath, 'utf8');
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { MNEMONIC, INFURA_HOST } = process.env;
const provider = new HDWalletProvider(MNEMONIC, INFURA_HOST);
const web3 = new Web3(provider);
@mager
mager / lottery.test.js
Last active February 2, 2018 13:36
Testing a lottery contract (snippet)
it('allows an account to enter', async () => {
await lottery.methods.enter().send({
from: accounts[0],
value: web3.utils.toWei('0.015', 'ether'),
});
const players = await lottery.methods.players().call({
from: accounts[0],
});
const balance = await lottery.methods.getBalance().call({
@mager
mager / inbox.sol
Created February 1, 2018 15:09
Inbox contract example
pragma solidity ^0.4.18;
contract Inbox {
string public message;
function Inbox(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {