Catching up!

A lot has changed since the last blog post (more than three years). I was happily running a successful business around Videocache till Google decided to push HTTPS really hard and enforced SSL even for video content. That rendered Videocache completely useless as YouTube video caching was the unique selling point. Though people are still using it for other websites (whatever supported and not HTTPS yet), I personally didn’t find it good enough for selling. To add to the trouble, Mozilla and friends announced that there will be free certs for everyone. Now, that took away whatever motivation was left to keep working on Videocache. I decided to open source Videocache and the source is now available on GitHub. If you have better ideas or you are looking forward to make things work by forging certs etc, fork it and give it a shot.

After all that mess with Videocache, I am left with a contract job which is not working out well. So, the learning hat is back and I am trying to catch up with the tech world. I didn’t really want to get into the whole JavaScript framework mess because there is no clear winner and there are too many of them but it looks rather unavoidable or Unflushable (if you remember Jeff from Coupling). I have been trying to make simple apps with Angularjs. There is little documentation and you have to dig really deep at times but still you can make things work if you persist. Once you spend some quality time with it, you may actually start liking Angularjs. So, I did give it some time and implemented angular fronted for Pixomatix-Api (another learning project I am working on) and I think I sort of like it now.

In 2015, if you are web developer, you must know how APIs work and you should be able to consume them. So, to learn to expose APIs and version them properly, I fired a small project Pixomatix. Being a Rails developer, you really get obsessed with it and try to implement everything using Rails. Even when you want an API with 2-3 endpoints, you tend to make the horrible mistake of doing it in Rails. This kept bugging me and a few weeks later, I decided to freshen up my Sinatra memories. But working with Sinatra is not all that easy especially if you are used to all the niceties of Rails. Dug up my attempt of implementing Videocache in Ruby, and extracted few tasks and configurations I had automated long time ago. Ended up working a lot more on it and packages into a template app with almost all the essential stuff. Though I need to document it a little more, the app has got everything needed to expose a versioned API via Sinatra.

On the other hand, I tried to use devise gem to authentication for Pixomatix. It was all good for integration with standard web apps and APIs but it sort of failed me when I tried to make the API versioned. Devise turned out to be black-hole when I tried to dig deeper to make things work. I tried a few other gems which supported token authentication but they were also no good for versioning. Generally, you may not need to version the authentication part of your API, but what if you do! Since, this was just a learning exercise, I was hell bent on implementing this. So, I just reinvented the wheel and coded basic authentication (including token authentication) for the API.

That’s it for this post. I am looking forward to post regularly on the new stuff I learn.

 

Javascript To Remove All Facebook Apps From Your Account

This is a guest post by Gaganpreet Arora AKA bitgeek.

My Facebook app list was cluttered with useless apps accumulated over the time I had joined Facebook. The worst thing is that Facebook does not allow you to remove multiple apps in one go. You have to select one, confirm on “Are you sure?” first and then click on “Okay” when it is deleted. Very cumbersome. So I wrote a Javascript hack to remove all of the apps in one go.

Warning: This will actually delete all the apps

Step 1

Go to: http://www.facebook.com/editapps.php?v=allowed.

Step 2

Select and copy the complete code below and paste it into the address bar.

javascript:
function postwith (to,p)
{
  var myForm = document.createElement("form");
  myForm.method="post" ; myForm.action = to ;
  for (var k in p)
  {
    var myInput = document.createElement("input") ;
    myInput.setAttribute("name", k) ;
    myInput.setAttribute("value", p[k]);
    myForm.appendChild(myInput) ;
  }
  document.body.appendChild(myForm) ;
  myForm.submit() ;
  document.body.removeChild(myForm) ;
}
 
function getElementsByClassName(classname, node)
{
  if (!node)
  {
    node = document.getElementsByTagName('body')[0];
  }
  var a = [], re = new RegExp('\\b' + classname + '\\b');
  els = node.getElementsByTagName('*');
  for (var i = 0, j = els.length; i < j; i++)
  {
    if ( re.test(els[i].className) )
    { a.push(els[i]); }
  }
  return a;
}
 
