Wednesday, August 29, 2012

Get Singapore Stock Market Quotes in Google Docs

*20 August 2018 update: Due to data unavailability for both Google Finance and Yahoo finance, i had created a new Google Apps Script to download and import SGX daily price list data to Google sheets. Please refer to this link for details.

* 24 Feb 2014 update: Recently, i have had some problem with getting the result from Yahoo finance and the cell always show #VALUE! with error - "The data could not be retrieved. Please check the URL". I tried to use GoogleFinance again and it seems like they finally start to support SGX stocks. So to get the price of stock like Keppel Land, just type the following in the cell

=GoogleFinance("SGX:K17")

So the syntax is quite easy, just type in the stock quote name with SGX: precede in front. The only problem is the limitation of 2 decimal points...

For more information on what data can be retrieved, please refer to this link.

=====================================================================

If you are using Google Docs to keep track of your stocks statistics, this will be something very useful to you. By having the ability to import stock market quotes directly, you can manipulate this data further, example - to calculate paper gain/loss quickly.

Google actually provide a useful tool which is GoogleFinance* for this purpose but unfortunately, Singapore stock is not supported. Luckily, there is still this tool call ImportData which we can use to import structured data from other website like Yahoo Finance.

To do this, first,  you need to know your stock symbol. You can get this easily by typing the stock name in the get quotes field. Screenshot shows the list of possible stocks after i type in Keppel Land.


After you know your stock symbol, you just need to type the following in the cell of your spreadsheet document and replace the italic word with your own options. You can go to the following link for all the special tag options.

=ImportData("http://finance.yahoo.com/d/quotes.csv?s=stock symbol&f=special tag")

For example, if you want to get last trade price for Keppel Land, i just type the following:

=ImportData("http://finance.yahoo.com/d/quotes.csv?s=k17.si&f=l1")

and that's it, you can see that Google Docs will load the last trade price in the cell as shown below:




Thursday, August 2, 2012

Configure ramdisk for Openfiler


Create a new file under /etc/bootloader.d directory. In this new file, type add_options ramdisk_size=32000. Please note that the unit is in kilobytes. The example below shows the new file is called ramdisk.conf and the content of this file.

[root@abc ~]# cd /etc/bootloader.d
[root@abc bootloader.d]# ls
distro-defaults.conf  plymouth-bootloader.conf  ramdisk.conf  syslinux_bg.png
[root@abc bootloader.d]# more ramdisk.conf
add_options ramdisk_size=32000


After the file is created, type bootman to apply the configuration as shown below

[root@abc ~]#bootman


Restart your machine and you can check whether is it successful by typing cat /proc/cmdline as shown below:

[root@abc ~]# cat /proc/cmdline
mce=dont_decode cciss.cciss_allow_any=1 splash quiet ramdisk_size=32000 ro root=LABEL=/ initrd=/initrd-2.6.32-71.18.1.el6-0.20.smp.gcc4.1.x86_64.img BOOT_IMAGE=/vmlinuz-2.6.32-71.18.1.el6-0.20.smp.gcc4.1.x86_64


Create a filesystem on /dev/ram0 and mount it up and you will have a 32MB ramdisk.

Thursday, June 28, 2012

PowerShell to check MSSQL database status

A very simple Powershell script to check database status.

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') ServerName
$db = $s.Databases.item("databaseName")
"status: " + $db.status + " isaccessible: " + $db.isaccessible

Example output:
Database status is normal
status: Normal isaccessible: True

This output is created by renaming the log file.
status: RecoveryPending isaccessible: False

For more status description, please refer to this Microsoft site.

Tuesday, March 20, 2012

Useful Linux Command - mkdir -p

-p (parents) option for mkdir gives you the ability to create a multiple levels deep directory with all the intermediate directories created as well.

Example: When you want to create a directory tree like this /a/b/c/d, where a,b,c,d are all not exist before, you need to create each directory independently like

mkdir /a
mkdir /a/b
mkdir /a/b/c
mkdir /a/b/c/d

if you do mkdir /a/b/c/d, you will encounter "no such file or directory" error.

With -p option, you can create /a/b/c/d with just one single line of command as shown below:

mkdir -p /a/b/c/d

Tuesday, February 14, 2012

Load Brocade CNA driver for Openfiler

1. Download the rpm package from Brocade website. Choose the "Linux - Other Distributions".
2. Perform the following steps to extract the bna files (Ethernet package) out from the rpm package

rpm2cpio bna_driver_linux-3.0.3.0-0.noarch.rpm > temp-file.cpio
cpio -idumv < temp-file.cpio

3. You should be able to see a usr folder in your working path. Copy all the files inside ./usr/src/bna folder to the /usr/src/.

cp ./usr/src/bna /usr/src/ -R

4. Go to /usr/src/bna and execute make.
5. After that, you should be able to locate a file call bna.ko in the /usr/src/bna directory.
6. Run insmod bna.ko to install the module and then you have your Ethernet driver loaded successfully.

Thursday, October 27, 2011

Ubuntu: Running Dynamo Executable: No such file or directory

Symptom:

root@testMachine:~/iometer-2006_07_27.linux.i386-bin/src# ls
dynamo  iomtr_kstat  scripts
root@testMachine:~/iometer-2006_07_27.linux.i386-bin/src# ./dynamo
-bash: ./dynamo: No such file or directory

For this case, you need to make sure you have ia32-libs installed. To check whether the package is installed, run:

root@testMachine:/# dpkg -l ia32-libs
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  ia32-libs      20090808ubuntu ia32 shared libraries for use on amd64 and i

if it shows "un", meaning ia32-libs is not installed. If is installed, it will show "ii".

Install ia32-libs by

apt-get install ia32-libs

* Please note that, for simplicity, i using root account to run the above command, you might need to add sudo in front of the above commands if you are not using root account.

Thursday, October 13, 2011

dpkg : status database area is locked by another process while trying to install

This will happen if you accidentally kill the apt-get process and dpkg become orphan process. To solve this problem you can either

Reboot your server or do the following:

sudo rm /var/lib/dpkg/lock

sudo dpkg --configure -a