Monday, December 29, 2008

PHP in Blogger: In all Pages!

Note: I assume you are hosting your blogger blog from your own web server (i.e. you use ftp publishing and not a subdomain on blogspot.com)

This is an alternate method to add PHP code to your blogger blog. This method works across all pages and not just the index page (contrary to the method outlined in the last post).

Add this line to your .htaccess file:

AddType application/x-httpd-php .html

What this does is tells the webserver to process all html files as PHP files. This means that the web server will process any php code in the html files (just anything within <? ?> the tags ). So now you can add PHP code to you blogger template, and it will work universally throughout your blog - but you will take a performance hit (since even static html pages will not be parsed and processed as PHP code) and also a possible security risk (anything within <? ?> will now be executed as PHP code).

One option against this problem would be to restrict where this is to be applied, in your .htaccess file - as show below:


<Files index.html>
AddType application/x-httpd-php .html .htm
</Files>
<Files 200*>
AddType application/x-httpd-php .html .htm
</Files>


The above code restricts the treatment of html files as php to files with the name index.html and files with names that match the 200* pattern (the monthly archive html files).

I also recommend you go into your parent archives directory (the permanent links of posts are usually stored in an address along the line of "year/month/day/PostTitle" - the parent archive directory I refer to would be the "year" directory - this would be the directory by the name 2008 and/or 2009) and add the first code line from this post to the .htaccess file there.

AddType application/x-httpd-php .html

This would mean that all html files in that directory would get processed as if they were PHP files. This would cover the archived permanent links to the posts.

Voila. PHP in Blogger.

Important: It is important to realize the side-effects of these methods and then use this method if you feel it is okay. You might have to make changes to the above steps to match your blogger setup, this is the basic idea.

Sunday, December 28, 2008

Server Side Scripting in Blogger (aka PHP, ASP etc in Blogger)

I wanted to try and add some php code to blogger, and when I added some php code to the template page, nothing seemed to happen....here is how you make it work:

It is actually very simple. It is a 2 step process.

Step 1: Set your blog file name in publishing option to index.php (the default is index.html). The fact that its a php file now allows you to integrate php code in the template that would be processed by the server. Here is an image of where you would do this:


Step 2: Add the php code to your template. Here is an image showing that.


The same steps will be followed for ASP pages or anyother server side scripting language - the difference being, the blog filename extension would have to correspond to the language (.asp for ASP).

The drawback is that this would only work on the index page, the rest of the pages (archives, post permanent link pages etc) are still generated as html pages.

Labels: , , ,

Saturday, December 27, 2008

Rest of site to be fixed soon

At the moment, the only page with the new design implemented is the blog (home-page and the anything related to the posts). Other pages (Project, Resume, Contact, About etc) either do not exist or are based off the old design. These will soon be updated.

Labels:

Friday, December 26, 2008

New Site Design is Up and Running!

It was a wonderful experience working the Gartheepan! Thanks a lot for the new design :)

The new site is up and running now.

Monday, December 22, 2008

New Website Design

And now, I will provide you with a sneak-peek of the new and improved Ai-Projects.

I owe a very big THANK YOU to Gartheepan, who came up with the design. He is definitely a very talented graphics artist/designer.

I really loved it. Here is a sneak peak of the new design as viewed of Firefox 3 on a widescreen resolution.


We are working to get the finer details finalized. This should happen sometime soon.

I am not sure how big a readership I have at this point, but for anyone reading this, feel free to comment on what you think of the new design from this pic. I really appreciate you for taking the time to comment.

Thanks,
Aishwar

Thursday, December 11, 2008

SQL parser - Syntax checker

As I previously noted, one of the main components of this DBMS would be the SQL interpreting engine. One thing it would have to do is check for Syntax errors. I have been thinking that regular expressions would be a good way to check the SQL syntax and I have roughly come up with some (I just brushed up on my regex by reading some tutorials) - these may not be syntatically correct (i.e. have not been tested), but should contain the basic idea. Here we go:

SELECT statement
/
^SELECT[:space:].*[:space:]
FROM[:space:].*[:space:]
/

