Monitoring a webpage for changes

I have been following Reconstructing Ruby articles to create a Ruby VM from scratch just to learn the process of creating a VM and the tools involved. I would like to be notified when a new article appears on the scene.

RSS feed?

I wish I could use RSS for it, but this particular side doesn’t have any rss feeds. Also, the author of these articles updates the page with the links to the new article, so I’d probably need something that checks the page for changes and notifies me of the changes.

So, you gonna write one yourself, right?

Not so fast. Like all good developers, I thought of googling to see if there’s a solution for this out there and google didn’t disappoint. I found Page monitor chrome extension that not only polls for the changes, it also allows the user to configure when and how they want to be notified of the changes. I have been using the extension for few weeks now and it works like a charm. You should give it a try too.

Leave a comment

First impressions of AngularJS

Do you care about view markup in your applications?

I do to an extent that anything, even slightly, untidy leaves be deflated. Then one day, I had to work with this AngularJS application, and it was overwhelming, to say the least.

AngularJS builds on the promise of improving the HTML markup and making it more expressive. However, my first impression was ‘What the hell is this mess!’. My friends, don’t judge a book by it’s cover, so I still gave my best shot and dug a bit deeper to find out that it’s not bad. To be honest, it’s quite powerful and expressive, and for what it provides with this nice little framework is pretty cool. It’s quite similar to another framework from Google guys, called, Polymer.

I have only touch the surface of AngularJS and once I let my first impressions go, I could see the power beneath the surface. I will be working with it more in the near future and post my thoughts on it again.

Tagged | Leave a comment

Ultrahook and GET requests

A couple of months ago, I wrote about testing Stripe’s webhooks with Ultrahook.

Just this week, I found out while trying to run a GET request against Ultrahook, that it doesn’t allow GET requests for security reasons. May be give ngrok a try for testing GET requests to your localhost. Webhook calls are POST requests and Ultrahook is as good as gold for that use-case.

Tagged , | Leave a comment

When Zeus doesn’t work…

Do you work with Rails? and is it not a brand spanking new Rails 4, but the older and less-loved, relatively speaking, version?

Then, you must have come across Zeus. It’s pretty handy if you like to test drive your code from outside-in and aren’t scared to venture into the dark and a tad dragging land of integration specs. A normal Zeus workflow is, to start the server first, and then issue commands to the server from the client. Simple!

However, it’s not always like it. You may come across unhelpful error messages, like the following when you start the server:

1.

exit status 1 and then run tests.

2.

Could not find 'zeus' (>= 0) among 214 total gem(s) (Gem::LoadError)

Both the error messages are quite random. Googling the first one will reveal a lot of reasons and ways to fix it, second one is just a normal gem error message when the gem is not found. In both the cases, I found the reason for the error to be some gems missing from project’s bundle and installing those gems fixes the issue.

So, next time when you pull upstream changes, and Zeus stops working, try running bundler’s install command.

Hope it helps.

Tagged , , | Leave a comment

Convert SVG to PNG on Mac OS X

Android’s WebView is very primitive in terms of rendering SVG images as the background. I decided to convert them into PNGs and test their rendering. I don’t have photoshop, and I could have used ImageMagick to convert SVGs to PNGs, but whilst googling I found another nifty utility to achieve the same, qlmanage.

In Mac OS X, Quick Look allows one to quick preview files. qlmanage is a tool used by Quick Look internally to generate the images for the preview.

Please note that it may be limited with how much it can achieve and is definitely not comparable to something like ImageMagick, but still nifty when you don’t have anything else installed on your machine.

Hope it helps.

Posted in Programming, Tech | Leave a comment

Test Google Places API locally

Yesterday I had a chance to try out Google Places API. Quite detailed as you’d expect from Google. But, before integrating it with the code you really want to try it out.

When I say try it out, I mean just ‘curl’ an end-point in the terminal and inspect the results. With Google API’s you can create a server key (an API key) and at the time of it’s creation you specify IP address for the server where requests would be made from. In order to test it locally, just find out your IP address, either using whatsmyipaddress service if you don’t have a static IP address, and then just use that IP address as the server address.

Now, you can use any tool (or may be just use a GET end-point in your browser) to see the results.

Hope it helps.

Posted in Programming | Leave a comment

CSS issues in Android WebView prior to 4.4(kitkat)

Should you venture into developing a hybrid app for Android WebView in versions before 4.4?

NO. Unless you liked fixing bugs for IE6 when you knew that IE8 or IE9 were a bit better and people should just upgrade their browsers. Although, upgrading OS on devices running Android is quite complicated, and should be dealt in a separate post.

With 4.4, the WebView uses Chromium rendering engine, which is most up-to-date and implements the HTML, CSS, and JS specs correctly. Anything before that used a native Android rendering engine which was buggy and didn’t implement the spec properly. Now, the ‘business’ won’t like you distancing yourself from the older versions because as it happens, a lot of users are still running the older version, for example, 4.3, and 4.2.2.

What can you do in such a scenario?

There’s not much you can do, really. Bite the bullet and fix them bugs. With hybrid apps, you can use Android specific stylesheets (in Cordova) to workaround the problems. Android forums aren’t of much help because they simply refuse to backport any bug fixes made in 4.4 (since the whole WebView implementation has been re-written), and your best resource is StackOverflow.

