benbeadle on March 18th, 2013

So I’ve started working on a project and have decided to go with Google App Engine as my backend. I must say, I have absolutely fallen in LOVE with the service! Anyways, I learned about their experimental Endpoints API, and decided to immerse myself in the wonderful documentation and absorb the API. I quickly fell in love with the simplicity of development and how powerful this service really is – It only takes a few lines of code in Javascript to use my new API!! Nevertheless, that’s for another time.

Part of my project also involves websockets, and since I am in love with Pusher, I started using the service  in my project. As I continued developing the web app (Google App Engine) and the client app (websockets), a part of the project was implementing Pusher’s new webhooks. After viewing the documentation for webhooks and the Channel Existence Event documentation, I attempted many times (over many hours) on how to develop my endpoint to handle the webhook. After many headaches, and the help of a friend, I figured it out! Perhaps, I was overlooking the simplicity, or failing to understand what was really going on, but I wanted to share my results with you in case you are in the same position I was in, especially since my copious amounts of Googling and researching returned very little helpful results. In this tutorial, I’m going to show you how to:

  1. Create the Endpoints API
  2. Configure Pusher to create the webhook
  3. Connect to Pusher
  4. Bonus: Use your new API in Javascript

Create the Endpoints API

To begin, I’m assuming you have created a Google App Engine application and have an app.yaml. Inside the app.yaml file, you need to add the endpoints api handler:

Once you have defined this, you can go ahead and actually create your Endpoints API, which should look something like this:

As you can see, I’ve created the Class and defined the webhook method which will execute when Pusher sends a request to your app. Take a look at lines 32 – 37. For an example, I actually am triggering an event to Pusher when a user connects to say hey and welcome. A couple of things: One, you obviously are going to need the Pusher class to enable this, which I found on Pusher’s Git. Two, I don’t suggest doing triggers like this since it makes a REST API call to Pusher and is bad practices. I suggest creating a task queue which processes this Trigger.

Once you have done this, go ahead and deploy to your app on GAE and check the logs to make sure everything is working correctly and no errors were found. If that’s the case, then go to: https://developers.google.com/apis-explorer/?base=https://[your-app-id].appspot.com/_ah/api and there you can view your API, which currently only consists of your pusher webhook. You can actually use this explorer to fake a pusher webhook request to make sure you get no errors.

Configure Pusher

Now it’s time to tell Pusher your webhook URL. There are many ways to find this URL. I suggest going to the explorer I just mentioned above and you can actually execute the API called and it will show you the url it POSTs to, which should be something like: https://[your-app-id].appspot.com/_ah/api/my_api/v1/pusher/webhook. Assuming you have created your app on pusher, go to the webhook page: https://app.pusherapp.com/apps/app_id/web_hooks. Under “Define a new WebHook”, add the api link, select the “Channel existence events” option and hit save.

 

Pusher  Webhooks Definition

Once you save, your new Webhook, you should be good to go! I suggest next going to the “Debug Console” tab and leaving it open so you can debug the next step easier.

Connect to Pusher

The next step is to actually connect to Pusher. This is naturally done in whatever language your application is in, but in Javascript, it looks something like this:

This will connect to pusher when executed. Once you go ahead and run the code, check out the Pusher Debug Console you left opened previously and make sure that you get the green box that says “Webhook sent”. If it’s not green, then hit the arrow on the left to see what data they are sending. Also, you can check the GAE logs to see the POST request from Pusher and hopefully get a glance of what went wrong.

Bonus: Use your new API in Javascript

So now you should be good to go connecting the Client, Pusher, and Google App Engine. The app I’m developing is partly Chrome extension, and I want access to other methods I have defined in my API. Google makes it so incredibly easy, that I’ll simply show you my code that allows me to make API calls.

First, you need to add the remote Google API:

Next, just call the load method and wait for it to load:

For a more in-depth look at using your API in Javascipt, check out the docs.

Conclusion

I hope this tutorial has made it a little easier on understanding how to use Pusher Webhooks with Google App Engine. I know for me, I wish I would have had more documentation specifically with GAE, so here it is, in my own words!

