Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrew Mager mager

🏠
Working from home
Block or report user

Report or block mager

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
@mager
mager / index.html
Created Apr 14, 2011
Polymaps example for shading polygons
View index.html
<!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 Feb 10, 2012
Spotify Apps API - Play/pause with an HTML element (JS)
View spotify-apps-sandbox-click_to_play.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 Apr 12, 2018
Example SF GeoJSON polygon
View sf.json
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 Feb 10, 2012
Spotify Apps API - Get the currently playing track (JS)
View spotify-apps-sandbox-current_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 Feb 2, 2018
Compile & deploy a BigGame contract
View deploy.js
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 Feb 2, 2018
Testing a lottery contract (snippet)
View lottery.test.js
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 Feb 1, 2018
Inbox contract example
View inbox.sol
pragma solidity ^0.4.18;
contract Inbox {
string public message;
function Inbox(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {
@mager
mager / spotify-apps-sandbox-Facebook_get_listening_history.js
Created Feb 10, 2012
Spotify Apps API - Get a user's listening history from Facebook (JS)
View spotify-apps-sandbox-Facebook_get_listening_history.js
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var auth = sp.require('sp://import/scripts/api/auth');
var permissions = ['user_actions.music'];
var app_id = '126891607432106';
var request_url = 'https://graph.facebook.com/me/music.listens';
auth.authenticateWithFacebook(app_id, permissions, {
onSuccess : function(accessToken, ttl) {
View ex-stats-tracker-usage.ex
iex> ExStatsTracker.counter(your_key, 1)
iex> ExStatsTracker.increment(your_key)
iex> ExStatsTracker.gauge(your_key)
iex> ExStatsTracker.timing(your_metric, 1)
iex> ExStatsTracker.histogram(your_metric, 1)
iex> ExStatsTracker.meter(your_metric, 1)
View ex-stats-tracker-config.ex
config :ex_stats_tracker,
host: “your.statsd.host.com”,
  port: 1234,
  prefix: “your_prefix”
  flush_interval: 10000
  chunk_size: 20
You can’t perform that action at this time.