Friday, January 21, 2011

sudo: no valid sudoers sources found, quitting - ubuntu

Issue:

When I tried to add a new user into sudoer file  /etc/sudoers, I need to chmod sudoers
chmod +w /etc/sudoers
Then, system gave this error:
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting

Solution:
Enter Ubuntu recovery mode to change /etc/sudoers to 0440

enter ubuntu recovery mode in vm

press 'shift' when reboot the ubuntu in VM

Thursday, January 20, 2011

how to embed google map in website

Recently, I just added gmap to my customer's website
http://northbeachhealth.com/contact.php

Here are instructions:
1, get a free google api key
Here is the page to get key
http://code.google.com/apis/maps/signup.html

2, find longitude and latitude of the address
A, enter your address in gmap
http://maps.google.com/maps?oe=utf-8&client=firefox-a&rlz=1R1GGLL_en___US406&q=367+Bay+St.,+Suite+B+San+Francisco,+Ca.+94133&um=1&ie=UTF-8&hq=&hnear=367+Bay+St,+San+Francisco,+CA+94133&gl=us&ei=Vpw4TdHXN8TflgfYmLmHBw&sa=X&oi=geocode_result&ct=title&resnum=1&ved=0CBMQ8gEwAA
B, click the 'link' on the right top of the map, you will see
'Paste link in email or IM' and
'Paste HTML to embed in website'

Copy the code in 'Paste HTML to embed in website'.
You will find 'll=37.805672,-122.413083', they are longitude and latitude of the address


View Larger Map



3, add these code into your html page head part.
Go to the page http://northbeachhealth.com/contact.php
right click the page and get source code from line 8 - line 40

  <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAwRhSY6F_2jelV6V3hr36IRQXzaJo3hs4ignG9MPTCEQrUyb-4RTCJR_RLSFtILRbBVU3WW33j5ikTw"
  type="text/javascript"></script>
 

    <script type="text/javascript">
    function createMarker(point,html,what)
    {
        var marker = new GMarker(point,{id:what, name:"chemmol", description:"chemalog"});
        GEvent.addListener(marker, "click", function()
        {
          marker.openInfoWindowHtml(html);
        });
        return marker;
    }
     
    function initialize()
    {
      if (GBrowserIsCompatible())
      {
            var map = new GMap2(document.getElementById("map_canvas"));
            map.setCenter(new GLatLng(37.805672,-122.413083), 16);
           
            var bz_point = new GLatLng(37.805672,-122.413083);
            var marker = createMarker(bz_point,'<div style="width:240px">BinZhi Acupuncture Clinic  <p>',"this")
            map.addOverlay(marker);     
       
            map.openInfoWindow(map.getCenter(), document.createTextNode("BinZhi Acupuncture Clinic"));
            map.setUIToDefault();
           
        }
    }

    </script>

4, in your html page body
copy
 <div id="map_canvas" style="width: 400px; height: 500px"></div>

dump mysql table to csv file

1, Login to mysql terminal:
c@cm-test:~$ mysql -u xxxxxx -pxxxxxxx mydatabase

2, run:
mysql> select * into OUTFILE 'abc.CSV' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM excel_unique;

3, the file should be in
/mydisk/lib/mysql/mydatabase/abc.CSV

Friday, January 14, 2011

Thursday, January 13, 2011

get table info

method 1:
mysql> show create table xxxxxxxxx;
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| compounds | CREATE TABLE `xxxxx` (
`mol_id` int(10) NOT NULL AUTO_INCREMENT,
`uid` int(10) DEFAULT NULL,
`ucid` varchar(255) DEFAULT NULL,
`CASNumber` varchar(255) DEFAULT NULL,
`CName` varchar(255) DEFAULT NULL,
`SubstanceID` varchar(255) DEFAULT NULL,
`MF` varchar(255) DEFAULT NULL,
PRIMARY KEY (`mol_id`),
UNIQUE KEY `CAS` (`CASNumber`)
) ENGINE=MyISAM AUTO_INCREMENT=49400000 DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC |
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>

method 2:
mysql> select * from information_schema.tables WHERE table_name='table_name' and TABLE_SCHEMA='db_name';

+---------------+--------------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+-------------------------------------------------+---------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME | UPDATE_TIME | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+--------------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+-------------------------------------------------+---------------+
| NULL | xxxxx | compounds | BASE TABLE | MyISAM | 10 | Dynamic | 0 | 0 | 0 | 281474976710655 | 2048 | 0 | 49400000 | 2011-01-13 16:10:20 | 2011-01-13 16:10:20 | NULL | latin1_swedish_ci | 0 | checksum=1 delay_key_write=1 row_format=DYNAMIC | |
+---------------+--------------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+-------------------------------------------------+---------------+
1 row in set (0.00 sec)

mysql reset auto_increment

alter table compounds auto_increment=49400000;