var arr = [];
els=document.getElementsByClassName('app_row');
arr['fb_dtsg']=document.getElementsByName('fb_dtsg')[0].value;
arr['remove'] = 1;
arr['post_form_id_source']='AsyncRequest';
arr['post_form_id'] = document.getElementById('post_form_id').value;
arr['app_id']=els[0].id.replace("editapps_allowed_","");
arr['__a'] = 1;
for (i=0; i
<h3><span style="text-decoration: underline;"><strong>Step 3</strong></span></h3>
Press Enter.
 
The browser may get stuck for a few moments if the list is large, so if it does, just wait a bit and it will respond back.
<h3><span style="text-decoration: underline;"><strong>References</strong></span></h3>
Function postwith was taken from <a href="http://mentaljetsam.wordpress.com/2008/06/02/using-javascript-to-post-data-between-pages/">here</a>, and getElementsByClassName was taken from <a href="http://snipplr.com/view/1696/get-elements-by-class-name/">here</a>.
 

News : Memepress (Yahoo! Meme) WordPress Plugin Version 0.3 is available

Memepress is a wordpress plugin which provides wordpress widgets for displaying public posts from Yahoo! Meme. Memepress is SEO ready and provides options to noindex/nofollow your Meme posts. New version fixes a few bugs and provides enhanced style control for the widget.

You can download memepress version 0.3 from wordpress plugin page.

For details on usage/installation instructions, please check plugin homepage.

 

How To: Install PHP 5.3 on CentOS 5.1 or RHEL 5.1

PHP 5.2 and PHP 5.3 has tons of functionalities which are not provided by PHP 5.1 and PHP 5.1 is the most recent version of PHP available in CentOS 5.1 and RHEL 5.1 via updates. Also, its difficult for people to upgrade OS(s) on production servers frequently and especially if the servers are running absolutely fine, it doesn’t really make sense to upgrade just for the heck of it. One more reason for no upgrades is the OS choices provided by many hosting companies. But a lot of CMS(s) and softwares are now recommending at least PHP 5.2 for an extended feature set.

I tried a lot of repos for CentOS including RPM Fusion, RPM Forge, EPEL etc., but none of them could provide even PHP 5.2. In some corner of my mind, I had a faint idea of Remi Collet publishing updates about Remi repository. Did a quick google search and found out that PHP 5.3 is actually available in the repository 😀

So, if you are really in need of PHP5.3 on your CentOS/RHEL 5.1 or lesser, head over to Repository Configuration Page and follow the instructions.

Note: The repository is not enabled on install (enabled=0). You need to enable it in /etc/yum.repos.d/remi.repo.

Once installed and enabled, you can update PHP, MySQL from remi repository using the following command

[root@fedora ~]$ yum update php php-* mysql-*

Warning: Drupal is still not totally compatible with PHP5.3 and if you run Drupal sites, be sure to investigate things before upgrading.

 

Memepress Ready to be Translated (Supports Turkish now)

Thanks for an awesome response to the Memepress (Yahoo! Meme) WordPress plugin. A lot of people have blogged about it and contacted me via email for enhancements. New version also fixes the bug regarding image size in posts. I have also updated the plugin to support internationalization(i18n). Now you can translate about 20 strings in your local language and you’ll have Memepress in your own language.

Turkish Translation

Huge thanks to Yalçın Erdemir for translating the plugin to Turkish 🙂

How To Translate

If you are interested in translating Memepress plugin in your language, then download the memepress.pot (POT file) and open it in your favourite text editor. Now for every string against msgid should be translated to your language and populated in quotes against msgstr. See the example below.

Before translation

#: memepress.php:37
msgid "Title"
msgstr ""

After translation

#: memepress.php:37
msgid "Title"
msgstr "_WHATEVER_TITLE_IS_WRITTEN_AS_IN_YOUR_LANGUAGE_"

Once you are done with translating all the strings, save the file and mail me at kulbirsaini25 [AT] gmail.com .