Pages

Wednesday, December 14, 2011

Sri lanka NIC number validation using Date of Birth JavaScript, JQuery

JavaScript Part

$(document).ready(function(){
    $('#btn').click(function() {
            var error = '';
        if ($('#dob').val() == "") {
            error = "Please input date of birth \n";
        }
        var id = $('#id').val();
        if ( id == "") {
            error = error+"Please input your Id number"
        }
        if (id.length < 10 || id.length > 10) {
            error = error+"Invalid Id number"
        }
        if(error!=''){
            alert(error);
            return false;
        }
        
          var dob = $('#dob').val();
          var id = $('#id').val().substr(0,5);
          var arr  = dob.split('/');
          var year = arr[2];
          var month = arr[1];
          var day = arr[0];
          var gender = $('input:radio[name=sex]:checked').val();
          var dayCount = getDayCount(month, day);
          var idnumber;
          var yearType = year%4;
          if(gender=='f'){
             if(yearType== '0'){
                 idnumber = year.substr(2,2)+(dayCount+499);
                  }else{
                 idnumber = year.substr(2,2)+(dayCount+500);
                  }
          }else {
              if(dayCount<10)
                  idnumber = year.substr(2,2)+'00'+dayCount;
              else if(dayCount<100)
                  idnumber = year.substr(2,2)+'0'+dayCount;
              else
                  idnumber = year.substr(2,2)+dayCount;        
          }
          if(id==idnumber){
              alert('Id number ok');
              return true;              
          }else{
              alert('Your Id number, Gender or date of birth invalid');
            return false;
          }
    });

    function getDayCount(month, day){
        var dayCount = 0;
        var month = month;
        var day = parseInt(day);
        if(month==1){
            dayCount = day;
        }else if (month==2) {
            dayCount = 31+day;
        }else if (month==3) {
            dayCount = 59+day;
        }else if (month==4) {
            dayCount = 90+day;
        }else if (month==5) {
            dayCount = 120+day;
        }else if (month==6) {
            dayCount = 151+day;
        }else if (month==7) {
            dayCount = 181+day;
        }else if (month==8) {
            dayCount = 212+day;
        }else if (month==9) {
            dayCount = 243+day;
        }else if (month==10) {
            dayCount = 273+day;
        }else if (month==11) {
            dayCount = 304+day;
        }else if (month==12) {
            dayCount = 335+day;
        }
        if( (month > 2)){
            return dayCount+1;
        }
        else {
            return dayCount;
        }
    }
    
});

HTML body.
<body>
<form action="" method='post'>
<label for='dob'>Date of Birth*: </label>
<input class="required" type='text' name='dob' id='dob' value='' maxlength="50" /><br>
<label for='dob'>Id*: </label>
<input class="required" type='text' name='id' id='id' value='' maxlength="50" /><br>
<label for='sex'>Gender*: </label>
Male<input type='radio' name='sex' id='sex' value='m' maxlength="50" checked="checked" />
Female<input type='radio' name='sex' id='sex' value='f' maxlength="50" /><br>
<input type="submit" value="Validate" id="btn" onclick="validateid()">
</form>
</body>

Description

To use the above javascript function, you should have installed JQuery and Jquery UI libraries properly. 
If JQuery has been installed properly, you can see the Date Of Birth field which gives the jquery calender to select the date as follows.
Once you have configured your environment to use JQuery, you can create a simple html form along with the fields that you want to capture data. This form must capture the following in order to validate NIC number.
  • Date Of Birth
  • Gender
In other words, your html form must have at least 3 required fields. Date of birth, gender and the NIC number.
Put the above JQuery function inside your scripts.
<head>
<script>
.........<above function goes here>

</script>
</head>
Now you are ready to go. Try it and feel free to ask for help if you hit any issue with this.





Friday, November 18, 2011


The Asia-Pacific Economic Cooperation (APEC) countries may become a good example of how to deal politically with deadlocking issues. At their summit in Honolulu last week, they agreed to reduce import tariffs to boost trade in products that cut fossil fuel use and reduce pollution.

