Wednesday, July 20, 2011

Start MySql with launchd.plist

1. Create a mysql plist file on /Library/LaunchDaemons/com.mysql.mysqld.plis

2. Start MySql Server
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

3. Stop MySql Server
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist


How to uninstall Mysql in MacOS

Do this command first:
vim /etc/hostconfig and removed the line MYSQLCOM=-YES-

Then do the following lines:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
sudo rm /etc/my.cnf
rm -rf ~/Library/PreferencePanes/My*

Do not forget to remove the my.cnf file.

Monday, July 11, 2011

Spots

import java.awt.*;

public class Spots extends java.applet.Applet{

final int MaxSpots = 10;
int[] xPositions = new int[10];
int[] yPositions = new int[10];
int currentSpots = 0;

public void init() {
setBackground(Color.black);
}

public boolean mouseDown(Event evt, int x, int y){
if (currentSpots < MaxSpots){
addSpots(x,y);
}
else
{System.out.println("Too Many Spots.....\n");}

return true;
}

void addSpots(int x, int y){
xPositions[currentSpots] = x;
yPositions[currentSpots] = y;
currentSpots++;
repaint();
}

public void paint(Graphics g){
g.setColor(Color.blue);

for(int i=0; i < currentSpots; i++)
{
g.fillOval(xPositions[i] -10, yPositions[i] -10,20,20);
}
}

}