Pages

Monday, July 11, 2011

Cleaning up my GMail Account

Once i thought my Gmail account is impossible to fill, but after a few years, couple of mailing list, couple of crazy mailing list, now i often need to clean up my email to make sure no email is lost because my inbox is full. This is what i usually do

Find email that has an attachment
This is usually the quickest way to free same space. You can use
has:attachment to query the mail that contains attachment in the search box. Or if you want, you can even specify the type of file by using filename: .doc adding "label:" to the query can give more refined search. Too bad we can't sort it by the attachment size

Using date
We can also use date to delete our old email. This can be done by using the "before:" and "after:" query. For example :

label:notification before:2011/01/01 after:2010/01/01


Again, using label like the above example, can help to refine your search. And to lessen the impact if you search and then delete the wrong query :)

Starred mail
While using the query above is very useful but often the queries return hundred or even thousand of emails. GMail will page the result, dependent on your settings it can give 25, 50 or even 100 in each page. But still a tedious task to do. GMail can help you even more, by selecting all of the email in that page, another option will come out in the top, that will let you select all of the email in this query. And then delete it.

But this approach is a "scorched earth" approach. You will delete all of the email, but sometimes there are important email included in this search, the one that we usually mark with a star. Logically, we want another parameter in our query. Looking for a starred email can be done by adding is:starred parameter to our query. But what we need is a "not starred" parameter. This can be achieved by negating the previous parameter to :
-is:starred . But the problem is, even there's only one email in the thread that isn't starred. The thread would still be selected.

Thus why i create my own method to handle this. first i create a temporary label named "my_starred" then i go to each label and query

label:notification before:2011/01/01 after:2010/01/01 is:starred


selecting all, and add my_starred label. And then remove the notification label. After that you an select the notification label again with the date range, and then delete all the email. The last step is to go to the my_starred label, and change it back to the notification label. Repeat this for every other label that you want to clean up.

Heaven

Sometimes people have to go through a series of unfortunate event. To understand, that their values didn't belong in this world. To Let go will give you a better understanding and the opportunity to rise again from the ashes, just like a phoenix soaring up to the sky.

Heaven is Dead

Wild beast

The thing that we bear for others
The things that we must do.
what we mustn't do
in the name of society, norm and values.

But sometimes, it is necessary to be savages.
To give in, to let your anger explode
Becoming the wild beast that is full of lust and hatred
Becoming the purest kind of human
that will survive
above everything

Because after all of that has passed,
you will find true calm and peace

Wednesday, May 4, 2011

Debugging HTC Hero in Ubuntu

So, when I'm not on my PC. I'm using ubuntu in my laptop. Turn out, developing on the device is not as a simple as in windows. You need to follow the link below to make it work.

http://forum.xda-developers.com/showthread.php?t=823956

Saturday, April 2, 2011

Its time to have some bug tracking tools - Installing Trac

We're in the stage where simple notes.txt isn't enough to track our project. I think we need a better bug/feature tracking tools. So, I'm going hunting for a few of the common bug tracking tools that's available on the market.

I narrow down my choice into two, Jira and Trac. I've used Bugzilla before, but it never clicked with me. And also Bugzilla and Mantis have their own horror story. Jira actually caught my attention with the $10 starter pack. But the next packet, 25 user for $1,200 is way out of my league.

So finally my decision goes to Trac. It was simple enough. People won't be distracted or hinder by the many fields they need to fill to submit a bug. Both Jira and Trac support mercurial. Just perfect. And although simple and minimalistic Trac have two very cool feature :
  • Timeline – shows current and past project events in order
  • Roadmap – shows the upcoming milestones to be achieved in the project

The only drawback in Trac is the interface, it has its way to annoy you when you look at it too long :P

Installation

I wont be installing this from scratch. I will be installing this at the last state of  my infastructure post.

You can install Trac with mercurial support using this three simple steps :
sudo apt-get install python-setuptools
sudo apt-get install python-genshi
sudo apt-get install trac-mercurial

But when i write this blog post the trac version in ubuntu repository is 0.11.7. Since i want to use trac 0.12, I'll be doing some of the things manually.

First I installed the setup tools using apt-get.
sudo apt-get install python-setuptools

Then I'm using setuptools easy_install to install Genshi and Trac
sudo easy_install Genshi
sudo easy_install Trac

And for the trac-mercurial plugin, you need to check out and build it manually. But first you need to install subversion.

sudo apt-get install subversion

check out the code, build the egg, and install it
mkdir trac-plugin
cd trac-plugin
svn co http://svn.edgewall.com/repos/trac/plugins/0.12/mercurial-plugin
cd mercurial-plugin
python setup.py bdist_egg
sudo easy_install dist/TracMercurial-0.12.0.28dev_r10657-py2.6.egg

After finished installing Trac, lets do some test. But first you need to create a database for Trac in mysql. Using mysql root user :
-- It is better to set the innodb as the default storage engine
mysql> create database trac;
mysql> grant all privileges on trac.* to 'trac'@localhost identified by 'mypassword';
mysql> flush privileges

Trying logging out and then loggin in using the new account.

Next, you need to install python library for connecting to mysql from python.
sudo apt-get install python-mysqldb

And the basic setup is complete.

Create A Trac Project

Now we need to create a trac project. Since i want it to be integrated with my mercurial server. I've created the project in my hguser account.
sudo su - hguser

create the directory for your project
mkdir -p ~/trac/myproject

init the project
trac-admin ~/trac/myproject initenv

If you're having a problem with trac-admin not in your path, try logging out and then relogin to your system.

The initenv command will ask some question. On the database connection string input this :
mysql://username:password@hostname:port/databasename