With dismal expectations for the COP17 climate change talks, which will open in Durban, South Africa later this month, this agreement looks like a lesson on how to bridge differences and reach consensus. It could also somehow inspire the parties to the climate convention about to gather in South Africa. Durban’s COP17 risks provoking the collapse of the UN climate change negotiations architecture if it ends on a standstill.

The APEC meeting started with sharp differences between the U.S. and China. Opening statements from both countries’ leaders, Barack Obama and Hu Jintao, explicitly mentioned their disagreements. Obama even showed a trace of irritation with Chinese trade practices. “We’re going to continue to be firm that China operate by the same rules as everyone else,” he said at the close of the 21-nation APEC summit, after saying that “enough is enough”. It looked like a deadlock would be unavoidable.

In his opening statement, Hu Jintao insisted on more clout for China as an emerging global power. He also made clear Beijing prefers to work through existing global trade architecture rather than allow itself to be subject to U.S.-led efforts to open Asia-Pacific markets at any cost. Chinese officials also warned that the U.S. decision to launch a probe that could lead to anti-dumping duties on Chinese-made solar cells and modules could impair energy cooperation within APEC.

But, at the end of the meeting, both countries managed to agree to cut import tariffs on environmental goods (mainly clean energy products) to 5 percent by 2015. APEC members also pledged to eliminate domestic content requirements that distort environmental goods and services trade by the end of 2012.

Additionally the APEC leaders agreed to:

* rationalize and phase out inefficient fossil-fuel subsidies that encourage wasteful consumption, and set up a voluntary reporting mechanism on progress, to be reviewed annually;

* promote energy efficiency by taking specific steps related to transport, buildings, power grids, jobs, knowledge sharing, and education in support of energy-smart low-carbon communities; incorporate low-emissions development strategies into our economic growth plans and leverage APEC to push forward this agenda;

* a goal of reducing the region’s energy intensity by 45 percent by 2035;

* work to implement appropriate measures to prohibit trade in illegally harvested forest products and undertake additional activities in APEC to combat illegal logging and associated trade.

Chinese President Hu Jintao signed onto the plan, even though earlier this week Chinese officials criticized the tariffs cuts as too ambitious.

The environmental goods that will have their import tariffs cut are still to be designated. U.S. officials “have identified solar panels, wind and hydraulic turbines, air pollution filters and sewage treatment pumps as goods they would like included,” according to Reuters.

Tariffs and subsidies cuts are more easily enforceable because they become immediately effective upon enactment. Energy intensity goals are more elusive. Chinese officials hurried to explain that they were aspirational goals and that the APEC commitments are “voluntary and non-binding.”

“We can and must address both the region’s economic and environmental challenges by speeding the transition toward a global low-carbon economy in a way that enhances energy security and creates new sources of economic growth and employment,” said the Asia-Pacific Economic Cooperation leaders in their Honolulu Declaration.

“We are committed to advancing our shared green growth objectives. We can and must address both the region’s economic and environmental challenges by speeding the transition toward a global low-carbon economy in a way that enhances energy security and creates new sources of economic growth and employment.”


The APEC deal can be a major step forward in the adoption of clean energy by major developed and emerging economies. It may also become a lesson on how to constructively address contentious issues. If the deal becomes effective in 2012, it could be used as a reference to future climate negotiations.

Negotiations on tough issues have a better chance of success when the number of parties to the deal is relatively small. To make a difference in the status quo, the parties have to be representative. APEC is a powerful economic conglomerate, and its contribution to GHG emissions is considerable. The APEC countries account for more than half of global GDP, 44 percent of global trade, and 63 percent of global greenhouse gas emissions. Although the European Union, Brazil, and India, also relevant economic actors and major GHG emitters are not represented, the group can make a difference. One useful contribution from APEC could be to propose the extension of these commitments to G20 countries.

Reference:
http://www.greatenergychallengeblog.com/blog/2011/11/14/can-the-apec-help-cop17-climate-change-talks/

Saturday, October 29, 2011

Do you know about Carbon capture and storage (CSS) project? A big challange

