Thursday, February 9, 2012
Why is Weekend so important to programmer?
Weekend is a time for programmer to do his things on his own way.
Those two days are filled with exploration, excitement and doing things beyond what he always do on weekdays. Those are the days where he enhances his programming practice which is his codebase. Those are days where he is learning new things and formulating a simple application to showcase it. Those are days of the week that he is so true, that no one may disturb him while he is on his logical and imaginative mind.
On those days, he will do things on his way, we will make sure that every minute counts. He will read everything that catches his mind and will implement it. He will do diffucult bugs also sometimes enhance it on that day. And as that weekend close, he will never see any TO DO on his codebase.
Those days, he will go beyond his capabilities, he will push himself to create and learn new things for only forty-eight hours. Sometimes he will fail on doing it but still he is happy, because he learn again new technology and created something that has put him to what makes him original on his programming life.
On those days, he will be staying on his cave, maybe it will be a room, in the living room or maybe even in the kitchen. After forty- eight hours of meditating, he will evolve as a new man. He now has a new skill set on his sleeve, new methodology that he discovers more efficient, a new thinking that had been formulated on the two days of rumination and that novel view that programmer is never selfish, for he will be grateful to share it to the world. He knows that what he discovered on that two divine days will be of great use and not just meant on a recycle bin. Most of all, he know that if he share it to others, what he had discover on that two days will unlock more astounding designs that programmers can use.
Those are the days when the programmer rest. It‘s just that REST for programmer is doing things beyond their limits and a means to breakaway. Rest for him is learning new things, creating and producing something valuable through them.
Sunday, January 29, 2012
Add new YUM repository Fedora
All the RPM (RedHat Package Manager) that are based linux (such as Fedora, CentOS, RHEL) use yum for software management. Yum always help you to install application through remote repository of rpms.
Yum Repository in Deeper Sense
If you want to tween yum, you can do so by editing /etc/yum.conf (I will explain the configuration next week). And by default, all the configuration of yum repository are located on /etc/yum.d and /etc/yum/repos.d dir. (defined by reposdir)
Installing RPM direct from the repo
If you know the location of an RPM on the web, you can install it by adding it’s remote repository (so RPM does not belong to any repository) just by:
rpm -Uhv protocol://location-of-file-in-the-web
where U means upgrade; this will install the new version (if your rpm is the new version) and remove the old one.
v means verbose; this will print verbose information - error messages or warning
h means hash; this will print 50 hash marks as the package archive is unpacked.
protocol://location-of-file-in-the-web - this represent the location of your rpm to be installed on your local computer.
rpm -Uhv http://origin-download.mono-project.com/download-stable/openSUSE_11.4/x86_64/glib-sharp2-2.12.10-27.11.x86_64.rpm
Installing 3rd party repository manually
Based on the example, Let’s say I wanted to add a repository where glibsharp2 is located. So first I will create a file on /etc/yum.repos.d named mono.repo (to make it more meaningful)
cd /etc/yum.repos.d
vi mon.repo
Then put:
[mono]
name=mono
baseurl=http://origin-download.mono-project.com/download-stable/openSUSE_11.4/
enabled=1
gpgcheck=1
gpgkey=http://origin-download.mono-project.com/download-stable/openSUSE_11.4/repodata/repomd.xml.key
save and close it by pressing escape and :wq and enter.
where
[mono] - repository name
name=mono - repository name in more human readable string
baseurl=http://origin-download.mono-project.com/download-stable/openSUSE_11.4/ - the url of the repository, this location must include the content which is the repodata directory. This repodata contains all the information of the repo.
enabled=1 - means this repo is enabled, 0 if disabled.
gpgcheck=1 - security feature is enabled, 0 if disabled. This uses GPG key.
gpgkey=http://origin-download.mono-project.com/download-stable/openSUSE_11.4/repodata/repomd.xml.key - location of the gpg key of the repo
Sometimes you have to manually import the gpg key of the repository which is done by:
rpm --import http://origin-download.mono-project.com/download-stable/openSUSE_11.4/repodata/repomd.xml.key
If you need more information about rpm, yum and it’s configuration just:
man yum.conf
man yum
man rpm
Hope this can help you.. :)
Thursday, January 26, 2012
Branching and Merging for Git
Branching is a technique wherein you can create an active line of development for your source code. Through this, you will be able to create a separate copy of your source code that you can edit and merge to your original or other copies (branches).
In order to create a branch named “testing” on an existing git repository:
git branch testing
This will create a branch named testing.
In order to check your local branch:
git branch -l
To check for your remote branch
git branch -r
To check all available branch for your repo:
git branch -a
Example you inputted git branch -l, this will list all the branch on your local repo
testing
*master
The asterisk marks the branch you are currently on. For you to transfer to testing just:
git checkout testing
For you to transfer to master again, commit your changes first for testing branch then checkout master:
git checkout master
Therefore, the change you made on the testing branch is not visible on master.You can change then commit it.
If you are on master and you want to merge the changes of master and testing, you can do so by running:
git merge testing
If you’re on testing:
git merge master
Sometimes, there are conflicts on merging the two branch (conflict means you edit the same file on the same line). You can see all the file that has conflict by the use of:
git diff
If you can’t fixed the conflict on files and decided to give up you can:
git reset --hard HEAD
or if the change is committed use:
git reset --hard ORIG_HEAD
If you want to delete testing branch, just execute:
git branch -d testing
REFENCE:
Wednesday, January 25, 2012
The Promise
Monday, December 5, 2011
Changing user password
mysqladmin -u root password NEWPASSWORDif you want to change a root with a existing password, you can use this:
mysqladmin -u root -p 'oldpassword' password NEWPASSWORD
Changing MySQL password for non-root user
To change a normal user password you can use the same syntax as changing root with existing password:
mysqladmin -u username -p 'oldpassword' password NEWPASSWORD
Chaning User Password using MySQL command
You can also used the MySQL command line to update user's password, MySQL stores username and passwords in a table inside MySQL database.
- Login to mysql server.
- Use mysql database.
- change password for username by entering: update user set password = PASSWORD("NEWPASSWORD") where user='username';
- Lastly, restore the privileges: flush privileges;
Wednesday, November 30, 2011
Extracting tar.bz and tar.bz2 on Linux
tar -jxvf filename.tar.bz2where j means it's for bzip2, xz, lzip and lzma compress extension.
To extract a tar.gz file, the command is:
tar -zxvf filename.tar.gzwhere z means it's for gzip, gunzip and ungzip compression extension
x is extract files from filename.tar.gz
v is to list all the file proccessed
f is to extract filename.tar.gz
if you want to specify the directory to where the extracted file go, use this command:
tar -xvzf file.tar.gz -C directorywhere C means put extracted file to directory
Friday, November 18, 2011
How to know MySQL activities: MysqlBinLog
mysqbinlog [options] logfilelike:
mysqlbinlog /var/lib/mysql/localhost-bin.000005This command will then display the content of the binary file localhost-bin.000005. The content of this file is:
This 1st line which is "# at 430" means that the starting position of the event in the binary log file is 430. On the second line, the number's with colon is the timestamp of the event (this is when the event happen). The "server id 1" state that the event happen on server id number 1. "end_log_pos 537" indicates that the next event starts at 537. "thread_id=2" says that the thread that execute the event is id 2. "exec_time=0" means the time spent to execute the event. Lastly, the last line is the event executed by the server. As you can is it is an update.# at 430#111110 21:55:34 server id 1 end_log_pos 537 Query thread_id=2 exec_time=0 error_code=0SET TIMESTAMP=1320933334/*!*/;update Company set name='hello' where id = 1
For your server to log event as a binary file, you must first enable it. To enable, you must edit the my.cnf and append log-bin=path.
The normal formal of binary file logs is host_name-bin.###### and store in /var/bin/mysql directory.
Mysqbinlog I commonly use:
mysqbinlog /var/lib/mysql/localhost-bin.000005 > ~/mysql5.sqlThis will put all the content of the logbin to the file mysql5.sql.
mysqbinlog --start-datetime="2011-11-11 11:11:11" /var/lib/mysql/localhost-bin.000005This will only display event that is log on and after 2011-11-11 11:11:11.
mysqbinlog --stop-datetime="2011-11-12 11:11:11" /var/lib/mysql/localhost-bin.000005This will only display event that is log before 2011-11-12 11:11:11.
mysqbinlog --database=liims2 /var/lib/mysql/localhost-bin.000005
This will only display event that is invoke on database liims2.
Hope this will help you on using mysqlbinlog utility.
Reference:
http://dev.mysql.com/doc/refman/5.0/en/mysqlbinlog.html
http://dev.mysql.com/doc/refman/5.0/en/log-file-maintenance.html
Saturday, November 12, 2011
Updating from Fedora 15 to Fedora 16
First install the new Fedora 16 gpg key.
rpm --import https://fedoraproject.org/static/A82BA4B7.txtthen upgrade all packages using this commands.
yum update yum
yum clean all
yum --releasever=16 --disableplugin=presto distro-sync
you must have a root permission to do all the command above. so use sudo or log in as a root
Thursday, November 10, 2011
Maven - Installing Dependencies in your Local Computer
maven install:install-file -Dfile=foobar.jar -DgroupId=foo.bar -DartifactId=for-bar -Dversion=1 -Dpackaging=jar2. Create your own repository and deploy it there. This is a fovrite method for companies with an intranet and need to be able to keep everyone in synch. There is a Maven goal called deploy:deploy-file which is simlar to the install:install-file goal.
On the two ways stated above, I normally used the 1st one if the project is been done by I alone. And if it is a team project, the 2nd ways is what I used.
Monday, October 10, 2011
Mysql Database Back/Restore
- Mysqldump - this will create a dumpfile (also called textfile) or it will display the dump file on your console.
- Syntax: mysqldump -uMysqlUserl -p
databaseName <>> filePath> - mysql -uroot -p liims2
- after press enter will ask for password, display dumpfile of liims2 database as a whole in the console
- mysql --complete-insert -uroot -pmysql liims2 pnpa
- display the dumpfile on console of pnpa table with complete insert query
- mysql -uroot -pmysql liim2 >> /opt/mysql_backup.sql
- backup all the data in liim2 database and put it on /opt/mysql_back.sql file
- Mysql restore function - will restore you data from a dump file or text to a specific database
- Syntax: mysql -uMysqlUserl -p
DatabaseName << Backup.sql - mysql -uroot -pmysql liims2 << /opt/mysql_backup.sql
- restore all that data defined on /opt/mysql_backup.sql to liims2 database