Skip to content

Instantly share code, notes, and snippets.

View rdegges's full-sized avatar

Randall Degges rdegges

View GitHub Profile
@rdegges
rdegges / app.js
Created July 21, 2017 01:32
Crypt Compare getColor
/**
* Return a CSS color (either red or green) depending on whether or
* not the value passed in is negative or positive.
*/
getColor: (num) => {
return num > 0 ? "color:green;" : "color:red;";
}
@rdegges
rdegges / index.html
Created July 21, 2017 01:27
Crypto Compare table.
<table class="table table-hover">
<thead>
<tr>
<td>Rank</td>
<td>Name</td>
<td>Symbol</td>
<td>Price (USD)</td>
<td>1H</td>
<td>1D</td>
<td>1W</td>
@rdegges
rdegges / app.js
Created July 21, 2017 01:21
Crypto Compare setInterval
/**
* Once the page has been loaded and all of our app stuff is working, we'll
* start polling for new cryptocurrency data every minute.
*
*/
setInterval(() => {
app.getCoins();
}, UPDATE_INTERVAL);
@rdegges
rdegges / app.js
Created July 21, 2017 01:16
Crypto Compare created hook.
let app = new Vue({
// ...
created: function() {
this.getCoinData();
}
});
@rdegges
rdegges / app.js
Created July 21, 2017 01:12
Crypto Compare getCoinImage
getCoinImage: function(symbol) {
return CRYPTOCOMPARE_API_URI + this.coinData[symbol].ImageUrl;
}
@rdegges
rdegges / app.js
Created July 21, 2017 01:07
Crypto Compare getCoinData
getCoinData: function() {
let self = this;
axios.get(CRYPTOCOMPARE_API_URI + "/api/data/coinlist")
.then((resp) => {
this.coinData = resp.data.Data;
this.getCoins();
})
.catch((err) => {
this.getCoins();
@rdegges
rdegges / app.js
Last active July 21, 2017 01:07
Crypto Compare getCoins
getCoins: function() {
let self = this;
axios.get(COINMARKETCAP_API_URI + "/v1/ticker/?limit=10")
.then((resp) => {
this.coins = resp.data;
})
.catch((err) => {
console.error(err);
});
@rdegges
rdegges / app.js
Created July 21, 2017 00:50
Crypto Compare Vue app.
/**
* Our Vue.js application.
*
* This manages the entire front-end website.
*/
// The API we're using for grabbing metadata about each cryptocurrency
// (including logo images). The service can be found at:
// https://www.cryptocompare.com/api/
let CRYPTOCOMPARE_API_URI = "https://www.cryptocompare.com";
@rdegges
rdegges / cryptocompare-api-example.sh
Created July 21, 2017 00:39
Crypto Compare API example.
$ curl https://www.cryptocompare.com/api/data/coinlist
{
...
"Data": {
"AVT": {
"Id": "138642",
"Url": "/coins/avt/overview",
"ImageUrl": "/media/1383599/avt.png",
"Name": "AVT",
"CoinName": "AventCoin",
@rdegges
rdegges / example.sh
Created July 21, 2017 00:28
coinmarketcap API example
$ curl https://api.coinmarketcap.com/v1/ticker/?limit=10
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "2747.54",
"price_btc": "1.0",
"24h_volume_usd": "2242640000.0",