How to use SVN (Subversion) on Google Code hosting

Google has generously offered free hosting services for free open source developers to host their projects either by using Mercurial, Subversion or git.

This blog post touches on the basic on to use SVN to maintain source code repository on Google Code Hosting.

Assumptions
This tutorial assume that you have :

  • Created an open source project on Google Code
  • Installed subversion on your GNU/Linux operating system
  • Have source code to import

Initial Import
You must perform initial check-in in order to use the SVN repository. To do that, you must go to your Google Code project, as shown in the screenshot.

subversion svn

From bash terminal, to import your project into Google Code, type:

svn import /path-to/src/ https://your-project-name.googlecode.com/svn/trunk/ --username example@gmail.com -m "initial import"

You'll be prompted to enter googlecode.com password, which you can generate from your Google project page

SVN commit
After initial import, your source code will be made available from Google Code hosting for public access.

You may 'commit' after you've made revision or alteration into the source code. to "commit" type:
[bash]
svn commit -m "added new TextField to user-interface"
[/bash]

the -m specifies change log, you shouldn't commit without a proper log message as this will help other users to track the changes that you've made with your source code.

SVN add: For adding new source files
If you add new files to your source code, just type:
[bash]
svn add <filename>
[/bash]

You may then proceed with "svn commit" to add the file to the repository server.

Recursively add unversioned files into SVN repository
If you've added several new files into source code working copy, these file will be unversioned and thus won't be committed to the subversion server.

You can use this command recursively add new unversioned files to svn repository.

[bash]

svn status | perl -ne 's/^\?\s+(\S.+)$/\1/g;chomp;system("svn add \"$_\"");'

[/bash]

**taken from http://www.amiryan.org/2009/04/22/howto-recursively-add-unversioned-files-into-svn-repository/

Backup your Gmail account in Ubuntu Linux with gmvault

This is a follow-up of my previous post “What to do when your Google disabled your Gmail account?“.

Here’s how to download all emails from your GMail account with Gmvault:

Download and setting up gmvault

1. First you need to install python-pip
[bash]
sudo apt-get install python-pip
[/bash]

2. Then using ‘pip’, install gmvault
[bash]
sudo pip install gmvault
[/bash]

3. Finally you can sync and backup GMail accounts with ‘gmvault
[bash]
gmvault sync your_username @ gmail.com
[/bash]

4. gmvault will ask you to authenticate yourselves with GMail, and after that, the syncronization process starts. gmvault stores all the gmail backup in the ‘gmvault-db‘ directory.

p/s: Some users encounters error telling that the “All Mail folder is not visible”. You can enable All Mail folder visibility by checking the “Show in IMAP” box in Settings->Labels. Also, IMAP access should also be enabled for this to work.

p/s 2: It might not be obvious right now why you need to backup your emails when Gmail has gigabytes of storage. But according to Gmail discussions group, Google can and might disable access to all of its services, locking the users out from their emails forever.

How to optimize MySQL tables automatically using cron

Busy websites which has a lot of insert/delete transactions may introduce fragmentation in MySQL tables. Fortunately, users and optimize mysql tables with ‘OPTIMIZE TABLE’ command, but how to execute it automatically?

Here’s how:
The mysql-client package in Ubuntu installation comes with a tool called mysqlcheck which is handy for optimizing table in mysql. This command can be executed from bash and can be executed using cron.

to do that, just run this command.

[bash]
cron -e

#in the crontab file– add this line
59 23 * * * /usr/bin/mysqlcheck -o -v -u <mysql username> -h localhost <database_name> -p <password>
[/bash]

This will tell cron to execute mysqlcheck and optimize mysql table of the specified database exactly on 11:59pm, every day. You can change the setting to suit your need.

How to secure server from SYN-flood attack using iptables

SYN-flood attack is commonly utilized as a mean to disrupt network communication and it is a form of (Distributed Denial-of-Service) DDOS attack. RFC4987 details common mitigation to deal with SYN-flood attack.

However in this post, I’m going to share you the method that I use to reduce the risk of SYN-flood attack from my department computers, with iptables
[bash]
/sbin/iptables -N syn-flood
/sbin/iptables -A syn-flood -m limit –limit 100/second –limit-burst 100 -j RETURN
/sbin/iptables -A syn-flood -j LOG –log-prefix "SYN-flood attempt: "
/sbin/iptables -A syn-flood -j DROP
[/bash]

RFC4987 suggests the use of SYN-cookie for added protection. You can enable SYN-cookie protection in Linux by running this command (as root):
[bash]
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
[/bash]

hope that helps…

Note: I’m not a full-time sysadmin as I’ve a different dayjob, but I was put incharged in securing part of my school’s computer network, so there.

Rant: About Starting up an E-commerce Site….

A bit of advice when starting up an e-commerce (especially storefront) site, please use proper e-commerce software for the job. Do not ‘force’ a general-purpose (CMS) to be an e-commerce site via plugins (or *cough* *cough* ‘component’), it’s gonna be a pain-in-the-ass to secure ’em.

So do yourself (and the sysadmin guys) a favor, use a proper e-commerce software platform or just turn to blogger.com for selling your stuffs…

Public Domain vs Open Source License, which to choose ?

*Note that I’m not a legal expert or an attorney, this is just based on my personal experience and internet search*

There are people who asked me about why bother to release a piece of software or code under Open Source License instead of putting it in Public Domain.

First of all it is a matter of personal choice if write the code or the said work on your own, . But if you release your work under open license (open source or creative commons), you can still retains the copyright (ownership) of the materials that you’ve released. Technically, people who used your work has to adhere to the copyright license terms of your choosing, including freeing you from liabilities if the software is broken or causes harm. Licensing your work will acknowledge you as the owner and those who used your application, and you retain legal rights for your work.

On the other hand — once you have put your work on Public Domain, you will lose your rights on the work, as the work would have no copyright-owner and isn’t protected by copyright law. So people are free to use the materials without any restrictions at all, including to incorporate the material into their work and make it proprietary and subsequently copyrighted it without legal repercussion. You will lose the legal right on your work.

Public domain isn’t a license, it is merely a statement that the software was given to the public and to make things more complicated, some countries disallow public domain material, meaning that the writer will not be protected by the copyright law if the software causes harm to others (the ABSOLUTELY NO WARRANTY and LIMITED WARRANTY, or AS IS clause).

Remember: Public Domain is not recognized internationally and is not stipulated under Berne Convention and in some countries, the author can’t disclaim moral rights.

Therefore, it is more wise to release the the software under a permissive license (copyright), rather than releasing it under public domain right away.

References
1. Creative Commons vs Public Domain
2. Is Public Domain software Open-Source ?
3. Why the Public Domain isn’t a License?
4. Why public domain release is a bad idea