If you have any questions/comments, you can tweet me @benbeadle and I’ll respond promptly! Have a wonderful day!

 

Ben Beadle

For those of you who don’t know, Google Reader is an RSS Feed aggregator. You can keep up to date with your favorite websites which provide RSS feeds.

I’m currently subscribed to 36 websites. While some of those rarely have new content, according to Google Reader I have read almost 8,500 items in the past couple of days. That’s a lot of items to shift through!! As you can expect, I can get bogged down and days behind. This really unfortunate for some items which include sales of products for a single day. If I’m days late to reading that article, then I miss the opportunity for savings! This is also frustrating when sites post invite codes to new services which run out quickly because of the number of readers said site has. Doh!

This has been a frustration for a while and I’ve been trying to find ways of getting super important content to me as fast as possible. I’m not sure why I haven’t thought of it before, but using some tweaking and IFTTT, you can get important new content to you pretty fast without having to worry about getting behind in Google Reader. By adding certain subscriptions to a certain ‘watch’ folder, you can make that folder public and provide IFTTT with the RSS Feed Google provides to that folder so IFTTT can watch for certain keywords or phrases! Of course, if you subscribe to picture websites, then adding them to your ‘watch’ folder would be pointless.

This article assumes you have a Google Reader account already set up with some subscriptions and an IFTTT account.

Here’s how to get important new content texted to you:

  1. In Google Reader, roll over “Subscriptions” in the Navigation pane and click on the down arrow that shows up on the right.
  2. Find a subscription that you would like to add to your ‘watch’ folder and click “Change Folders” and then at the bottom hit “New Folder”. You can call this folder whatever you want, I just chose to call it ‘watch’ since it’s basically what the folder is for: IFTTT to ‘watch’ for new updates.
  3. Next, add all other subscriptions you would like to said ‘watch’ folder.
  4. Once you are done adding subscriptions, you need to make the ‘watch’ folder public. Click on the “Folders and Tags” tab and click the little RSS Feed icon (next to “private”) for your ‘watch’ folder.
  5. Links will appear on the same line. Click the “view public page” link which will open a new tab, and then copy the “Atom Feed” link. This is the RSS Feed link you will provide IFTTT.
  6. Now, checkout this recipe on iFTTT: Text me when there’s a new (public) Google Reader item matching ‘…’. Use this Recipe to monitor your RSS Feed with whatever word / phrase you would like!

Hopefully this can help some people who’s, like me, Google Reader gets backed up and you miss important posts in time!

Ben Beadle

benbeadle on December 17th, 2012

Probably my favorite class this semester was Information Storage and Retrieval. The class taught many ways to use data and turn it into more than just data. We learned how to classify and cluster text, rank documents in searches, and recommend items by analyzing previous data. We got some great insight as to how Google works and some of the things that makes their search engine so good. Overall, it was an awesome class and James Caverlee was an awesome professor! So good, in fact, I’m taking Big Data with him in the Spring!

Anyhow, our main project at the end of the semester was to somehow use what we’ve learned in class and apply it to something real world. So my partner, Amanda Cofsky, and I set out to find the project we wanted to work on. We wanted it to be fun and actually be useful and entertaining. We had Twitter in the back of our heads and knew that we wanted to somehow incorporate Twitter in our app.

Amanda came up with the idea to use the show My Little Pony: Friendship is Magic as the basis for our show, and so we began to ponder what we could do that related to My Little Pony. After pondering for a little bit, I figured it out. I know there were quizzes that helped you find what pony you are most similar to, but no apps that automated the process by analyzing your tweets. That, my friends, is how Pony Placement Project was born! This nifty app automatically finds what pony you are most like by analyzing your tweets!

 

The application, which is Ruby on Rails, uses Cosine Similarity and kNN Classification to compare your tweets to the transcripts of My Little Pony. For every tweet, it compares the text to over 7,000 lines of transcripts to find the kNN closest lines. It then adds up the similarity values and finds which pony you are most like! If you would like, you can view the source code over on Github.

 

