Sunday, December 16, 2007

Common rails validations



A rather short post, this one if focused on few validations in rails that I often use. In rails you could do a lot of validations, as they are very simple to handle. Because of the well structured and separated MVC architecture all you need to do is write you validations for the database in our model. Actually as a matter of fact you could also write them as a library and call its methods. The ones below aim to do just that. They use regular expressions, in case you are confused with what that is do read up.

Validating an Email Address

validates_format_of(:email,
:with => /^([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i,
:on => :create,
:message=>"has an invalid format")

Validating URLs

validates_format_of :url, :with => /^(https?://)?([^/]+)(/.+)?$/i

# OR

validates_format_of :url, :with => /^(ftp|https?)://((?:[-a-z0-9]+.)+[a-z]{2,})/

Validating IP addresses

validates_format_of :ip, :with => /^(d{1,3}.d{1,3}.d{1,3}.d{1,3})?$/

=================================================
||My FREE services||

ParkingWHOIS is now not only a domain parking lookup, but now also has reviews on Parking Companies.
=================================================


Tuesday, December 4, 2007

Installing Rails on uBuntu 7.10 Gusty Gibbons


So I wanted to install Ruby on Rails on my new linux box. And really thats not tough, this post just guides you to do the same. Actually I feel it is 80% easier to setup your linux box for any programming language than a windows COMPUTER. I might be wrong cause I used Windows for about a decade and then its a little more than one year since I have been using uBuntu (DUH!! a linux distro for the ones that didnt know) and I am already in love with it. One year and it still hasn't crashed. I can go on and on about my love for uBuntu but I think I will stop here. Ohh BTW uBuntu 7.10 (or uBuntu Gusty Gibbons has launched). It is sooooo light and awesome looking that my mom also is telling me to install it on her laptop. Truly linux for human beings. But I think I will let her laptop be a dual boot with XP and uBuntu; It will help me test my web apps.

Coming back to the main topic of discussion, I need to install Rails on uBuntu (actually works well for debian too). So here are few basic steps you might want to review:
1) Make sure all the build essentials are present on your Linux box. If not then quickly get into the terminal and hit

sudo apt-get install build-essential

2) Next you need to install ruby ri and rdocs so hit
sudo apt-get install ruby ri rdoc

3) Now you would want to download the latest versions of RubyGems; you could do that from http://rubyonrails.org/down or hit
sudo wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz

4) Uncompress and extract the file by
tar -xvzf rubygems-0.9.0.tgz

5) Go into that folder by
cd rubygems-0.9.0

6) execute the setup.rb file to setup RubyGems
sudo ruby setup.rb

7) Use RubyGems to install Rails
sudo gem install rails --include-dependencies

8) If the previous step gave you an error about SSL then install the Open SSL library for ruby
sudo apt-get install libopenssl-ruby


And you are ready to go!!! Lets test the Rails setup by creating a demo project and running it (remember you are still in the terminal)
$ rails testapp
$ cd testapp
$ ruby script/server

/testapp$ ./script/server
=> Booting WEBrick…
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-12-07 05:28:37] INFO WEBrick 1.3.1
[2006-12-07 05:28:37] INFO ruby 1.8.4 (2005-12-24) [i486-linux]
[2006-12-07 05:28:37] INFO WEBrick::HTTPServer#start: pid=6687 port=3000



You’ll notice that the server is listening on port 3000. Open up a browser, and go to http://localhost:3000. Ok this is it for this article hope you are successful in setting up Rails on your Linux box and I wish your app gets as famous as David's. Peace.








=================================================
||My FREE services||

Find out more information about domain parking at ParkingWHOIS
=================================================

Thursday, November 29, 2007

Does habit equal addiction?

This article talks about the Siamese twins called Habit and Addiction, their similarity and how one should tackle them...

The oxford dictionary defines habit as a settled or regular tendency or practice or alternatively an addiction to drugs. Ok that was what the books told us, but lets see what I understood of the word habit, Habit is word or tendency such that when I remove the starting letter from it (i.e. H), I still have a-bit, if I remove the next letter (i.e. A), I am still left with bit, when I remove the next letter from that, I am left with it, I still keeping having it, now in my desperate attempt I remove the next letter from that (i.e. I), I am still left with T, i.e. tea or coffee whatever you prefer. So habit is one such word so well defined in the English literature that it doesn't make you feel like an addict nor does it sound insulting, an extremely polite way of saying, Yes, I am addicted to something.