After finish with the environment, we need to modify the configuration file to support mercurial.
vi /home/hguser/trac/myproject/conf/trac.ini

modify the file with the line below :

[components]
tracext.hg.* = enabled[repositories]

[trac]
repository_dir = path_to_default_repository
repository_type = hg


You can start trac server and see the result by accessing http://yourserver:8000/myproject

tracd --port 8000 ~/trac/myproject

Integrating with apache

Mod_python is dead, so I'm choosing mod_wsgi to integrate trac with my apache server. First you need to install mod wsgi and restart the apache2 server
sudo apt-get install libapache2-mod-wsgi
sudo service apache2 restart

sudo to the hguser and create egg-cache directory under ~/trac/myproject

to create the wsgi file you can create it manually, or use the trac-admin deploy method like below :
trac-admin trac/myproject deploy /tmp/deploy

it will create the .cgi .fcgi .wsgi file under the cgi-bin directory. Then you can copy the file to the real cgi-bin directory
sudo mkdir /usr/lib/cgi-bin/trac
sudo cp /tmp/deploy/cgi-bin/trac.wsgi /usr/lib/cgi-bin/trac/myproject.wsgi
sudo chmod +x /usr/lib/cgi-bin/trac/myproject.wsgi

now you need to add the new location to your apache configuration file. Usually it's under site-enabled/000-default-file . I'm using port 8008 for this purpose but later will create a subdomain for trac :


ServerAdmin webmaster@localhost
DocumentRoot /var/www

#WSGI scrip for trac
WSGIScriptAlias /trac/myproject /usr/lib/cgi-bin/trac/myproject.wsgi

        <Directory /home/hguser/trac/myproject>
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
        </Directory>

After restarting apache, you should be able to access your trac installation in http://yourlocalhost:8008/trac/myproject

While trying to integrate trac with apache, I keep stumbling to an error that said :

TimeoutError: Unable to get database connection within 0 seconds. (TracError: Database "/usr/www/trac/db/trac.db" not found.)

I'm using mysql so trac shouldn't need to create the embedded db. It seems that trac couldn't read the content of my trac.ini files. It turn out that I've stumble to this bug. As a work around I added group read-write permission ,
sudo chmod g+rw ~/trac/myproject/conf/trac.ini
but i wonder, will this create a security problem. Since the trac.ini contains the db access URL ?

Configuring Authentication

To add authentication method, I just added my mercurial hgusers file

        <location /trac/myproject/login>
                AuthType Basic
                AuthName "Trac"
                AuthUserFile /home/hguser/hgusers
                AuthGroupFile /home/hguser/hggroups
                Require group myproject
        </Location>

To be able to use the admin web page you need to add admin privileges to your user
trac-admin ~/trac/myproject permission add frodo TRAC_ADMIN

it is recomended to install the AccountManager plugin. To install it run

sudo easy_install https://trac-hacks.org/svn/accountmanagerplugin/trunk

and then go to the admin tab > plugin , and enable the features

Removing anonymous user access

You can disallow anonymous user access by


trac-admin ~trac/myproject permission remove anonymous '*'

Thursday, March 17, 2011

Mercurial : Separating two groups

In my mercurial setup a new requirement has come up. I need to separate two groups of user, lets call the first group research and the second one project. A user can belong to one of the groups or both. My mercurial server is setup like this, and then I modified it a little to enable the virtual server name right here. To implement this requirement I'm following the public and private repositories and modified it a little.

Configuration

First, what i do is i log-in as the hgusers (user I've setup specially for mercurial, see the first blog post). At the hgusers home directory I've created a new folder called project. And then I move hgusers and hgweb.config from the hg folder to the hgusers main folder.

We need to create a different set of file for our repositories. So copy each of the config files :
$> cp hgweb.config hgweb_project.config

and then modify hgweb_project.config content so it will point to the new project folder. The file content should look like this :

[collections]
/home/hguser/project/ = /home/hguser/project/

now go to our hgweb.cgi directory and copy the file
$> cd /usr/lib/cgi-bin/hg/
$> cp hgweb.cgi hgweb_project.cgi

modify the config variable to point to the project repo folder

config = "/home/hguser/hgweb_project.config"

and finally modify the apache settings
vi /etc/apache2/sites-enabled/000-default

copy the previous ScriptAlias and Location div, and modify it to point to the project location. Another that you need to do is to add the AuthGroupFile, and change The Require line. I will go into detail about this in the next section. The file should look like this :

ScriptAlias /project /usr/lib/cgi-bin/hg/hgweb_project.cgi


AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /home/hguser/hgusers
AuthGroupFile /home/hguser/hggroups
Require group project


ScriptAlias /repo /usr/lib/cgi-bin/hg/hgweb.cgi


AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /home/hguser/hgusers
AuthGroupFile /home/hguser/hggroups
Require group research

Creating Group
I already have user sam and frodo from my previous settings. Now i'm adding two more user using htpasswd command. The users are golum and sauron.

Now we need to create the group for these users. To do this go to the hguser home directory and create a new file called hggroups. You can use VI or your favorite text editor to create it. The file content should look like this :

research: frodo sam golumn
project: golumn sauron

the word before the colon is the group name, like the one you specify on the Require group line. And the words after that is the users that belong to the group. In my setup sauron would only able to see the project repository (limiting his access). And so does frodo and sam, they can only see the research repository. While golumn would be able see both repo. Just what i wanted to.

If you wanted to have a lot of user that can access both group, you could create a new group and than add that group to the Require line

Sunday, March 13, 2011

I

I love non self centered people. And my number 1 list, is to witness a miracle, from me.