So now, all that’s left is for you to find your inner pony via Pony Placement Project!

 

- Ben Beadle

benbeadle on November 25th, 2012

I have had an iPhone for over 2 years. I got the iPhone 4 and of course immediately jailbroke it to allow much more use of the hardware. All of the devices I own have been hacked or personalized in some way. I want my devices exactly how I like it and if I have to hack it to enable functionality – then I will.

I got the iPhone 5 the day it came out and loved the extra screen real estate and upgraded hardware. I was patiently waiting for a jailbreak to come out, being that Apple and AT&T limit certain functionality of the iPhone because they want control over what their users do with the device. The excessive restrictions Apple has put on iPhone, and iOS in general, has been a huge pain and annoyance for me. You can do so much more with the iPhone, but Apple simply restricts the use. This is a useful marketing scheme for Apple because it maintains the basic functionality of the phone allowing them to create the brand iPhone.

A couple weeks after I got my iPhone, I was talking with a friend about his Android. We compared functionality of iOS vs Android and I was amazed at what Android users can do – without even having to hack the phone! I can quickly list numerous apps that are just sitting in the Google Play store that Apple would never in a heartbeat allow to be in the Apple App Store. It was so frustrating to be sitting there with the iPhone 5 (unjailbroken) and not being able to do half the things my friend’s Android could do. The level of integration Android brings between the OS, apps, and hardware is incredible which is something Apple strongly avoids.

Other than seeing what Android could do right out of the box, I had always wanted the ability to develop for my phone. Since I had the iPhone, I wasn’t able to program mainly because iOS development requires a Mac to develop on. Being unable to program for my phone was a huge upset and limitation. At the same time, knowing that Android’s development is in Java (which I have experience with) made it that much more appealing.

So between seeing what possibilities Android and the open market provides compared to Apple, it was a no brainer for me. Sure, for users who don’t want to be able to hack their phones and use them to their fullest potential the iPhone is an awesome phone. However, for users like myself who want to dig a little deeper, the iPhone is simply too limiting. And not only that, but when the iPhone is jailbroken, it’s slows down the phone tremendously and kills the battery life.

So as a recap, here are the reasons I sold my iPhone 5 for an Android (with a couple extra reasons):

  1. iPhone development requires knowledge of objective-C and a Mac. Android development is open to major operating systems and uses Java.
  2. Hacking the iPhone slows down the phone tremendously and still doesn’t provide the level of access Android apps do.
  3. The Google Play store has apps that would never be allowed in the iOS store. The reasoning is because Android is open and provides an SDK apps can use to control most all services of the phone.
  4. In the end, I actually made a profit by selling my iPhone and buying an Android. So not only did I get the phone I wanted, but I made money doing it!
  5. Google offers many services which can be integrated into the phone that the iPhone doesn’t allow. One example is Google Music which stores all of my music in the cloud that I can stream whenever I want, also allowing the use of downloading certain songs so I don’t have to stream every time.
  6. I can customize my phone in ways I never imagined. I can install completely different OS versions (I currently have Jellybean installed when the stock rom is Ice Cream Sandwich).

When all of these points come together – it was a no brainer to sell my iPhone and buy an Android. Sure, the Android phone I have may not be as nice as the iPhone 5, the battery may not last as long, there may be a few bugs, etc, but I am so willing to give all of that up for a phone I’m actually proud to use and that allows me to make it how I want it without having to jump through loops because of the restrictions.

benbeadle on September 26th, 2012

This past summer, on a random Sunday morning when I was at church, I was thinking about ways that I learn. Since I am a huge computer/tech nerd, I tried to think of ways I could use technology to memorize scripture since I love being around / using technology. That morning started what was a huge train of thought into how I could use Twitter to help me memorize Scripture.

I wanted a way to make the Scripture come to me so I was forced to look at it. I started thinking about how I could use the power of Twitter to make it happen, and Weekly Bible Verse was born.