Many people, including my clients keep asking me, How can I differentiate between a habit and an addiction? Well the answer is very simple, you can't, and you just can't differentiate between a habit and an addiction. They both mean exactly the same. Socially or rather politically, the word habit is considered to be more polite than the word addiction. In most cases, if not in all, habits are formed unknowingly and people involuntarily get habituated. Now why did I say that? Well in most cases you never understand your body and why is it demanding something. You just do it because your body demands it.

Accepting that you are addicted is the only way to conquering your fears. You need to realize, not assume, what you are habituated to. Getting rid of an addiction or a habit starts from knowing your body, understanding its needs. Bringing discipline in your life, is a more practical way to word it. You need to know that your body is not like any other machine that processes your food, but is way much more complex. You need to balance your sleep hours, eating habits, and recreation timings.

Loosing your addiction or habits is only half success, but maintaining it for life is your final success. So once you have won yourself against addiction, it is very important to maintain this victory. The key element that would keep you going on in this battle is that fact that you love yourself and you love your life. Boys like their toys and girls like their boys, a phrase that displays relation betweens the oddest of elements. Raising the bar is a very good thing, as humans are competitive but one must know when and where the word enough, in their line of life. You may not be the best but you are not bad either.

So, let me end this one here by saying, be in control of yourself and your life. They just give you one life, so don't let any habit manipulate it cause this is one place you never get a second chance.

=================================================
||My FREE services||

Find out more information about parking domains at ParkingWHOIS
and many more...
=================================================

Wednesday, November 28, 2007

Domain monetization

Welcome to the world of monetization, the a prime community of online real estate. Back in the early 90s a man named Rick Schwartz saw the future of domain names; Domain monetization as we call it now. Rick that time bought many generic domain names like men.com, eScore.com and a whole bunch of adult domain names. Men.com is no longer rick's property but he sold that prime name for $1.3 Million, he also sold eScore.com to Stanley Kaplan test preparation company for about $100 thousand. Although rick sold few of his generic domain names he still owns a good lot of them. And that just one of them now you cannot forget Frank Schilling, Sahar Sharid and many more...

So, how is the market now? and what do you do if you lost a chance on grabbing one of those prime real estate. Well in real life one would simply buy some real estate near those prime property and that exactly happened in the cyber world too. People started buying typos of domain names that were either generic or famous brands. It there exist a loan.com then someone bought a laon.com buy getting inspired by that. Mind it, its a good strategy but not a successful one always. There is a good chance that the typo you own may not be the best that exist for that particular domain and hence its value might be less than few others. It is really hard to calculate the probability of how successful a typo domain name would be, but you could use this tool at SEOChat to generate domain typos. This lead to a new generation of pseudo domainers called typo squatters. One can get lucky with a good domain typo but there are times you can be sued for trademark violation.

Is this opportunity just for individuals? Well I would say no!! Back in the early days people in the Registry (i.e the DOTcom registry)also understood what they are gonna loose, so they tried to cap the losses by proposing the Wait List Service (WLS). The whole idea of WLS was, there would be a wait list for a particular domain name. If a person wanted a domain name he could pre order it. If that domain name has to expire then he would be the next rightful contender of that domain name. This was proposed for the DOTcom and DOTnet top level domains (tlds). But the deal never went through. The DOTtv registry is another example of the registry making profit out of domain names. The DOTtv registry has marked some domains are their premium set of domain names, no one can register them but a person can only rent them for a tenure of one year. The domain renting rate for each domain is calculated on its value in the industry and changes very dynamically.

