Tuesday, December 11, 2012

A code hosting comparison for open source projects

http://opensource.com/life/12/11/code-hosting-comparison


If you're starting a new open source project, or open sourcing some existing code, you'll need a publicly accessible location for the version control system holding your code (if you're not planning on setting up a publicly accessible VCS, reconsider; no public source control is a red flag to potential contributors). You could set up your own repository hosting, but with so many companies and groups offering existing setups and services, why not use one of those and save yourself some time? Here's an overview of some of the more popular options.

SourceForge

The granddaddy of code hosting sites, SourceForge has been around since 1999. It offers support for every popular revision control system, from CVS on up to Git. Most modern code hosting services are tightly integrated experiences, presenting a single UI with source code browsing, issue tracking, wikis, etc. While SourceForge is moving in this direction, they still keep some of their old kitchen sink philosophy, allowing projects to run phpBB forums, Wordpress blogs, or anything else they might want.

GitHub

While still young compared to SourceForge, GitHub has become the de facto host for open source projects, with over 4.2 million repositories at the time of writing. GitHub's strength is their tagline, 'Social Coding'. On GitHub, it's trivial to make a copy of another developer's project, make changes to that project, and then submit those changes using GitHub's pull request system.
Given the number of developers already on GitHub, and how easy it makes submitting contributions, if you're starting a new open source project and hoping for community contributions, use GitHub. Unless you don't like Git.

Google Code

Google Code Project Hosting is one of the most minimal code hosting options available, which may be appealing to anyone who already has their own infrastructure setup. In addition to offering Subversion, Mercurial, or Git repository hosting, Google Code provides wikis and simple issue tracking. The interface design is sparse, and does not provide the social hooks seen throughout GitHub.

Gitorious

Gitorious is noteworthy for being one of the few open source code hosting repositories that's actually open source itself. You're free to download and run the software yourself, or take advantage of their public hosting. They offer Git hosting, wikis, and a merge request system for community contributions (though the interface seems clunkier than the high mark set by GitHub).

Bitbucket

Just as Git was squaring off against Mercurial for distributed version control dominance, GitHub was facing Bitbucket. Bitbucket began as a Mercurial only hosting service, but a year after its acquisition by Atlassian, it began offering Git support as well.
Bitbucket is very similar to Github. It offers pull requests, a highly visible fork button on each repository, issues, and wikis. One thing Bitbucket does offer that Github does not is unlimited private repositories. If you want to store your family's secret chocolate chip cookie recipe, Bitbucket will let you do it for free (you'll only need to pay after sharing the recipe with five other family members).
There are many more sites that provide free hosting. I've focused on a few of my favorites (this comparison is also avaliable on Github). If you're looking for something special (perhaps GNU Arch support?), or if you're just curious to see all the options, Wikipedia has a great comparison table.

HowTo: Linux Limit A Specific User’s Shell Account Network Bandwidth Using Bash Shell

http://www.cyberciti.biz/faq/linux-limiting-specific-user-shells-internet-bandwidth-usage

I am using a bash shell under Ubuntu Linux operating system. Sometime I need to restrict my own Internet bandwidth for all my shell applications such as ftp, sftp, wget, curl and friends. How do I limit the network speed under bash without setting up a complicated firewall and tc rules as described here?

You need to use a portable lightweight userspace bandwidth shaper called trickle. It can run in in collaborative mode or in stand alone mode. trickle works by taking advantage of the unix loader preloading.
Tutorial details
DifficultyIntermediate (rss)
Root privilegesYes (for installation)
Requirementstrickle
Essentially it provides, to the application, a new version of the functionality that is required to send and receive data through sockets. It then limits traffic based on delaying the sending and receiving of data over a socket. trickle runs entirely in userspace and does not require root access.

Installation

Type the following apt-get command under Debian / Ubuntu Linux to install trickle software:
$ sudo apt-get install trickle
Sample outputs:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  trickle
0 upgraded, 1 newly installed, 0 to remove and 20 not upgraded.
Need to get 43.0 kB of archives.
After this operation, 180 kB of additional disk space will be used.
Get:1 http://debian.osuosl.org/debian/ squeeze/main trickle amd64 1.07-9 [43.0 kB]
Fetched 43.0 kB in 1s (30.6 kB/s)
Selecting previously deselected package trickle.
(Reading database ... 280975 files and directories currently installed.)
Unpacking trickle (from .../trickle_1.07-9_amd64.deb) ...
Processing triggers for man-db ...
Setting up trickle (1.07-9) ...