Carbon capture and storage (CCS) is a family of technologies and techniques that enable the capture of CO2 from fuel combustion or from industrial processes, the transport of CO2 via ships or pipelines, and its storage underground, in depleted oil and gas fields and deep geological formations. The IEA estimates that CCS will play an important role as part of a cost-effective portfolio of solutions to combat climate change.

It is like this...







Watch this video....




Global Challenge....

The total investment cost of the needed 1800 installations could amount to nearly USD 900 billion. While this is a large sum of money, it only represents 2% of the total investment needed to halve global energy-related CO2 emissions by 2050, a level deemed necessary to combat climate change. Of this total, some USD 670 billion will be needed in the industrial sectors in developing countries, representing a significant challenge for financing. “While the developed world must pave the way for carbon capture and storage deployment efforts in the next decade, the technology must also spread rapidly in the developing world. The growth needed will require expanded international collaboration, supporting policies and financing for CCS demonstration in developing countries”, said Edward Clarence-Smith, UNIDO Representative and Director of the regional office in China.

More about the CSS project....

This is how it works



Refferances....

International Energy Agency:

Thursday, October 20, 2011

Possibility of a Hybrid Mail System in Sri Lanka

As a Sri Lankan I would like to see the advantages of a hybrid mail system implemented in our country. This is a new system(service) that can be introduced to Sri Lanka's Department Of Post easily. I intend to address the problem of not having a proper way of sending urgent documents or other mails to rural or urban areas in which internet is hardly in access of the public. I'm referring to a system called the 'Hybrid Mail System'.




For instance if Jack wants to send a mail to Smith who does not have access to internet, Jack can use this system to send a soft copy via email to Smith's postal address which would reach the nearest post office to Smith, then that post office will print a hardcopy and will deliver it to Smith via post.

The concept of this system is quite simple. This is a combination of digital and physical mail systems. It involves transforming digital data into physical letter items at distribution centers located as close as possible to the final delivery location(physical address). Because this system requires a number of centers though out the country, the best place to introduce such a system is our Department of POST. For better service this system requires to have internet facility at all the post offices. However It is possible to start the system using only main offices. As per my knowledge the internet is already a requirement of this department for a better service and for an easy internal administration with new technologies. And I suppose introduction of this system will be a good improvement for the department's target of adopting the new technologies.


This new, fast and easy to use system will allow the Department of Post to provide a better service to the public. Most of the countries in which this system is used, it has been introduced and is currently run by the private sector. Although, in my opinion, it is best that the Department of Post itself introduces this system as the department has been the trusted way of communication between all Sri Lankans for more than 200 years.

Some countries might not need such a system because of their high percentage of internet users(see this). But in some cases they also might need this. When we come to Sri Lanka we have the requirement of such a system. not only because of our low internet user persantage (see this), but also to have a fast and easy service.

So now, do you think this is possible to be implemented in a country like Sri Lanka. How viable do u think it is.......?





Monday, October 17, 2011

Global Warming and Vehicle Exhaust

Global warming refers to the rising average temperature of Earth's atmosphere and oceans and its related effects. In the last 100 years, Earth's average surface temperature increased by about 0.8 °C (1.4 °F) with about two thirds of the increase occurring over just the last three decades. Warming of the climate system is unequivocal, and scientists are more than 90% certain most of it is caused by increasing concentrations of greenhouse gases produced by human activities such as deforestation and burning fossil fuel. These findings are recognized by the national science academies of all the major industrialized countries.

Even we know that global warming is such a dangerous effect of increasing greenhouse gases produced by human activities, there are few good aspects we can gain such as below.

  •  Better for the Economy.
  • Warmer Weather is Healthier
  • More Usable Land For Farming & Housing:
  • Carbon Dioxide Good for Plants
  • Fewer Hurricanes
  • Warmer Weather is Safer... (find more)