Weekly Bible Verse is an app that I wrote that works on my server in the background. What it does it tweets a Bible Verse three times a day – every day. As the week progresses, the application removes words from the Bible Verse and replaces them with blanks (____) and then tweets that. By Sunday, the tweet is full of blanks and hopefully you have memorized it the through the entire week and can still recite it!

I am hoping that this application can help you with memorization and help use technology to learn the Lord’s Word.

I also know that people have different preferences of Bible translations and therefore wanted to give access to different translations. The current translations available are: ESV, KJV, NASB, NIV, NLT, and NRSV. You can follow the corresponding account depending on what translation you want!

To learn more, check out the page for Weekly Bible Verse.

Ben Beadle

benbeadle on September 23rd, 2012

There was a bug which would not allow the extension to load properly. 1.1 fixes this issue and you can install it here.

Ben Beadle

benbeadle on September 8th, 2012

So when it comes to my iTunes songs, I get pretty OCD and want every song to have lyrics. This way I can sing along to songs I don’t know the words to while also helping me learn the words! :)

Unfortunately, I haven’t found a viable application to automatically download lyrics that integrates with iTunes. I decided to develop a Chrome Extension to help simplify copying lyrics to the clipboard in one click. Enter LyricMe.

LyricMe is a Chrome Extension that allows you to search only supported sites and then allows you to either view the lyrics in a simple interface, or copy the lyrics to your clipboard in one click.

To learn more about LyricMe, check out the homepage.

I hope you find it useful!

- Ben Beadle

benbeadle on August 12th, 2012

Around the middle of last semester, I learned about a sleep cycle that allowed you to only sleep 2 hours a day and still get the REM cycle you need. As far as we know, this is completely healthy and the remaining sleep that one normally uses when not in REM cycle is basically a waste of time. Fascinated with this concept, I did research to learn more about it and how it works. I was at the point where I was done researching and came to the conclusion this was awesome and wondered what it would be like. Productivity would be through the roof! The image below shows that with the decrease of core sleep time, and the increase of nap times spread throughout the day, you could technically sleep 2 hours a day and be fine (as far as we know). That is 22 hours a day of productivity! WHAT!?

Polyphasic Sleep Cycle

Courtesy of dustincurtis.com

 

Well this summer, I got to thinking. I realized that this option would not only be amazing for the summer, since outside of work I only had like 7 hours of awake time and of those 7 hours, I was usually hanging with friends or doing something social. Because of this, I had no time to do the things I love such as programming.

I began doing a little more research and found that my fall semester coming up, giving a little sleep manipulation, allowed for me to do the The Everyman 3-nap sleep cycle. Now, there are many many different patterns someone can follow. Each pattern depends on the person and how their body adapts.The sleep cycle I have chosen is 2 1.5 hour core naps, and then take 3 (roughly) 20 minute naps throughout the day. I have not pinpointed my exact times, but have talked with someone on a forum who has done polyphasic sleep cycle to get his opinion on it all and help me out which has been a great help.

So, I have decided I am going to do it. There is no better time than in college to experiment, so why not give this a try? It probably won’t be easy, but it’ll be an awesome experience. As you can imagine, the beginning few weeks are going to be miserable since you are completely changing how you are sleeping. This is going to be the worst part, and to help better transition this, I’ve been suggested to try another sleep pattern for a couple of days and then transition to my real polyphasic sleep cycle. So, to begin, I am staying awake for roughly 24 hours. After that, I am going to take a 26 minute nap every 3 hours. The number 26 is relative. As I’m going through this process, I’m going to fine tune it to find what works for me since each person is different. After a couple of days, I can finally transition to my permanent schedule.

Now, I know there are debates on whether this is a healthy sleep cycle. I know there’s pros and cons and this sleep schedule might make it a little difficult to work around others’ schedules. I also know that there will be times I need to do things, but will have to take a quick nap. It’s not going to be easy, but hopefully I will find most of it beneficial and worth it. While some people found this sleep schedule didn’t work for them, most of what I read said that they could never go back to a monophasic sleep cycle.

