Aug 16, 2011

All about NRIC Number in Singapore


What is NIRC Number?
NRIC is the abbreviated form for the National Registration Identity Card, which is the identity document in use in Singapore. It is compulsory for all Singaporean citizens and permanent residents who are fifteen years of age and older to have their NRICs. It is not compulsory for bearers to hold the card at all times, nor are they compelled by law to show their cards to police officers conducting regular screening while on patrol, for instance. But it is a required document for some government procedures, commercial transactions such as the opening of a bank account, or to gain entry to premises by surrendering or exchanging for an entry pass. Failure to produce the card may result in denied access to these premises or attainment of goods and services.
Structure Of NRIC Number
The NRIC number consists of total 9 characters in the pattern #0000000@, where
#
  • This is a letter that can be “S”, “F”, “T” or “G” depending on the status of the holder.
  • For Singapore citizens and permanent residents, this is the century prefix.
  • The NRIC number for citizens and permanent residents born before the year 2000 is assigned the letter “S”. “S” is the 19th letter in the English Alphabet, denoting that the NRIC number was issued in the 20th century (1900-1999). It was commonly believed before 2000 that the “S” stands for Singapore, especially since the letter “F” was used for foreigners. It is unknown, however, if that was ever the intended meaning.
  • Singapore citizens and permanent residents born in 2000 and beyond are assigned the letter “T”. “T” is the 20th letter in the English Alphabet, denoting that the NRIC number was issued in the 21st century (2000-2099)
  • Foreigners holding employment or student passes issued before 2000 are assigned the letter “F”.
  • Foreigners holding employment or student passes issued in and after 2000 are assigned the letter “G”.
0000000
  • This is a 7 digit serial number assigned to the document holder
  • For Singapore citizens and permanent residents born in 1968 and after, their NRIC number will start with their year of birth e.g. 71xxxxx#. For those born in 1967 and earlier, the NRIC number does not relate to year of birth, and commonly begins with 0 or 1. Non-native Singaporeans who were born before 1965 are assigned the heading numbers 2 or 3 upon conversion of permanent residency (PR) or citizenship.
@
  • This is the checksum letter calculated based on # and 0000000.
How to Validate the NRIC Number?
The algorithm to calculate the checkdigit of the NRIC is not publicly available; as of 1999, the Ministry of Home Affairs, Singapore only sold the algorithm to Singapore-based organizations demonstrating a” legitimate need” for it. Nevertheless, the simple mathematics involved in checking the validity of the NRIC number is summerized as mentioned below:
The Singapore NRIC number consists of SEVEN (7) digits with a UIN/FIN letter prepended and checksum letter appended. This checksum letter is calculated from the first SEVEN (7) digits using the MODULUS ELEVEN (11) method. This system is the most commonly used since it provides a high degree of security.
The steps involved in the computation are as follows:
  1. Multiply each digit in the NRIC number by its weight i.e. 2 7 6 5 4 3 2 in order.
  2. Add together the above products.
  3. If the first letter i.e. UIN of the NRIC starts with T or G, add 4 to the total.
  4. Find the remainder of (sum calculated above) mod 11.
  5. If the IC starts with S or T: 0=J, 1=Z, 2=I, 3=H, 4=G, 5=F, 6=E, 7=D, 8=C, 9=B, 10=A
    If the IC starts with F or G: 0=X, 1=W, 2=U, 3=T, 4=R, 5=Q, 6=P, 7=N, 8=M, 9=L, 10=K
For example I want to test the NRIC number S1234567D.
Here the 7 digits are 1234567.
So the sum of  product of digits with weightage is, 1×2+2×7+3×6+4×5+5×4+6×3+7×2=106.
Now, 106 mod 11= 7
From the table above as listed in item 5 on the list above, 7=D (Since IC is S).

Aug 15, 2011

C# is VS as

is (C# Reference)

Checks if an object is compatible with a given type. For example, it can be determined if an object is compatible with the string type like this:

if (obj is string)
{
}

as

The as operator is used to perform conversions between compatible types. The as operator is used in an expression of the form:
expression as type
is equivalent to:
expression is type ? (type)expression : (type)null
Note the use: 
ViewState["id"] = 10;
string s = ViewState["id"] as string. Then s will be null.

Aug 16, 2010

[部署]部署工具Capistrano

Capistrano是ruby on rails提供的部署方案,原名叫SwitchTower。它集成了很多部署程序必须的步骤,借助ssh、版本管理系统(支持svn、cvs等等好几种)和rails的migration,只要做好配置,就可以在很大程度上实现部署自动化。

Mark一下,万一以后用的着方便找到。

Apr 29, 2009

SQL Server解锁步骤

1.创建一个临时Table
CREATE TABLE #HarveyLock
(
SPID INT,
DBID INT,
OBJID INT,
INDID INT,
TYPE VARCHAR(100),
RESOURCE VARCHAR(100),
MODE VARCHAR(100),
STATUS VARCHAR(100)
)
2.将Lock信息存入该Table

INSERT INTO #HarveyLock EXEC SP_LOCK
3.在Table中下条件查询得到的LOCK
SELECT * FROM #HarveyLock
4.KILL 相关LOCK
KILL @SPID