07 November, 2010

Removing MYSQL completely from OSX

Today I was running through hell to find out how to remove mysql completely from OSX. Why I wanted to do this is to I installed a wrong version of MySQL on my mac, and wanted to downgrade it, and when I try to install the older version it never allows me to install and says there is a newer version installed on my disk, and therefore cant let me install the one I am trying to do.

alright here is the trick

follow these steps and it should remove mysql from your machine.

1. Make sure you have killed mysql
2. Delete the mysql folder in the local folder ( sudo rm -Rf /usr/local/mysql and sudo rm -Rf /usr/local/mysql* )
3. Remove mysql references from the StartupItems ( sudo rm -Rf /Library/StartupItems/MySQLCOM )
4. Remove it from the PreferencesPanes ( sudo rm -Rf /Library/PreferencePanes/My* )
5. Edit the host config ( vi /etc/hostconfig ) file with VI editor or any text editor you prefer and remove the line MYSQLCOM=-YES-
6. Most importantly you have to delete every mysql related file from the receipts folder ( cd /var/db/receipts/ AND cd /Library/Receipts/ )

These steps have to solve the issue. It worked for me anyway.


20 September, 2010

Easy steps to set up SVN

At SilverStripers I have been working on setting up SVNs for 100 times, every two weeks I am setting up a new SVN repo, sometimes I have to install SVNAdmin and start from the scratch. Then there comes Capistrano for deployments, etc. etc.

Though that it will be good to maintain a blog post on how to set up SVN as then I can refer to it anytime I need, and thought it will be useful for others if I blog it here. Following are the steps I use.

Installing a SVN admin

