• missing xbfish.com image
Life
missing xbfish.com image
Posted on

Finally, getting into the tutorial slot I wanted

NUS CORS is a bullshit system. I ranked a tutorial slot as my first choice and I didn’t get in. Ironically, I got a friend who ranked it as 3rd choice got in.

xbfish.com

After camping for the whole day today, I finally get into the tutorial slot that I wanted.

xbfish.com

“Guan Yin Ma” blessed me… :)

Uncategorized
missing xbfish.com image
Posted on

A clever way to recycle your old PC casing

missing xbfish.com image

Brillant, isn’t it? :)

I.T Concepts
missing xbfish.com image
Posted on

Conversion of Binary & Gray codes

First of all, you need to understand the truth table for Exclusive-OR gate:

Input Output
0 0 0
0 1 1
1 0 1
1 1 0

With this in mind, we move on to converting binary code to gray code.

Suppose we want to convert decimal 10, binary value of 1010 to gray code, the first step is to retain the most significant bit(MSB) of the binary. Hence,

1 0 1 0 (binary)
1 x x x (gray)

where x is still unknown.

Then, we take the adjacent pair of binary code to derive the 2nd significant bit of the gray code. Based on the truth table, 1 and 0 give us a 1 :

1 0 1 0 (binary)
1 1 x x (gray)

Then we move on to the next adjacent pair of binary code to get the 3rd significant bit of the gray code, with reference from the OR truth table :

1 0 1 0 (binary)
1 1 1 x (gray)

and lastly,

1 0 1 0 (binary)
1 1 1 1 (gray)

Therefore, the gray code of 1010 (decimal 10) is 1111.

Now, to convert gray code to binary code, we employ the same technique with the exception that we take the previous significant bit of the gray code and the next binary code to get the output.

Suppose we want to convert decimal 6, gray code value of 0101 to binary code, the first step is still to retain the MSB of the binary. Hence,
0 1 0 1 (gray)
0 x x x (binary)

where x is still unknown.

From here, we move on to take the previous significant bit of the gray code and the next binary code, which is 1 and 0. 1 and 0 give us 1.

0 1 0 1 (gray)
0 1 x x (binary)

and then we move on….

0 1 0 1 (gray)
0 1 1 x (binary)

0 1 0 1 (gray)
0 1 1 0 (binary)

Thus, the binary code of 0101 (decimal 6 in binary) is 0110.

Automotive
missing xbfish.com image
Posted on

Yamaha T135 Stock Battery

This is the stock factory battery for Yamaha T135 a.k.a Yamaha Spark 135:

missing xbfish.com image

This is a wet battery and its rating is 12V with a size of 5Ah.

I.T Concepts
missing xbfish.com image
Posted on

Converting 2-complement to decimal

To convert a decimal to 2-complement (2s), you first convert the decimal to binary and invert the bit. From there, you plus one and that would be the 2s of the decimal.

For example, a decimal 5 in binary would be: 0101 (in 4 bits)

The 2-complement of 5, which is -5, is:

First step: Invert the bits of 5 in binary -> 1010

Second step: Plus one to the inverted bits -> 1011

Hence, the 2-complement of 5 would be 1011

Now, to convert a 2-complement back to a decimal….

The algorithm is as follows:

“If it is positive, simply convert it to decimal. If it is negative, make it positive by inverting the bits and adding one. Then, convert the result to decimal. The negative of this number is the value of the original binary.” quoted from Mississippi College.

For example, convert 1101 to decimal.

First step: The sign bit of 1101 shows that it’s a negative decimal. Hence, we invert the bits -> 0010

Second step: We add one to the inverted bits -> 0011

0011 in decimal is 3. The negative of 3 is -3. Hence, the original binary value of 1101 is -3.

Software
missing xbfish.com image
Posted on

Automatically refresh Mozilla Firefox

The Mozilla Firefox addons, ReloadEvery, is a useful tool for automatically refresh or reload your Firefox.

The function is embedded in the browser context menu and it also comes with custom timing input where you can set the automatic refresh rate:

missing xbfish.com image

This is particularly useful for me especially when adding tutorial slot is instantaneous in CORS.

Automotive Video
missing xbfish.com image
Posted on

Old grandma from Taiwan riding motorcycle

The grandma is unbelievably strong to spin the big bike…

Programming
missing xbfish.com image
Posted on

[CakePHP 2.0] Authenticating user with email

By default in CakePHP 2.0, the authentication component make use of 2 fields to authenticate a user: username & password

If your web application requires user to login using email instead of a username, you can add in the following code snippet in the respective controller:

1
2
3
4
5
6
7
8
public $components = array(
        'authenticate' => array(
            'Form' => array(
                'fields' => array('username' => 'email')
            )
        )
    )
);

Take note that $components is a variable instead of a function under a controller.

Explanation: In the above code snippet, the email posted by the form will be taken as the username for the authentication component. The authentication component will then authenticate the user using email when $this->Auth->login() is called.

For more info, please refer to CakePHP 2.0 authentication component.

Automotive
missing xbfish.com image
Posted on

White headlight on my Yamaha T135

Previously, I was using a non-OEM normal bulb (35W ratings):

missing xbfish.com image

Currently, I am using this white bulb that I posted last month, (25W ratings):

Video
missing xbfish.com image
Posted on

My Heart Will Go On (in Cantonese)

Singer: Sally Yeh