WHERE clause
/
^WHERE[:space:]
[a-zA-Z0-9]=( ([a-zA-Z0-9]*) ^ \'([a-zA-Z0-9\"[\\\']*]*)\' ^ \"([a-zA-Z0-9\'[\\\"]*]*)\" )
((AND ^ OR) [a-zA-Z0-9]=( ([a-zA-Z0-9]*) ^ \'([a-zA-Z0-9\"[\\\']*]*)\' ^ \"([a-zA-Z0-9\'[\\\"]*]*)\" ))*
/

INSERT statement
/
^INSERT[:space:]INTO[:space:][a-zA-Z0-9]*
[\(]
([a-zA-Z0-9]*[,])*
([a-zA-Z0-9]*)
[\)]
/

I will test these tomorrow, feeling sleepy now.

Wednesday, December 10, 2008

Discovery of new passion

Before this thought slips my mind, I think I have realized something I am passionate about and just love doing - high level design - I love to design high level solutions to real world problems. Why do I use the words "high level"? with my current projects I do the "low level" coding - and it is rewarding in itself - but coming up with the solution is the part that I most cherish. It is quite a fulfilling feeling.

I also love to deal with the problems (or oversights) that happen after my high level design. Improvements are always there to make, and this move towards perfection is truly fulfilling.

I said this sometime ago, and I shall repeat it - so that my previous statement does not carry a wrong image - "Perfection is like an asymptote, you can keep getting closer and closer to it, but you will never reach it". I don't think perfection is achievable, but, I repeat, the move towards perfection is truly fulfilling (of course know your limits, i.e. know when the next step isn't worth the cost and then stop).

Labels:

PHP Flat File DBMS: Planning

Assuming I work on the PHP-based DBMS, I believe the main parts of the projects are (for version 1):

* Framework to handle database and table objects

* Framework to handle table structures
+ Make a UNIQUE PRIMARY KEY essential
+ Support AUTOINCREMENT field

* SQL interpreter engine
+ Support simple SELECT statements
+ Support SELECT statement with WHERE clause
+ Support AND and OR operators
+ Support EQUALITY, NON-EQAULITY and LIKE operators
+ Support simple INSERT statement
+ Support simple DELETE statement
+ Support WHERE clause in DELETE statement
+ Support simple UPDATE statement
+ Support WHERE clause in UPDATE statement

* SQL framework to validate SQL statements
+ Malformed statements - syntax errors
+ Invalid statments - reference to non-existent fields

* Framework support for concurrency issues
+ Have some sort of concurrency handling

This could be quite work-intense. Hopefully I manage my time well enough, so that I don't detest this project (by working too hard on it) and stop working on it and I still have free time to do other "completely relaxing" things. But the prospect of creating something like this fills with me excitement. :)

I look forward to this.

Interesting Things to do

Having a little extra time in my hand now, and not wanting to waste it away by watching online videos, I thought of some really cool things (I am sure most normal people would not find this list as cool :) ) I could do:
  • Create a flat file PHP-based database management system
  • Work on the "MLS" project idea ("MLS" is a self-given acronym to one of my ideas)
  • Contribute to some Open Source Project(s)
  • Learn about how PAR files work. I read a little about them, I found it very cool and interesting

Thursday, December 4, 2008

Common Misperception of Arranged Marriages

I felt the urge to post this! - after an online chat with Arthur today.

I should probably post a disclaimer here: There are many variations of the arranged marriage "arrangement" process, and what I am posting here is the most common variety I have seen. And hence is by no means, meant to be taken as the de facto standard.

Phase 1: Working your family/friend connections.
You start looking for a bride/groom for your son/daughter by letting family and friends know. Being in the communal (as in community) loop, they try to make matches and propose to the relevant families.

In recent times, the internet has played a good role in providing the list of "available" people. These sites are different from the typical American "match-making" sites. These are usually just a listing with a photo, and some background information such as education, parents names, siblings etc.

NOTE: Phases 2 and 3 order change in some cases - I believe it is a case of which ever info of the 2 is first received is processed first

Phase 2: Visual match
The photo of the prospective bride/groom is shown to the son/daughter and to other family members. This stage is used to ensure the prospective couple would have a good visual match.

Phase 3: In-depth background analysis
The family history of the bride/groom is analyzed. I have heard this ... you can get a reasonably good guess of a person's personality through seeing 3 [older] generations of their family.

After the history is analyzed, and inquiries are done through other friends and family about the prospective bride/groom family, we proceed to the next stage of checking for Astrological compatibility.

Phase 4: Star-based match
Astrologers are consulted and the compatibility of the prospective couple is checked. (Personal Note: Astrology looks like a pseudo-science to me - I believe astrologers do some computation-like things based on birth charts, timings etc)

Phase 5: Person-to-Person match
Finally after all these tests are passed, the 2 people in the prospective relationship usually meet/talk to each other, and try to get a quick understanding of each other and evaluate if they would like each other and would get along well.

Phase 6: Its a Go!
After all these stages have been past, official ceremonies such as engagement etc take place, leading up to marriage and the start of a new couple.


Of course depending on the family, and how both the families know each other etc...some of these steps may be by-passed (as in cases where the 2 families know each other step 3 may be skipped or skimmed over).

I heard this recently in a wedding, and it is very true for Indian family marriages - a marriage is more than the union of 2 people - it is a union of 2 families. The new couple is not going to live in isolation, but is going to be an integral part of the family and take part as one in community events and ceremonies yet to come.

Thus! I conclude, the process of arranged marriage is not to be underestimated.

What about the argument, you just met a stranger and you get married to them?

After the whole process, the person is no random stranger, but is someone who both families believe would match well

If you're question is, where is the love? I believe you fall in love after the marriage :) ... you learn to accept each and live together

With that, I shall conclude, yet again, arranged marriages are not to be underestimated :)