We have covered premium domain names and also typo squatting, getting further in depth lets discuss how Registrars make money off domain monetization. In a particular domain cycle (this example image is specific to that provider) there are various stages when a registrar could monetize domains he has such as:
Domains that are newly registered
Often when you register a domain name you do not point that domain to your actual hosting provider for one reason or the other (may it be testing, or you don't have hosting as of yet). What a registrar could do is give a set of nameserver records and volla!! he is monetizing your domain traffic by simply giving you a "coming soon" page filled with ads. A good example of this would be this screen cap



Domains that have expired
When a domain name expires the registrar gets 45 days of grace if he chooses to keep this domain or get a refund for it. From the 45 days given to them they give about 15 to 20 days to the registrant of the domain name for them to register it. Once the 20 day period is over the registrar parks the domain name (in few cases from the start of the 20 day period). This is a good source of quick pocket money for the registrar. Another smart move would be to keep the domain to themselves if it makes them a good sum while they have parked this concept is called as smart parking.

Page not found | 404 error
Another way to make money from domains that are registered are to monetize their 404 error pages (in few cases all error). They display a very smart looking "page not found" error with rest of the page filled with ads. This generally is not done in paid hosting, it is more seen in free hosting where companies offer free hosting but use methods like these to make money on the side.

By now the Registry also knows the money involved here, what they do is a even bigger step, they wild card an entire tld. If you havent registered a particular domain name eg. my-domain.in.com the in.com tld is so configured that it will show you a generic parked page and monetize the traffic on that domain name. Check out this example below



All said and done domain monetization is a pot full of going coins or hug bunch of green Benjamin Franklins or which ever currency you follow but not the end of the purpose of the internet. I will leave this article here and continue this topic in another article.

=================================================
||My FREE services|| Find out where a domain is monetized
Parking WHOIS
and many more...
=================================================

Friday, November 16, 2007

SEO with different server-side languages

This article sheds light on an important aspect of SEO, i.e clean URLs. How would you achieve clean URLs in few commonly used server-side languages like JSP, PHP, Ruby on Rails.

Let me start off with clean URLs; Dynamic websites use server-side languages to process visitor inputs and display results generated at real time. Often you might see the address bar of most of your famous web browsers growing really long. I tried to search something on Google and I got a long URL on my address bar.
[goto|http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=rmk&q=urls&btnG=Search]

So what are all these weird words?
My techie brothers by now might have already guessed that these are parameters a page passes to the server to dynamically generate the next page you are navigating to. So if you lost then check this for a little intel on server-side coding. Search engines find it hard to index these pages that are dynamically generated. They love static pages, for example
www.domain-name.com/pages/Check-this-article.html

So lets quickly learn on how we could clean these URLs
You could use the POST method instead of GET, this would clean the URL; But the problem is that it would completely clean the URL... hahah for example
http://domain-name.com/search.php would simple direct you to http://domain-name.com/results.php
no parameters at all, but then the state of that page would be lost and just the default results.php page would be indexed.
You could use URL rewriting, this would be the best solution as it would still preserve the state of that page and index it. For example,
http://domain-name.com/search.php?query=finance
can be modified as
http://domain-name.com/search/finance
by using Apache's mod-rewrite.

So now we have modified the URLs, (I haven't explained how to do URL rewriting in detail as there a zillion tutorials on the net plus the official Apache tutorials) whats next?

Which Server-side language is the best for this?
You should consider the fact that the older a language is the harder it is to have clean URLs there. So lets compare
JSP - Advance configuration
ASP - Advance configuration
PHP - Intermediate configuration
ASP.net or the .net frame work - Rather simple
Ruby on Rails - No configuration already done by the system

What about Windows or Linux (*nux) servers?
As configurations depends on server flavors, it is a different procedure on a Windows Box as compared to a Linux Box rather it is different on a IIS server as compared to Apache server or any other choice. According to the tests I can confirm that it is much easier on a Apache
server as compared to an IIS server.

Few links to help you configure your server for URL rewrite
On IIS try http://www.isapirewrite.com/ (commercial/paid)
On Apache try the mod-rewrite (Open source/FREE)
On Websphere try http://www.exforsys.com/tutorials/websphere/websphere-v5.0-running-applications-understand-session-manager.html

In the end of the day, it you and your application; For the love of coding... keep the cyber world clean and green!!!

=================================================
||My FREE services||
Parking WHOIS
and many more...
=================================================

Tuesday, September 25, 2007

Am I addicted?

A question that pops up in your mind when you do a certain task very regularly with your understanding so as to why you are doing so in the first place. I have noticed in many situations that people never realize that they are addicted until they are told so. So how do people react when they are termed as addicted? A very obvious emotion seen is fright, or worry. Addiction is considered to be a disease that can't be cured. However, just like a coin addiction can be viewed with two different perspectives. A positive addiction is similar to a good habit that voluntarily or involuntarily done by a person. At the same time a negative addiction is just like habit that causes damage to self or others in a physical or psychological way.

Ok so I am addicted, can you help me? The answer to this question is NO. There are no drugs or special herbs that would come in handy in this situation. So how do I cure myself? The answer is in that question itself, i.e. I, yes only you can cure yourself. Learn to use the word NO; it's a small word with big impact. You have to be strong in your mind, don't let your sub-conscious mind control you but you control your sub-conscious mind. Whenever you are tempted to do one of those addicted tasks, be strong, understand the fact that it is wrong, and finally refrain from doing it. You may have mixed emotions in you mind that instance but don't you ever overlook the fact that you are now so proud of yourself, for saying NO, to all those addictive tasks.

Isn't that like so simple, so what is the catch? I spoke to few addicts, after they understood this procedure they agreed to follow it for a month to start with and then they would give me feedback on it. The day of the feedback I realized that many could successfully follow the procedure only for a week or even less, many very easily lied and later confessed, and there were some who just preferred continuing being an addict without even trying to see the other side of the world. Yes, it isn't as simple as it sounds. Controlling your sub-conscious mind isn't very simple.

So the question arises, how do I control my sub-conscious mind? Do I take relaxants or any other drugs? No don't need to start taking relaxants; you cannot stop one addiction by starting another. The idea out here is to always be in your conscious mind and not let your sub-conscious mind control you. You should be in peace with yourself; yes this is one very important thing. I would recommend yoga in the morning; a small session would do the trick. When you meditate I want you to remember all the good things that happened to you, all the bad things that happened to you, how would that change you, how would respond to things, this way I want you to reflect on your past, and cure the wounds, so that your past positively influences your present. When you do this exercise regularly, it also presets you in an active mode when you start your day, rather than a passive mode.

As they say, winning someone's trust is hard, but keeping that trust maintained is even harder. This phrase also applies in our situation too, as coming out of an addiction is hard but maintaining that life long is even harder. So let us see some sarcastic do's and dont's. If you are tempted towards an addictive task, don?t feel bad that?s just human, but you saying NO is just divine. For every addictive action, there is an equal and opposite guideline. If you feel defeated, complaining would just not help, just work harder. If they call you a geek because you quit an addiction, times are changing, geeks are cooler now-a-days. Every person in an addictive state tends to remain in that state unless an external force is applied to it.

I would like to conclude saying, be strong and stay strong. It is hard and it even gets harder, but its totally worth it.


=====================================================
||My FREE services||
Parking WHOIS
and many more...
=====================================================


Thursday, September 13, 2007

Does your command center have the essentials??

Yes, its your computer I am referring to. I have often seen people buy the most expensive computers in the market at that time. They believe that it would help them do more tasks and last longer before being outdated. Well, I don't believe that is entirely true. On an average any computer is new only for three months. After three months there is always a new processor or higher ram or even better graphics card. I guess then what really matters is what your computer can do or rather what is its functionality; Obviously assuming the fact that those functionalities are hardware independent. There are always a small bunch of functionality that one would always expect his computer to do. Let me name a few...

  1. Access the web and use its various elements like email or chat or telephony
  2. Draft documents
  3. Keep their computer safe from malicious programs
  4. Gather and organize pictures
  5. Listen music and watch movies

I am sure a lot of you accomplish all this in one way or the other. But this is for the few that don't, here is what you can do; Try Google Pack, it has the most basic essentials that are required. This is what you get when u download and install Google Pack...

  • Google Earth (Zoom from space to street level — tour the world)
  • Norton Security Scan (Detects and eliminates viruses and internet worms)
  • Google Desktop (Find all your email, files, web history, and more)
  • Firefox with Google Toolbar (Browse the web quickly and securely)
  • Adobe Reader (View, print, and search PDF files via a redesigned interface)
  • Skype (Make free voice and video calls to anyone else on Skype)
  • StarOffice (Word processing, spreadsheet, presentation, and more; also includes Java™)
  • Google Toolbar for IE (Search from any web page and autofill forms; Block annoying pop-ups)
  • Spyware Doctor (Detects and removes spyware, adware, trojans and keyloggers)
  • Picasa (Find, edit, and share your photos in seconds)
  • Google Photos Screensaver (Display photos from your PC and photo sharing sites)
  • Google Talk (Connect with your friends via IM or free voice calls)
  • RealPlayer (Play popular media formats, organize music and videos)

Well although I am not such a big fan of the Google Pack but recently I understood how important it is have something on similar lines. My aunt wanted to watch one of her documented videos, her XP have nothing but a standard installation, it took a mind boggling 3 minutes 18 secs for her PC to boot (as compared to 26 seconds on my uBuntu box). I was her all time favorite computer mechanic. It was so sure her computer was stuffed with malware and trojans; And I was imagining my task list...
  1. Need some antivirus
  2. Have to shift to Firefox
  3. Needed something for communication

Luckily all of this could be covered by a single Google Pack installation. Moral of the story, although not my favorite but Google Pack can save you some time but if you are old school like many(including me) then you wouldn't really need this product.

==================================================================
||My FREE services||
Parking WHOIS
and many more...
==================================================================