Showing posts with label Web Development. Show all posts
Showing posts with label Web Development. Show all posts

Friday, August 29, 2014

Adding opensearch to your site

What is Opensearch?


Opensearch allows you to specify how queries are formed when searching a website. You can read the documentation at opensearch.org


How to install it?


This is how I have achieve it on my site


First add a autodiscovery link to your site pages



<link rel="search" type="application/opensearchdescription+xml" title="Rabin's blog" href="/opensearch.xml"/>


Next you need to define the open search document which will be in /opensearch.xml file in your website



<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Rabin's Blog</ShortName>
<Description>Search Rabin's Blog: </Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://www.rabinshr.com/favicons/favicon-16x16.png</Image>
<Url type="text/html" method="get" template="http://blog.rabinshr.com/?s={searchTerms}&amp;submit=Search"></Url>
</OpenSearchDescription>

That’s it. The next time you have loaded the page, you should be able to search your site by pressing tab on Chrome.


Happy coding!






via Rabin's blog

Thursday, June 12, 2014

Git rebase vs merge

I have been thinking about this for quite a while now. I have been doing merge and it always keep adding the merge commit which is good to keep track of the project history. However, I am more lenient towards git rebase as it keep the history flat and clean.



A typical git rebase example:


Lets say you start working on a feature enhancement



#Start a feature branch
git checkout -b feature
#commit
git commit -a -m "Feature added"

Now there is a sudden need to do a bug fix



#create bug fix branch
git checkout -b bugfix master
#commit
git commit -a -m "bugfix"
#merge back to master
git checkout master
git merge bugfix
git branch -d bugfix

Now that bugfix is merged with master, we rebase feature branch to keep our repo history flat and clean



git checkout feature
git rebase master

This will put the feature branch changes to the tip of master so we can do a standard merge from master once we are ready to commit feature changes.


Do you prefer git merge? and why?






via Rabin's blog

Wednesday, April 23, 2014

Twitter OAuth API package via Composer

I had been wanting to implement twitter’s follower count, statuses count on my website. Being a bit more familiar with composer, I went through and created a packagist which is avaiable via composer to be used on any site. The packagist is rather simple at the moment and allows only getting User Info at the [...]



via WordPress http://ift.tt/1iefmMA

Thursday, February 27, 2014

How to set SSL version when sending requests via SoapClient?

Every now and then you are required to work on a API which is pretty big. However, the SSL version they have used is depreciated one so you cannot use standard SoapClient class to communicate with them. The following snippet allows you to create your wrapper class which extends SoapClient and allows you to execute [...]



via WordPress http://ift.tt/1bQuJbQ

Monday, August 19, 2013

Building a LAMP system using Puppet

I have always been interested in sysadmin, however the thing that annoyed me was trying to remember the config file contents. Back in the day when I used to work for Boss Pacific Information Systems, I would find the idea of setting up servers very interesting. In the mean time, the tedious task of remembering which config file to change and what to change was a bit daunting.

Recently, I have been introduced to Puppet script which has been used in my work environment has proven its importance.
"Puppet manages your servers: you describe machine configurations in an easy-to-read declarative language, and Puppet will bring your systems into the desired state and keep them there."

This tutorial will show you how to create a simple puppet script to build a LAMP system which is the base for any web system. The components required for a web system such as apache, mysql etc are all available as modules from Puppet Forge

Thursday, August 8, 2013

Avoiding offset on tables with high volume data

In web development, it is common to be able to perform some action on each row of a high volume table. The first thing that comes to mind in doing this is fetching rows from the table in batches using LIMIT OFFSET,BATCH statement.

SELECT * FROM `table` LIMIT OFFSET,BATCH;


The flaw of this method is as the offset goes on increasing, it takes that much longer for the database engine to return the result. The reason being the engine has to go though all the rows to find that offset and then return the batch of records.

The solution would be to use a where clause on the primary key instead of offset:

Friday, August 2, 2013

Issues with having underscore in domain name

I have come across wierd hair scratching problems and this is one of them. Turns out, if there is an underscore in your domain/sub domain name, IE stops saving cookies. Which i have already mentioned in my earlier post title 'IE Why? Why?'.

Now another issue that I have noticed with underscore in domain is that PayPal will not accept this url as a valid url. So if your site has PayPal processing then it will error out.

All the fun with having underscore in domain names.

Monday, July 15, 2013

IE why? why?

Today, I came to know about another issue with IE browser. Apparently, IE browser does not allow cookies from sub domains that do not follow URI RFC. I wasted a few hours of my time trying to figure out why cookies were not working on my test site. Turns out this was the case.
IE why? why do you have to suck?