Raymond camden electricity billy elliot karaoke with lyrics

##########

I’ve been playing with the Marvel API for quite some time now ( “All My Friends are Superheroes”, “Building a Twitter bot to display random comic book covers”, “Using the Marvel API with IBM Watson”, and “Exampled of the Marvel API”) and I find myself coming back to it from time to time to just see what cool stuff I can find in their database. Unfortunately it looks like Marvel isn’t really doing anything new with their API lately, but at least it still works and I guess that’s something. k electric company duplicate bill A few weeks ago I thought it would be an interesting experiment to see if you could automate visualizing the changes of a character over time. So what do I mean?

I just love seeing the progression of style over the decades especially with such an iconic character. I decided to try to figure out a way to automate this and display it to the user. gas prices map Now, before I go any further, let me state that I’m not going to run this demo “live”. electricity in costa rica for travelers Why? First – I’m still not 100% sure how to stay “safe” in the free tier with Azure Functions. Last month I got a bill for 40 dollars because I made a wrong selection in a project and while that’s my fault, I still feel a bit burned by it. gas constant in kj Secondly, Marvel themselves have a limit on their API usage. It’s a fair limit of course, but it’s also something I just don’t want to worry about. gas urban dictionary If either Microsoft or Marvel want to help me out here, just drop me a line! I won’t hold my breath. 😉 That being said, all of the code I’m about to show can be found at my GitHub repo here: https://github.com/cfjedimaster/marvelcharacterovertime The Back End

My back end is built using Azure Functions. This was the first time I made use of Visual Studio Code integration and damn did it work well. british gas jokes I think it took maybe twenty minutes of setup or so but once done, it was one quick command to deploy to Azure when I had updates. It was also easy to run the code locally. electricity wikipedia in hindi From my limited experience so far, this is the best way to work with Azure Functions (obviously if you are a Code user) and it’s what I plan on using in the future.

const rp = require ( ‘request-promise’ ); const API_PUB_KEY = process . env . API_PUB_KEY ; const API_PRI_KEY = process . env . API_PRI_KEY ; const crypto = require ( ‘crypto’ ); module . exports = async function ( context , req ) { if ( req . query . name ) { let name = req . query . name ; let baseUrl = `https://gateway.marvel.com:443/v1/public/characters?nameStartsWith= ${ encodeURIComponent ( name )} &apikey= ${ API_PUB_KEY } ` ; let ts = new Date (). getTime (); let hash = crypto . createHash ( ‘md5’ ). update ( ts + API_PRI_KEY + API_PUB_KEY ). digest ( ‘hex’ ); baseUrl += "&ts=" + ts + "&hash=" + hash ; //console.log(‘baseUrl’, baseUrl); return rp ({ url : baseUrl , json : true }). then ( res => { //console.log(res.data); let results = []; if ( res . data . total > 0 ) { results = res . data . results . map ( r => { return { id : r . id , name : r . name , thumbnail : r . thumbnail . path + ‘.’ + r . thumbnail . extension }; }); } context . res = { // status: 200, /* Defaults to 200 */ body : results , headers : { ‘Content-Type’ : ‘application/json’ , ‘Access-Control-Allow-Origin’ : ‘*’ } }; }); } else { context . res = { status : 400 , body : "Please pass a name on the query string" }; } };

This one is the easiest as all it needs to do is use the characters endpoint with the nameStartsWith argument. This will let you enter a value, like ‘spider’, and get results. The stuff with the time and hash is simply part of Marvel’s API security which frankly feels like overkill but there it is. I get the results and then map it down a bit to remove a lot of data I don’t need. This makes the communication between Azure Functions and my web app a lot zippier as I’m not returning unnecessary data.

Marvel doesn’t have an API that returns covers with certain characters, but you can search comics for a character and I figured that would be close enough. In order to get my data, I thought I’d search for a year’s worth of data for results including a character. Unfortunately, the character API doesn’t return when a character was first seen. So in order to estimate that, I did a search with a date range from 1950 to 2090. electricity in water experiment Please feel free to come find me in 2090 and complain.

*/ if ( req . query . id ) { let id = req . query . id ; return new Promise (( resolve , reject ) => { // ok – try to get first issue let baseUrl = `https://gateway.marvel.com:443/v1/public/comics?dateRange=1950-01-01%2C2090-01-01&characters= ${ id } &orderBy=onsaleDate&apikey= ${ API_PUB_KEY } ` ; let ts = new Date (). getTime (); let hash = crypto . createHash ( ‘md5’ ). update ( ts + API_PRI_KEY + API_PUB_KEY ). digest ( ‘hex’ ); baseUrl += "&ts=" + ts + "&hash=" + hash ; //console.log(‘baseUrl’, baseUrl); rp ({ url : baseUrl , json : true }). then ( res => { let firstDate = ” ; if ( res . data && res . data . results && res . data . results . length > 0 ) { let firstResult = res . data . results [ 0 ]; // from what I know the type is always onsaleDate firstDate = new Date ( firstResult . dates [ 0 ]. date ). getFullYear (); } // no firstDate? if ( firstDate === ” ) { context . res = { body : { result :[]}, headers : { ‘Content-Type’ : ‘application/json’ } }; resolve (); //not sure I need this return ; } //temp hack: //firstDate = 2015; //get this year let thisYear = new Date (). getFullYear (); console . log ( ‘going to go from ‘ + firstDate + ‘ to ‘ + thisYear ); let coverCalls = []; for ( let x = firstDate ; x { console . log ( ‘in the all for calling covers’ ); let results = []; //each index of data is year X, we will return the: year, [title, cover] for ( var x = 0 ; x { console . log ( ‘error’ , e ); }); }); }); } else { context . res = { status : 400 , body : "Please pass an id (for the character) on the query string" }; } };

//const searchAPI = ‘http://localhost:7071/api/searchCharacters?name=’; //const coverAPI = ‘http://localhost:7071/api/getCharacterCovers?id=’; const searchAPI = ‘https://marvelcomicchar.azurewebsites.net/api/searchCharacters?name=’ ; const coverAPI = ‘https://marvelcomicchar.azurewebsites.net/api/getCharacterCovers?id=’ ; const app = new Vue ({ el : ‘#app’ , data : { needCharacter : true , character : ” , currentCharacter : ” , characterSearching : false , noCharacters : false , characters : [], loadingCharacter : false , loadingCovers : true , covers : [], noCovers : false }, methods : { search : function ( event ) { if ( event ) event . preventDefault () if ( this . character === ” ) return ; console . log ( ‘search for ‘ + this . character ); this . noCharacters = false ; this . characterSearching = true ; fetch ( searchAPI + encodeURIComponent ( this . character )) . then ( res => res . json ()) . then ( res => { this . characterSearching = false ; if ( res . length === 0 ) this . noCharacters = true ; console . log ( res ); this . characters = res ; }); }, loadChar : function ( c ) { console . log ( ‘load’ , c . id , c . name ); this . currentCharacter = c ; this . needCharacter = false ; this . loadingCharacter = true ; fetch ( coverAPI + encodeURIComponent ( c . id )) . then ( res => res . json ()) . then ( res => { this . loadingCovers = false ; if ( res . length === 0 ) this . noCovers = true ; //console.log(res); // todo, remove http://i.annihil.us/u/prod/marvel/i/mg/b/40/image_not_available.jpg this . covers = res . result ; }); }, reset : function () { console . log ( ‘reset here’ ) } } });