Install trickle under CentOS / RHEL / Fedora Linux

First, turn on EPEL repo and type the following yum command to install trickle software:
# yum install trickle
Sample outputs:
Loaded plugins: auto-update-debuginfo, protectbase, rhnplugin
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package trickle.x86_64 0:1.07-9.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================
 Package      Arch        Version            Repository
                                                        Size
=============================================================
Installing:
 trickle      x86_64      1.07-9.el6         epel       41 k
Transaction Summary
=============================================================
Install       1 Package(s)
Total download size: 41 k
Installed size: 89 k
Is this ok [y/N]: y
Downloading Packages:
trickle-1.07-9.el6.x86_64.rpm         |  41 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : trickle-1.07-9.el6.x86_64                 1/1
  Verifying  : trickle-1.07-9.el6.x86_64                 1/1
Installed:
  trickle.x86_64 0:1.07-9.el6
Complete!

How do I use trickle?

The syntax is:
 
trickle -u uploadLimit program
trickle -d downloadLimit program
trickle -u {UPLOAD_LIMIT} -d {DOWNLOAD_LIMIT} program-binary
 

Examples

Start ftp client limiting its upload capacity to 100 KB/s:
trickle -u 100 ftp
Start ftp client limiting its download capacity at 50 KB/s:
trickle -d 50 ftp
You can combine both options:
trickle -u 100 -d 50 ftp
You can pass other args to the ftp command:
trickle -u 100 -d 50 ftp ftp.cyberciti.biz
trickle -u 100 -d 50 ftp ftp.cyberciti.biz 8021

Use the wget command to download an iso file from openbsd.org ftp server:
$ wget http://ftp.openbsd.org/pub/OpenBSD/5.2/i386/install52.iso
Sample outputs:
--2012-12-04 16:00:16--  http://ftp.openbsd.org/pub/OpenBSD/5.2/i386/install52.iso
Resolving ftp.openbsd.org... 129.128.5.191
Connecting to ftp.openbsd.org|129.128.5.191|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 237457408 (226M), 230422880 (220M) remaining [text/plain]
Saving to: `install52.iso'
 7% [>                   ] 1,86,94,640 2.94M/s  eta 79s 
Now, use trickle to download iso file but limit capacity at 50 KB/s:
trickle -d 50 wget http://ftp.openbsd.org/pub/OpenBSD/5.2/i386/install52.iso
Sample outputs:
trickle: Could not reach trickled, working independently: No such file or directory
--2012-12-04 16:00:32--  http://ftp.openbsd.org/pub/OpenBSD/5.2/i386/install52.iso
Resolving ftp.openbsd.org... 129.128.5.191
Connecting to ftp.openbsd.org|129.128.5.191|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 237457408 (226M) [text/plain]
Saving to: `install52.iso.2'
 0% [                    ] 2,45,760    49.9K/s  eta 77m 22s

Limit bandwidth in a single shell for all commands

Launch bash or ksh shell limiting its upload capacity to 250 KB/s, and download capacity at 500 KB/s:
trickle -d 500 -u 250 bash
OR
trickle -d 500 -u 250 ksh
Now, for all programs launched inside currently running bash or ksh shell will follow bandwidth shaper rules:
wget http://example.com/foo.iso
sftp file.mp4 user@server1.cyberciti.biz:~/Downloads/

Other options

From the man page:
 -h           Help (this)
 -v           Increase verbosity level
 -V           Print trickle version
 -s           Run trickle in standalone mode independent of trickled
 -d     Set maximum cumulative download rate to  KB/s
 -u     Set maximum cumulative upload rate to  KB/s
 -w   Set window length to  KB
 -t  Set default smoothing time to  s
 -l   Set default smoothing length to  KB
 -n     Use trickled socket name 
 -L       Set latency to  milliseconds

Linux shell: understanding Umask with examples

http://linuxaria.com/article/linux-shell-understanding-umask-with-examples?lang=en


In a GNU/Linux system every file or folder has some access permissions. There are three types of permissions (what allowed to do with a file of any kind, directory included):
(r)read access
(w)write access
(e)execute access
There are also other “special” permissions, but for this article the basic permissions will be enough to illustrate how umask works, and the permissions are defined for three types of users:
(U) the owner of the file
(G) the group that the owner belongs to
(O) All the other users
umask (user mask) is a command and a function in POSIX environments that sets the file mode creation mask of the current process which limits the permission modes for files and directories created by the process. A process may change the file mode creation mask with umask and the new value is inherited by child processes.
In practice with umask you can define the permissions of the new files that your process will create.



