Today, while digging routing guides of Ruby on Rails, I spot this new feature which is available in Ruby on Rails 4. Routing Concern is a wonderful concept of re-using routing definitions. I just love how Rails try to reckon on DRY principle. I’ve worked in a project where routes.rb has about 50 lines of definition while the project was progress not more than 20%. There were many similar routing definitions in different scopes (namespaces). Routing Concerns will now enable us write less codes to define application routes.
I’m not going to show how to use it as Rails guide already did the job. I’m simply copying the codes over here.
I’ve also found this blog shared on facebook by one of my friend
Recently, I’ve worked with Tastypie which is my first introduction to tastypie. Tastypie itself is wonderful and very easy to work. However, my first catch was that I’ve to use it in a scenario where data source is not django’s ORM. My goal is to expose some API endpoints but the data will come from some other external API. Confusing? Let’s discuss about the implementation not about the wisdom of use cases. If you do not have introduction to the Tastypie, please have a look at their documentation.
Generally, when we create a Tastypie resource, our class inherits ModelResource. ModelResource is actually provides django’s ORM specific accesses as the resource is created on top of Django models. The fact is that, ModelResource is a thin wrapper on top of it’s Resource class and overrides few methods. If we want to use our custom data sources, we will have to override some methods of this Resource class based on our requirements. The methods we have to override are:
Well, first thing first. This blog may be little bit immoral even if it is not illegal by the provider terms of service. So, if you read this or later sentences, the responsibilities are on you.
I am going to share an idea that I’ve personally used a bit ago (2009) in my previous office to monitor the server and get notified when any server/service is down. I wrote a small PHP application that would do the tasks. Though I planned that time to blog about it, apparently, I forgot about it. The steps of the idea is:
A php chunk checks server status
If it finds something unexpected (or may be expected; depends on your logic :)) it creates an event in your google calendar which is due just 1-3 minutes from now
If your SMS alert is setup in Google Calender, Google will email you about the event.
Here I will not show how to write a PHP script to monitor server. I just told it as I applied this idea for same purpose. I guess you will get lots if you google it. However, the initial version that I developed just checked site’s homepage (using CURL) and if they were returning 200 response within a sensible time limit. If the response was not 200, it would create the event for me.
How to create Event?
It’s very simple. First of all download the following classes from phpclasses.org
WordPress 3.0 is still in RC1. I have already upgraded this blog to this version. I can’t but simply love the new theme ‘Twenty Ten’ which is default in WordPress 3.0. It is super simple theme.
In this theme, there is option to use custom header image. From the admin panel you can select the header image. However, all of the default banners looked interesting to me and I have also uploaded some of my own shots. I wanted to show them all.
Keeping that in mind, I made this simple plugin, Twenty Ten Image Rotator. Having this plugin installed, you can show all images on the header. Single banner each selected randomly on each page load.
I believe if you love Twenty Ten theme, you will love this plugin too :).
Just now Hasin Hayder, author of multiple books, has published a blog post how to host any wordpress.com blog virtually anywhere you wish. Using this simple script, you can host any wordpress.com blog in your own domain.
He wrote a simple proxy script and some codes in .htaccess file. Then the proxy script will fetch all contents from your original blog and show in your site.
Suppose, you have a blog in WordPress.com which URL is www.rajuru.wordpress.com. Using this script, you can host this same blog to somewhere like www.yourdomain.com.
The script does not yet support commenting. Currently it will redirect you to original blog for comment. But the author has just confirmed me that he will implement this part very soon.