Skip to content

Instantly share code, notes, and snippets.

View .gitignore
favicon.gif
favicon.ico
s
View keybase.md

Keybase proof

I hereby claim:

  • I am virtualwolf on github.
  • I am virtualwolf (https://keybase.io/virtualwolf) on keybase.
  • I have a public key ASD6EpSL0pY44AXCVwXwyg0ToM3XAvoD31nXVaT_LfmRQAo

To claim this, I am signing this object:

@VirtualWolf
VirtualWolf / callbacks.js
Last active Apr 11, 2020
getPhotoMetadata() before and after
View callbacks.js
// Original version using callbacks and the entire setup in a single giant function
getPhotoMetadata: (options, callback) => {
async.parallel({
exif: cb => {
jsonService.getJsonFromUrl(baseRestUrlService.getUrl('flickr')
.addQueryParam('method', 'flickr.photos.getExif')
.addQueryParam('photo_id', options.photoId),
(err, data) => {
if (err) { return cb(err, null); }
if (data.stat === 'fail') { return cb(data.message, null); }
@VirtualWolf
VirtualWolf / 01_callbacks.js
Last active Apr 11, 2020
sendUpdate() before and after
View 01_callbacks.js
// Original version using callbacks
sendUpdate: callback => {
const request = require('superagent');
HipChatWeather.find({})
.exec((HipChatWeatherModelError, results) => {
if (HipChatWeatherModelError) { sails.log.error(HipChatWeatherModelError); return callback(HipChatWeatherModelError, null); }
if (results.length === 0) { return callback(null, null); }
ninjaBlockService.getCurrentTemperatureAndHumidity({location: 'outdoor'}, (ninjaBlockServiceError, data) => {