So there you have it. My new sleep cycle that you are probably scratching your head calling me crazy, and maybe I am. But maybe I will find that I love this sleep cycle since it gives me more time to be productive and do things rather than feeling like I’m constrained to sleeping at night or else I will be dead tired the next day.

I will definitely keep my blog updated under the Polyphasic category so you can know what’s going on and how I’m doing with the whole process.

 

Wish me luck!

- Ben Beadle

 

Update: Well I have been adapting since Sunday, so about 3 days. I’ve been thinking about it and weighing out the pros and cons of this sleep schedule. A major con I’ve noticed is the time taken away from hanging with other people because I have to go take a nap. For example, I have planned on taking a core nap in the evenings. Which would then take away from dinner or really anything I would want/need to do. All of this to only gain 2-4 hours of awake time?

While I absolutely love the idea of Polyphasic sleeping and under the right circumstances it could definitely be a good solution for someone, I have decided I am no longer going to pursue this type of sleep cycle.

It’s been short lived, but even still a learning process.

benbeadle on June 21st, 2012

For those of you who know me, I am all about efficiency and automation. I love writing scripts, usually making things more difficult than it should be, simply so I have to do one less monotonous task. I will go out of my way simply to remove that one thing I do all the time so I never have to worry about it again.

I also love integrating services to make my life simpler. Being able to enable all of my web services I use on a daily basis to talk to each other is extremely powerful. One example is whenever I star an item on Google Reader, I want it to be emailed to me for later viewing. That way I can continue going through my Google Reader and all of the items I want to read later are in one place for my viewing pleasure.

Enter IFTTT. IFTTT is an amazing web application that does just this. It integrates the services you use on a daily basis to complete monotonous tasks so that you don’t have to. It combines two things I love using technology for!! What could get better?

Once you create an account, you will need to read up on the terms you will find through out the site which you can find here. Now, assuming you read up on that, let’s dig in to using IFTTT.

You should check out what Channels there are. There are a ton and most likely all of the ones you want are available for you to use. Anything you can imagine using these services can probably be automated. From triggering Recipes according to the Date & Time, to triggering Recipes when you are tagged into Facebook, to getting push notifications using Pushover (pushover.net) or Boxcar (boxcar.io), the possibilities are endless! Per the time of writing this blog post, there are 51 channels available for your use.

I could go into a lot more detail about about how IFTTT works, but I figured you should dive right in by creating your first recipe and browsing IFTTT to learn more. There is so much you can do with this extremely powerful web app that it’s impossible to sum up!

Here are some of the Recipes I’ve created and use to make my life much simpler:

So those are some of recipes I personally use. You should totally give IFTTT a try and have fun with it! There’s so much you can do with IFTTT, you are bound to find a recipe that does exactly what you want it to.

- Ben Beadle

benbeadle on June 10th, 2012

So I’ve gotten many questions as to what an RSS feed actually is. The cool cats over at How-To Geek just posted this awesome explanation, including how to use Google Reader to subscribe to RSS Feeds of your favorite websites. Here’s a quick explanation:

RSS allows web sites to push out content in a standardized format commonly called a feed. This feed can be subscribed to by anyone with internet access and an appropriate tool called a feed reader. Accessing these RSS feeds is free and many popular and robust feed readers…are also free.

For an example of an RSS feed, you can check out my very own RSS feed which shows all of my posts in chronological order. You can use a feed reader like Google Reader to subscribe to my feed. Whenever I post a new article, it shows up in your Google Reader for your viewing pleasure.

I use the ever popular Google Reader to subscribe to 44 feeds (at the time of this writing) and it only increases as I find websites that post relevant material to my interests. I actually had an idea for a website that did this before I learned about Google Reader. Could you imagine visiting 44 websites daily to catch up on their newest articles? That makes me cringe at the thought! I absolutely love Google Reader and it makes sure I don’t miss an article that my top websites post. Sure, I go through hundreds of feed items a day, but I wouldn’t have it any other way.

 

- Ben Beadle