But we should not let this world to keep this warming rate anymore. Why? Here is the dangerous dark side of it.



  • Spread of disease
  • Warmer waters and more hurricanes
  • Increased probability and intensity of droughts and heat waves
  • Polar ice caps melting
  • More floods
  • Fires and wildfires
  • Destructive storm
  • More dangerous Tsunamis
  • More dangerous thunderstorm
  • Migration, conflict and wars 
  • Death of ocean life and much more effects 

     

    CO2 and global warming


    Carbon dioxide is one of several heat-trapping greenhouse gases (GHGs) emitted by humans (anthropogenic GHGs).The scientific consensus is that human-induced greenhouse gas emissions are the primary cause of global warming, and that carbon dioxide is the most important of the anthropogenic GHGs. Worldwide, 27 billion tonnes of carbon dioxide are produced by human activity annually. The physical effect of CO2 in the atmosphere can be measured as a change in the Earth-atmosphere system's energy balance – the radiative forcing of CO2. (according to Wikipedia)


    Generation of electricity and heat was by far the largest producer of CO2 emissions and was responsible for 41% of the world CO2 emissions in 2008. By 2010, transport, the second-largest sector, represented 23% of global CO2 emissions according to the latest estimates of the International Energy Agency (IEA). Road transport, automobiles and light trucks produce well over 60% of emissions. However in low- and middle-income developing countries, freight trucks (and in some cases, even buses) consume more fuel and emit more CO2 than light-duty vehicles. Transport-related CO2 emissions from developing countries will contribute in increasing proportion to global CO2 emissions unless mitigating measures are implemented soon.


    However CO2 is not always destructive. It is also a gas essential to contain life on earth. An excess of CO2 is what harms the possibility of continuation of life on earth. However as the amount of trees are decreasing rapidly due to deforestation a higher level of CO2 remains in the atmosphere.


    A major role is played by trees when trying to reduce the amount of CO2 in the atmosphere. Trees absorb the CO2, using it for Photosynthesis releasing O2 to the environment.


    Carbon tax


    A carbon tax is an environmental tax levied on the carbon content of fuels. It is a form of carbon pricing. Carbon is present in every hydrocarbon fuel (coal,petroleum, and natural gas) and is released as carbon dioxide (CO2) when they are burnt. In contrast, non-combustion energy sources—wind, sunlight, hydropower, and nuclear—do not convert hydrocarbons to CO2. CO2 is a heat-trapping "greenhouse" gas.


    Scientists have pointed to the potential effects on the climate system of releasing GHGs into the atmosphere. Since GHG emissions caused by the combustion of fossil fuels are closely related to the carbon content of the respective fuels, a tax on these emissions can be levied by taxing the carbon content of fossil fuels at any point in the product cycle of the fuel.


    Carbon taxes offer a potentially cost-effective means of reducing greenhouse gas emissions. From an economic perspective, carbon taxes are a type of Pigovian tax. They help to address the problem of emitters of greenhouse gases not facing the full (social) costs of their actions. Carbon taxes are a regressive tax, in that they disproportionately affect low-income groups. The regressive nature of carbon taxes can be addressed by using tax revenues to favour low-income groups.


    A number of countries have implemented carbon taxes or energy taxes that are related to carbon content. Most environmentally related taxes with implications for greenhouse gas emissions inOECD countries are levied on energy products and motor vehicles, rather than on CO2 emissions directly.


    Opposition to increased environmental regulation such as carbon taxes often centres on concerns that firms might relocate and/or people might lose their jobs.It has been argued, however, that carbon taxes are more efficient than direct regulation and may even lead to higher employment.


    Reforestation


    Reforestation is the restocking of existing forests and woodlands which have been depleted, an effect of deforestation. Reforestation can be used to improve the quality of human life by soaking up pollution and dust from the air, rebuild natural habitats and ecosystems, mitigate global warming since forests facilitate biosequestration of atmospheric carbon dioxide, and harvest for resources, particularly timber.


    Our Vision

    Making the CO2 cycle more efficient is an achievable solution for global warming. This can be achieved by equaling the pace of reforestation to the speed of industrialization. 


    However funds are required for launching of reforestation projects. This can attained by imposing a Carbon Tax. The Authorities can declare a standared for Carbon emmision in vehicals and all those exceeding the pertaining limit will be accountable for the Carbon tax. Funds received via tax should be allocated for commercialy non profitable Tree Plantation programs.