Wednesday, August 19, 2009

Philippine Election

What's your criteria for electing political candidates? With all the media reports and "paninira" of one politician to other politician, I know it's hard. All we hear about on the radio and TV stations are all negative impressions. So how can people vote for the right leader? Actually, it's very easy. It only takes a common sense to vote wisely.

Vote according to their good things done to the community, rather than based on the media or "paninira" of other politicians. We all know every politicians say bad things to their competitors every election time, it's very obvious.

So, list down all your candidates with their achievements. Whoever is on top, then we should vote for them.

Don't forget to let us know your bet. :)

Pres. Gloria Arroyo V.S. Tiyo Pisto Guna

Personally, I don't want to vote for political candidates that are fond of sticking their nose to their neighbors, this would only tell me that they are not capable of doing their job and minding their own business. How can someone lead if he's so busy spying with his neighbors' activities? How can he do his job if he always thinks that he can do others' job better?

So tell me, is Tiyo Pisto 100% clean himself? Are they paid to investigate? Or are they paid by the citizens to lead? I want my money back!

Thursday, April 2, 2009

Javascript get domain name from URL or email

I've made a simple script that will retrieve the domain name of a given site url or an email.


function getDomainName(urlOrEmail)
{
var matches = urlOrEmail.match(/^([\w]+:\/{0,2})?([\w]+\.|.*@)?([\w]+\.[\w]{2,4})(\/?)(.*)?/);

return matches && matches[3] ;


}


Sample usage:

//any format such as images.photosnippet.com, www.photosnippet.com, etc
var site = "http://www.photosnippet.com";
var email = "me@photosnippet.com";

document.write(getDomainName(site)); => prints "photosnippet.com"
document.write(getDomainName(email)); => prints "photosnippet.com"

NOTE: Thist post has been updated. Thanks to "gwafo ko" comments, I was able to know more regex syntax such as "\w" and "String.match()". (obviously this was my first regex code. hehe ;) ).

I used this site as reference: http://www.regular-expressions.info/reference.html

What the script above does is that it will only retrieve the domain name, excluding subdomains. Here are the different scenarios that this script was intended for:

1. me@markglibres.com
2. my.projects@markglibres.com
3. mailto::me@markglibres.com
4. markglibres.com
5. www.markglibres.com
6. projects.markglibres.com
7. http://markglibres.com
8. http://projects.markglibres.com

This also has a strict rule of only having valid domain extensions such as ".com" or ".us" or ".info" (characters not greater than 4 characters)

This will return "markglibres.com"