this is a good source (http://subversion.apache.org/packages.html)

I mainly use Fedora and Debian

If it is Fedora
$ yum install subversion

If it is Debian

$ apt-get install subversion

Alright I've got the SVNAdmin now.

1. Creating a repository

svnadmin create /repo

2. Create users

vi /repo/conf/svnserve.conf

configure the svn ( these are some basics )

anon-access = none
auth-access = write
password-db = passwd

add the password file

vi /repo/conf/passwd

In that file add the users

username = password

3. Start SVN

svnserve -d

14 July, 2010

SilverStripe HTMLText Ripping off HTML Tags

I dont know whether this post will be that interesting. Yet this is something which I was trying for sometime with SilverStripe.

Let me explain my problem. I think everyone knows MailChimp. I got a HTML form from mailchimp and I want to provide the client with a TextField to edit the form when ever he needs. Now as you all might guess I did a code as such

class MailchimpPage extends Page{

static $db = array(
"MailChimp" => "HTMLText"
);

function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.MailChimp", new TextareaField("MailChimp"));
..........
return $fields;
}
.....


All looks fine. But what I enter there on the field had some empty DIV tags.
which looks like ( <div></div> ).


When I save the page with a save and publish what happened is that SilverStripe tried to make these tags self-closing. eg ( <div /> ) This is not valid at all. There is no such tag.

Now I was scratching my head for sometime and got an idea. What I did was made the HTMLText type to Text. Okay one battle is over, the HTML snippet get saved without anything being ripped off. Now the second. This appeared on the site's front as HTML, not processed. This might be because of the Convert class, anyway I dont want a piece of HTML to appear on the web page, the client will rip my head off instead :D.

Alright, I did something pretty nice there, Now though the Database field is not a HTMLText I wanted the output to be HTMLText.

I added a function similar to the following to the Controller of my page.

function HTMLForm(){
$field = new HTMLText();
$field->setValue($this->MailChimp);
return $field;
}


Now you know whats the trick there. I am wrapping the Text field with a HTMLText field, and then it worked. The Viewer doesn't know what I am doing.

Thought this might be interesting as no one on the IRC could help me out, as well as didn't find any source for this.

01 June, 2010

An editor of choice

From the start of my life as a hacker I have been trying out so many editors. I have been arguing this over the past 4 years too. Most love to work with IDEs like Eclipse, Netbeans, etc. and some like to use specific editors like Adobe Dreamweaver, and some people like me would rather choose a simple text editor ( VIM, TextMate, Notepad++, I use text mate on OSX ).

I thought that I have to write about my experience in finding an editor and why I preferred text mate.

First thing is when I started my ABC programming I had to use the notepad at the university mostly for java, and html. It didnt work out long. Soon I jumped to textPad another good editor which I found on Windows. But I didnt have much of time to spend with textPad I started using Macromedia Dreamweaver for my web development stuff. And mostly used netbeans for java. I was working with these two for more than an year and they became my good friends at work. I was a freelancer at that time.

After I joined my office, I became a full-time web developer, and I got Abode CS3 suite, as you might guess I started working with Dreamweaver, and I had to use Eclipse too in time to time. Its being quite nice, but from now on I wont say it nice. True the editor gives you code suggestions, IDEs handle the classes, name spaces, auto code generations, and lots. During this time actually I did a lot of home work with php, and I never did use eclipse or Dreamweaver at home cause I wanted to save each megabyte of my RAM.

Alright then things changed, I got my first apple ( a macbook ) early this year, I was searching for a good editor for me. Didn't want to install Adobe there too. And when I was searching over the net I found the best editor I have had for all my life and it was textMate.

All of the coding is much more simple, the editor helps me to keep the code clean, and some nice features like using colors on codes, saving projects, traversing through the class methods etc. And what I love most is that it supports HTML, CSS, XML, PHP, Python, and Ruby ( which I am working a lot these days ), also I bought my copy of license for the product, and I am now doing all my work with this nice editor which I got for about 35 pounds.

Let me write why I really liked this, with these simple editors you can be a real hacker.

1. You will be much more flexible, you will be able to code in any editor, whether its an IDE or something like Dreamweaver.

2. You will learn a lot. Yes you will be reading, understanding, learning a lot. This way of hacking helps me on my self-improvement as a sophisticated hacker. Most of my friends stick to IDEs and editors as these softwares helps them all the time to code. (personally I read a lot of documentations while hacking)

3. More simple = more disciplined. This is one of the most important things I think, for each and every code I write I do it with great care. I always try to make it super neat and tidy, comment the codes nicely so for later use its much more easy. When declaring variables / methods / functions I never do them leaving them to garbage collectors. When I use a simple text editor I always know what happens in every bit of the code, and as I know this, I have a huge potential of writing codes as a disciplined hacker.

4. It save my resources. When I was on windows, and dreamweaver I could feel my computer running much slower sometimes ( I dont have a super high computer ). But now I have never felt it that way so I know my resources are there for my work, not wasted for some fancy thing.

In my case it has been a great experience with textMate on osX, hope this will be useful for others searching for their editor.

07 March, 2010

Solving the PHP timezone on Snow Leopard

I had this problem for sometime, tried 100 times changing the /etc/php.ini.default and restarting the server.
But to say how stupid I am, it was only one more step for me to get this done.

Let me explain how I set the timezone on my snow leopard.

1. I got my /etc/php.ini.default opened in my text editor (I use textmate, and open it as the root user).

2. Find the date controllers, search for "[Date]".

3. Now I had to set my timezone which is "Asia/Colombo" (for PHP list of supported timezones click here)

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Asia/Colombo"


4. Save the file and rename it to php.ini ( mv /etc/php.ini.default /etc/php.ini)

04 March, 2010

More CSS 3 - Analog Clock

It has been fun since today morning! (if you read my previous post, it was a DoS attack the hosting said, am waiting for that to be fixed. ) Anyway I have something to show which is a Clock done with CSS 3.

Playing with CSS 3

Today morning I got up early to do some work on a site. But its a pity that the server responded me with time out errors. So I was totally disappointed about what happened. But things are not too bad at all I got a chance to try out some CSS 3.

Following is an image rotation which I try to do with CSS 3. You will need firefox 3.5 + to view this.

Spent some time with Adobe Illustrator. Didn't know I could d... on Twitpic

This image is rotated using CSS.

Below is my CSS

<style type="text/css">

#IMG1{ -moz-transform: scale(0.6) rotate(335deg); border:3px solid #CCC; }

<style >

Cool isn't it?

See what more imagination can do

 
 

03 February, 2010

Nidahas

Nidahas in Sinhala means Freedom, Freedom in the sense of Free as in Freedom.
Today Sri Lanka celebrates their 62nd Independence day.
Its quite special today as this is the first independence day after finishing 30 years of war against LTTE.
I have a gift for the day, and its 14poems.com. As mentioned on my previous blog post I started paying my respect for the whole nation by blogging a fortnight continuously.
Welcome to have a read.

31 January, 2010

14 days of blogging from February 4th

I have some feeling to do something special for the coming independence day, on 4th February 2010.
For that I thought I should blog 14 days continuously, my theme is Tibet S. Mahinda thearo's poems. I will be writing 14 essays on 14 selected poems of S. Mahinda thearo.
I will be writing more about this on my blog, these days working on the designs, and buys needed hosting for the project. Would love if you my friends read them.