The user mask contains the octal values of the permissions you want to set for all the new files and to calculate the value of the umask subtract the value of the permissions you want to get from 666 (for a file) or 777 (for a directory).
The remainder is the value to use with the umask command.
For example, suppose you want to change the default mode for files to 664 (rw-rw-r–). The difference between 666 and 664 is 002, which is the value you would use as an argument to the umask command.
Or just use this handy table
umask Octal Value File Permissions Directory Permissions
0 rw- rwx
1 rw- rw-
2 r-- r-x
3 r-- r--
4 -w- -wx
5 -w- -w-
6 --x --x
7 --- (none) --- (none)
In this article I’ll show you in practice how to use umask to change the permissions of the new files:, so open a terminal and follow me in this small list of commands and examples

1) Check your permissions

Let’s create a file in /tmp
cd /tmp
touch firstfile
ls -l firstfile
You’ll have an output like this one:
-rw-r--r-- 1 root root 0 Dec  3 23:34 firstfile
That’s a default, as you can see, looking from the left, the user that has created the file (root for me) can read and write the file, the group (root) can only read it and all the others can read the file, that’s the standard umask with a value of 0022, to check the umask that you are using in a terminal you can issue the command umask without any argument.
root@myserv:/tmp# umask
0022

2) Change the default umask

So now we know that the umask is 0022 that produces files with the -rw-r–r– permissions, but in many cases you want to give to your colleagues the write permission to directory and files that you create, so to calculate the new umask we translate the permissions -rw-rw-r– in their octal representation, that is: 664 and subtract this number from 666, the result is the umask you want to set in your shell:
umask 0002
cd /tmp
touch secondfile
ls -l secondfile
And this time you’ll get this output:
-rw-rw-r-- 1 root root 0 Dec  4 23:16 secondfile

3) Setup umask for process and daemons

Sometimes you have processes and daemons that create files, and you want to manage the permissions of these files, a typical example that comes to my mind is an apache httpd server that creates files with uploads or with some scripts and once they are created you want to modify these files with your username that shares the same group of apache, how to do it ?
In general you have to put the command umask in the script that is used to start the daemon or in files included in the start, so for apache this could be /etc/init.d/apache2 (debian) or much better in the environment file that is included, /etc/apache2/envvars (debian)
So you could set your umask in /etc/apache2/envvars :
...
# umask 002 to create files with 0664 and folders with 0775
umask 002
Restart your Apache :
/etc/init.d/apache2 restart
And now if you check the difference in your document root, you should see something like this :
ls -l *.txt
-rw-rw-r-- 1 www-data www-data  14 2012-12-01 18:58 test2.txt
-rw-r--r-- 1 www-data www-data  14 2012-12-01 18:55 test.txt


4) Setup Default umask for the whole system

So now you know how to change the umask in a working terminal, or session, but how to change it permanently ?
To change the umask for just an user the easiest way is to set the command umask NEWUMASK in the ~/.bashrc file of that user (assuming that he’s using bash) or in the equivalent file that is loaded at the start of his session by his shell.
To change the umask for all your users you have to change some system setting and these depends on your Linux Distribution:
Debian 6, Ubuntu and Mint

In Debian this can be handled with the help of a PAM modules, pam_umask is a PAM module to set the file mode creation mask of the current environment. The umask affects the default permissions assigned to newly created files, to enable/change these permissions edit the files:
/etc/pam.d/common-session
/etc/pam.d/common-session-noninteractive
And in each of these files add the line:
session    optional     pam_umask.so umask=0002
In this way all sessions will use the 0002 umask giving to the group the permission to write to files and directories.
Red Hat 6 and Centos 6

In these distributions the generic umask is wrote in the file /etc/bashrc, if you open it (as root) and you search for the word “umask” you’ll find something similar to these lines:
# By default, we want umask to get set. This sets it for non-login shell.
    # Current threshold for system reserved uid/gids is 200
    # You could check uidgid reservation validity in
    # /usr/share/doc/setup-*/uidgid file
    if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
       umask 002
    else
       umask 022
    fi
These lines set an umask of 002 for all the username whose uid is greater than 199 and the group name is the same of the user name.
So to change the umask for everyone you could simply change all these lines in this line:
umask 002
Or any value that you need.