Device (hardware), OS, and screen size for Android can result in endless permutations, and making a choice of supported devices and getting things to look and work consistent across all the possible combination is crazy. It’s like browser wars amplified.

Posted in Programming | Tagged | Leave a comment

Stripe and Currency conversion charges

Stripe is pretty awesome.

The integration is simple. Documentation is ample.

It just works!

But, do you know how Stripe works out currency conversion charges?

Being a SAAS company means anyone can pay for your service and although you don’t really need to know how the charges work, but it’d be nice if you know how many customers you really need before you make any profit. For you to calculate that number, you need to know how much are you making from one customer every month.

Whilst thinking about it, I came up with a few scenarios. I also made an assumption that in order to attract more customers, you preferred to create your plans in USD:

1. Your Stripe account is set up in GBP. User pays for a plan (in USD) with their local currency which is also USD. How many times does Stripe charge currency conversion fee? Once – to convert the USD’s to GBP’s for you to withdraw, right?

2. Your Stripe account is set up in GBP. User pays for a plan (in USD) with their local currency which not USD (could be any currency). How many times does Stripe charge currency conversion fee now? Twice – to convert the non USD’s to USD’s and then those to GBP’s for you to withdraw, right?

Confusing, isn’t it?

Well, Stripe is very reasonable. It never does what they call a ‘double dip’ when it comes to currency conversion charges. It only charges you currency conversion once when it converts the USD’s (which is what your plans are set up in) to GBP’s (what’s your account in set up as).

How can you save some of money on currency conversion?

Well, if you know where bulk of your customer segment is (I know I said SAAS kind of means you are open for business with anyone in the world), but let’s say for instance you did have that information you can always set up your plans in that currency. The saving won’t be huge, but something is better than nothing, right?

Hope it helps.

Tagged | Leave a comment

With koudoku, integrating Stripe payments in Rails is a doddle

Most, if not all, SASS applications need some sort of payment integration to charge customers for subscriptions and repeatedly do it every month (or year or any time interval). if you are looking for one such payment-subscription solution, then Stripe is what you need. Stripe has awesome documentation, amazing dashboard, and the ability to test everything out is icing on the cake. I’ve not had the chance to try any other Stripe like payment integration services and I’m sure they provide similar features. Anyways, today it’s about Stripe, and a lovely little gem called koudoku.

Koudoku is a Rails engine, and gives you all the subscription related stuff that you may ever need. For example: Signing-up with a particular plan, upgrading a plan for a user. It creates customers, charges cards, and updates subscriptions through Stripe’s APIs. You never have to worry about all that. The gem does all that for you. It has customisable views, just like devise, which you can style the way you like. Only one drawback is the support for webhooks is a bit sparse. Only supports three events right now, but the documentation does make that fact very clear.

However, there are a few gotchas:

1. In order to create some testing users, with subscriptions, you need to make sure they are linked to actual customers on the Stripe side, otherwise you will see the following error:

Stripe::InvalidRequestError: No such customer

The best thing to do is create some customers on Stripe in test-mode, and use their id’s when create users with subscriptions.

2. To get the webhooks working, I had to subclass the koudoku webhooks controller, and add the following line of code:

skip_before_filter :verify_authenticity_token

3. Stripe will call your webhooks end-point to notify of the various events on a customer, for example, payment succeeded, charge failed and so on. You can take the appropriate action, for example, to send invoice, or email admin in response to it. I found two very nice resources to test your localhost webhook with Stripe. I presume both use reverse ssh-tunnelling, but they work out of the box, and one is even a rubygem. I used ultrahook, but also found ngrok a little later.

In all, it took me one evening to set-up and test the whole thing end-to-end. It’s so easy that it should be called Stripe-asy!

Hope it helps.

Posted in Programming | Tagged , , | 3 Comments

Writing a Cordova plugin for iOS

There are a tons of articles out there to help you in writing a plugin. Cordova’s documentation is detailed and very helpful too, but it’s easy for you to get buried under the documentation and go right past the nifty quirks of the framework. Here’s my few tips which may come handy for you when writing a cordova plugin:

  • If you know a little bit of Objective-C syntax, it will help. It depends upon the kind of plugin you writing. If your plugin is going to dip down in the native iOS world, then Objective-C knowledge is a must. However, I had to do a very trivial thing in the plugin, so I got by fine.
  • Read and learn from other cordova plugins. There are a ton of plugins and reading their code will definitely help you in creating a successful plugin yourself.
  • Use Xcode to run your hybrid application. I can see people raising their eyebrows to that statement, but, the latest Xcode has command line tools and cordova leverages them heavily. That means, I could develop the application, run, test it in emulator without ever opening Xcode. But, with plugins, you want to run the application through Xcode to see errors on the native side.
  • Lastly, plugin.xml is the metadata file, similar to gemspec file in the Ruby world. plugin.xml allows one to write config that ends up getting used by Xcode, so make sure you have the correct interface name that you’d like to access from the javascript side.
  • And that’s it. Surely, you will stumble upon some yourself.

Posted in Programming | Tagged , , | Leave a comment