All work and no play makes Jack Dennis a dull null boy.
So one of the wonderful things about living here is that regardless the season we always have something great to do outside. During this time of year we go on a hike each Wednesday with a group of friends. Usually a great time to unwind and not have to think about anything work.
The trick or struggle always for me is to not think about anything work related and to just relax and enjoy the surroundings. I always enjoy spending the time outdoors whether on my bike, camping with family or on a hike like tonight. However without fail I am always working out a problem in my head at some point.
So I am proud to say that I actually made it through the hike without thinking about any problems I am currently working on. Breakthrough!!!
Tonight I created a new problem and worked on it during the hike. How is that for progress?
Recently I saw a demo on AngularJS and I was thinking on my hike how hard would it be to redo a jQuery plugin I did for displaying a twitter? The following is what I came up with:
Twitter Feed
- {{tweet.text}}
For now I was thinking of something really simple. Once I got it pulling data from twitter and displaying something I knew that the rest would come easy.
So before I get deep into the code of AngularJs let me give a sample of the jQuery plugin I had done awhile back.
(function($){ $.fn.minTweet = function(options) { var defaults = { tweets: 5, before: "
Probably not one of my greatest achievements but at the time of it's creation it was simple and served to solve a problem that I was working on at the time. Granted a majority of the code is that twitterTime()
function it always bothered me that I should have been able to make it simpler.
So would AngularJs save me or would my idea burn? Here is the javascript that I came up with.
function twitterFeed($scope, $http) { var url = 'https://api.twitter.com/1/statuses/user_timeline.json?callback=?&screen_name=dniswhite&count=1'; $http.jsonp(url).success(function(data,status){ $scope.tweets = data; }).error(function(data) { $scope.tweets = "Request failed"; }); }
For now I hardcoded the name of the twitter feed being retrieved to mine. As I went to test it I could see that the error()
function was being called. What could be wrong with my perfectly small piece of code?
Fire off my old jQuery plugin and sure enough it's no longer working. Did I ever deploy this code and if so what site did I deploy it on? Somewhere out there is a site with a broken twitter feed.
Take out the url from the code and lets give this a test.
{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}
So it appears that for now I am temporarily stuck and I will need to resolve the new API (this requires OAuth). I hate to end blogs without resolution so instead let me say "Stay Tuned"
Maybe it wasn't such a breakthrough to not think about problems during tonights hike.