Pages

Monday, July 11, 2011

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.

Thursday, February 24, 2011

Saving youtube video from google chrome

If you remember my post about youtube flv cache files, I've been saving my youtube video's manually. I like this approach because it allowed me to watch the video first, if I found it interesting then I will save the video. While some firefox plugin allow you to save youtube videos, it often force you to re-download the video from the beginning. And if you just download the video without watching it first, some time after one hour of waiting you just end up with a complete garbage !

These days I'm using Google Chrome as my main browser. So I'm faced with the same problem in a different environment. Unlike firefox, Chrome uses the windows temp to store its temporary files. Including the FLV files. But it's very defensive. You can't copy the cache while chrome uses it, and if you close the tab that shows the video, Chrome will immediately delete the file. Giving you no time to copy it. Damn you google guys :P

After some goggling i finally found a solution. Hobocopy to the rescue ! Hobocopy is an open source utility that can copy copy-protected file in windows. You can download hobo copy from here. Using this approach I can copy the protected files. The flv cache files can be identified easily by their name and size.  Usually it will start with fla and end up with .tmp extension. So using Hobocopy i can copy the file i want as simple as :

C:\HoboCopy.exe C:\temp F:\MyVideos\ fla18E.tmp

But you must be aware, since Hobocopy is not actually a file copy utility, the Syntax is a bit different.

Another thing that I've found out is about the firefox case. Remember when firefox only cache a part of my video but I can still play the full video in my browser. It turn out you can get the full FLV video's from Windows temp directory using this same exact method.

Now i can view my Youtube video's without worry about rebuffer and wasted a lot of bandwidth :D