Setting Up an Ubuntu Subversion Server

This tutorial describes setting up a Subversion server on an Ubuntu system and configuring it for use by a group of developers. The goal is to allow each member of a development team to access the Subversion repositories from a remote location (e.g., a workstation at home), using either the svn or svn+ssh protocol.

Prerequisites

It is assumed that you already have a basic Ubuntu server running, and that the other developers can connect to it. If you want to allow them to access the Subversion server with the secure svn+ssh protocol, then each developer must also be able to login to your machine with SSH.

Basic Subversion Setup

Begin by installing the Subversion package:

$ sudo apt-get install subversion

You’re going to need a directory for your repositories, as well as other Subversion-related files. Most people use /home/svn or /usr/local/svn for this purpose, and you can choose either. I personally prefer /usr/local/svn over /home/svn, as I like to keep /home for home directories of real users of the system.

$ sudo mkdir /usr/local/svn

Inside this directory, create another one to hold your repositories:

$ sudo mkdir /usr/local/svn/repos

Now, you need to set some access permissions on those directories. You only want to allow certain users of your system (that is, yourself and the other developers) to access the repositories, so add a new group for those users. Name the group svn.

$ sudo groupadd svn

Then, change the group ownership of /usr/local/svn/repos to the new group using the chgrp command:

$ sudo chgrp svn /usr/local/svn/repos

The members of the svn group also need write access to the repos directory, so use chmod to add the write permission for the group:

$ sudo chmod g+w /usr/local/svn/repos

Additionally, you need to make sure that all new files and directories created in the repos directory (in other words, anything committed to the repositories) will also be owned by the group. To accomplish this, use chmod again to set the set-group-ID bit on the directory, which causes any file created inside it to have the same group ownership as the directory itself. Effectively, everything in repos will belong to the svn group.

$ sudo chmod g+s /usr/local/svn/repos

OK, so you now have the repositories directory with proper permissions, ready to be used by the svn group. Go ahead and add yourself to the group:

$ sudo usermod -a -G svn michal

However, your new group membership will not be effective for the current session, so you need to log out and log back in. When you’re back, you can verify that your account is recognized as a member of the svn group:

$ groups michal adm dialout cdrom plugdev lpadmin admin sambashare svn

If the other developers have user accounts on your server, add them to the group too:

$ sudo usermod -a -G svn jimmy $ sudo usermod -a -G svn craig

If they don’t, they will still be able to access the repositories, but only using the basic svn protocol, not the secure svn+ssh method.

Creating a Test Repository

You can now create a repository. In the following steps, I’ll demonstrate how to create a simple test repository containing one text file, and how to check out and commit files. If you’re not familiar with Subversion, then this could be a good exercise to learn the basics. Otherwise, you can skip all the test checkouts and commits and just create the repository for your project.

The repository will be a subdirectory in the repos directory, and will have its group ownership set to svn (thanks to the chmod g+s you did earlier). However, that’s not all – you also need to make sure the repository will be group writable, so that the other members of the svn group will be able to commit files. To do this, set the umask to 002:

$ umask 002

This command sets the new file mode creation mask which controls the default permissions of any new file that you create. The default value is 022and it corresponds to read/write permissions for the file owner, and read permissions for the group and others. The new value, 002, also gives write permissions to the group, which is just what you need.

Create the repository using the svnadmin command:

$ svnadmin create /usr/local/svn/repos/test

And set back the default umask:

$ umask 022

So you now have an empty repository, waiting for you to commit something to it. But, before you do this, you need to check out the current version (i.e., the empty directory) to create a working copy.

$ svn checkout file:///usr/local/svn/repos/test Checked out revision 0.

The working copy has been checked out to a new directory named test. Go ahead and create a simple “hello world” text file in that directory:

$ cd test $ echo ‘Hello, World!’ > hello.txt

Then, add it to version control with the svn add command:

$ svn add hello.txt A         hello.txt

Finally, commit it using svn commit:

$ svn commit -m “Added a ‘hello world’ text file.” Adding         hello.txt Transmitting file data . Committed revision 1.

The hello.txt file is now in the repository.

Accessing the Repository with the Svn Protocol

Remote repository access with the svn protocol requires you to use svnserve, a Subversion server program. Each repository has a svnserveconfiguration file (stored in the conf subdirectory) which controls how the repository can be accessed with svnserve.

First, create a passwords file that lists the users of the repository and their passwords. This will be a common passwords file for your development team and you will be able to use it with multiple repositories.

$ sudo gedit /usr/local/svn/passwd-team

Here’s a sample passwords file. Each line (except the first one, which is the configuration section name) defines a user name and the corresponding password.

[users] michal = somepassword jimmy = anotherpassword craig = yetanotherpassword

Since the passwords are stored unencrypted, it’s important that you protect the passwords file by setting the proper permissions. The file should not be readable by anyone except the owner (which is root), so change its mode to 600:

$ sudo chmod 600 /usr/local/svn/passwd-team

Then, open the svnserve configuration file in the test repository:

$ gedit /usr/local/svn/repos/test/conf/svnserve.conf

There’s probably some default configuration in the file, but you can just remove everything and enter this:

[general] anon-access = none password-db = /usr/local/svn/passwd-team realm = Team

The anon-access = none line denies access to the repository to unauthenticated users (by default, they are allowed read access, so they can do checkouts). The password-db setting tells svnserve where to look for the passwords file when authenticating users, and the realm setting defines the name of the authentication realm.

OK, the configuration is ready, so you can now launch svnserve.

$ sudo svnserve -d –foreground -r /usr/local/svn/repos

The command-line options tell svnserve to run in daemon mode (-d) as a foreground process (--foreground), and to look for repositories in therepos dir that was created earlier (-r /usr/local/svn/repos). Normally the program should be running in the background (that’s what daemon processes do), but at this moment you only need to test it, so it’s more convenient to run it in the foreground, where you can easily kill it with Ctrl+C.

Now, try accessing the repository using the svn protocol. You can try it on another machine over the network, or on the same computer (in another terminal). In the latter case, make sure you’re not doing the checkout in the same directory where the previous test working copy was checked out, because it won’t work – either delete the test directory, or cd to some other location.

Enter the following svn checkout command, replacing 192.168.10.11 with the IP address of your Subversion server (if you’re testing on the same machine, you can use 127.0.0.1):

$ svn checkout svn://192.168.10.11/test –username jimmy

The server will ask you for password:

Authentication realm: <svn://192.168.10.11:3690> Team Password for ‘jimmy’:

Then, it proceeds with the checkout.

A    test/hello.txt Checked out revision 1.

And there’s your working copy. Now, check if it works the other way – try modifying the file and committing it back to the repository. Openhello.txt with a text editor and add some text:

$ cd test $ gedit hello.txt

When you’re done, commit it:

$ svn commit -m “Modified the hello.txt file.” Sending        hello.txt Transmitting file data . Committed revision 2.

Sweet, it works both ways.

Accessing the Repository with the Svn+SSH Protocol

Setting up your Subversion server for svn+ssh access is simple, as it doesn’t even require using the svnserve program. Assuming you have a SSH server running on the Subversion machine, and the other developers can login to it, you don’t have to configure anything – just set up the repository.

You can just go ahead and check out the test project. The checkout operation is slightly different with the svn+ssh access method. First, you must specify the full path to the repository in the checkout URL:

$ svn checkout svn+ssh://192.168.10.11/usr/local/svn/repos/test –username jimmy

Then, when the server asks you for a password, you need to enter the user’s SSH password, not the one from the passwd-team file.

jimmy@192.168.10.11’s password:

And there it goes:

A test/hello.txt Checked out revision 2.

From here, you can use your working copy the same way as with the svn protocol.

Svnserve Initialization Script

If you plan on using svnserve in the long run, you probably don’t want to start it from the command-line every time the server is rebooted. The proper way to start system services is with init scripts located in the /etc/init.d directory.

The Subversion package for Ubuntu does not include an init script, so you have to make one yourself. Or, you can download this init script, written by yours truly. Save the script as /etc/init.d/svnserve and make it executable:

$ sudo chmod +x /etc/init.d/svnserve

If you chose anything other than /usr/local/svn/repos for the repositories directory, make sure to change the path in the init script.

Run update-rc.d to install the script:

$ sudo update-rc.d svnserve defaults Adding system startup for /etc/init.d/svnserve … /etc/rc0.d/K20svnserve -> ../init.d/svnserve /etc/rc1.d/K20svnserve -> ../init.d/svnserve /etc/rc6.d/K20svnserve -> ../init.d/svnserve /etc/rc2.d/S20svnserve -> ../init.d/svnserve /etc/rc3.d/S20svnserve -> ../init.d/svnserve /etc/rc4.d/S20svnserve -> ../init.d/svnserve /etc/rc5.d/S20svnserve -> ../init.d/svnserve

And that’s it – svnserve will be started automatically when your system boots up. To start it manually, run this command:

$ sudo /etc/init.d/svnserve start

References

Store SQLite database on HTML5

Posted: May 19, 2012 in HTML

Store SQLite database on HTML5

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>SQL Storage</title>
<body>
<br/><br/>
<div align=”center”>
<input type=”hidden” id=”id”/>
First name:<input type=”text” id=”firstName”/><br/>
Last name:<input type=”text” id=”lastName”/><br/>
Phone: <input type=”text” id=”phone”/><br/>
<button onClick=”resetForm()”>Reset Form</button>
<button onClick=”updateRecord()”>Update</button>
<button onClick=”insertRecord()”>Insert</button>
<button onClick=”dropTable()”>Drop Table</button>
<div id=”results”></div>
</div>
</body>
Read the rest of this entry »

To sending params such as index.html?param1=xx&param2=yy, we can use window.location.search.

Example:

var params = window.location.search.slice(1).split(“&”);
for(var p=0; p<params.length; p++) {
var pair = params[p].split("=");
var name = pair[0] ;
var value = pair[1];
// What you want to do with name and value…
if( name == 'param1' ){
//
}else if(name == 'param2'){
//
}
}

Install the Streaming Media Services role. To do this, follow these steps: Visit the following Microsoft Web site: http://www.microsoft.com/downloads/details.aspx?FamilyID=b2cdb043-d611-41c9-91b7-cddf6e5fdf6b Download the Windows6.1-KB963697-x64.msu file. Run the MSU file for the Streaming Media Services role. To do this, type the following command at a command prompt: start /w wusa /quiet Windows6.1-KB963697-x64.msu To install the Streaming Media Services role, type the following string at a command prompt: start /w ocsetup MediaServer To start the Windows Media Services service, type the following string at a command prompt: net start wmserver

package com.invp;

import com.google.android.maps.MapActivity;

import android.hardware.Sensor;

import android.hardware.SensorEvent;

import android.hardware.SensorEventListener;

import android.hardware.SensorManager;

import android.os.Bundle;

import android.view.animation.Animation;

import android.view.animation.RotateAnimation;

import android.widget.ImageView;

import android.widget.TextView;

public class INVPMapActivity extends MapActivity implements SensorEventListener{
Read the rest of this entry »

ตอนนี้เทรนที่เห็นได้ชัดเลยคือการใช้อินเตอร์เน็ตผ่านมือถือ โดยที่ตัวเลขล่าสุดของผู้ใช้อินเตอร์เน็ตบนมือถือในเมืองไทยตอนนี้อยู่ที่ประมาณ 18 ล้านคน (เพิ่มจากปีที่แล้วที่ 12 ล้านคน) และมีท่าทีว่าจะเพิ่มขึ้นเรื่อยๆ ไม่ว่าจะเป็นเพราะราคาของโทรศัพท์สมาร์ทโฟนที่ต่ำลง ทำให้การเข้าถึงตัวฮาร์ดแวร์ขยายกว้างมากขึ้น หรือจะเป็นราคาค่าบริการอินเตอร์เน็ตบนมือถือที่มีให้เลือกสำหรับหลากหลายความต้องการมากขึ้น
Read the rest of this entry »


Internet usage is sky-rocketing throughout the Asia-Pacific region, obviously making the growth of social media the fastest in the world, as you’ll see, it’s not all about Facebook, but it still leads the way across the region, at least for now. This is a nice collective Infographic from Burson-Marsteller.
Read the rest of this entry »

Comparison of location estimation accuracy in Wi-Fi – indoor positioning system
1. Introduction:

Indoor positioning technology is an important issue to be addressed for providing any kind of location based services. There were lot of approaches for this technology by the user of active sensors like active badge, active bat, etc. (Hightower and Borriello, 2001), and some approaches use the in-building Wi-Fi networks for indoor positioning. The use of Wi-Fi signals as a potential positioning system within buildings has opened doors for many applications. Lot of research is being undertaken in this domain to find a more viable solution of location positioning using the Wi-Fi signals within the building with higher accuracy. This is because of the ubiquitous availability of Wi-Fi signals in almost all the buildings, so no additional hardware is required to install a positioning system in the buildings.

Read the rest of this entry »

This is a post by iOS Tutorial Team member Matthijs Hollemans, an experienced iOS developer and designer.

In iOS, apps can’t do a lot in the background. Apps are only allowed to do limited set of activities so battery life is conserved.

But what if something interesting happens and you wish to let the user know about this, even if they’re not currently using your app?

For example, maybe the user received a new tweet, their favorite team won the game, or their dinner is ready. Since the app isn’t currently running, it cannot check for these events.

Luckily, Apple has provided a solution to this. Instead of your app continuously checking for events or doing work in the background, you can write a server-side component to do this instead.

And when an event of interest occurs, the server-side component can send the app a push notification! There are three things a push notification can do:

  • Display a short text message
  • Play a brief sound
  • Set a number in a badge on the app’s icon

You can combine these however you see fit; for example, play a sound and set the badge but not display a message.

In this 2-part tutorial series, you’ll get to try this out for yourself by making a simple app that uses APNS!

In this first part, you’ll learn how to configure your app to receive push notifications and receive a test message.

This tutorial is for intermediate or advanced iOS developers. If you are still a beginner to iOS, you should check out some of the other tutorials on this site first. Also, it’s highly recommended that you review these two tutorials first (or have equivalent knowledge):

Read the rest of this entry »

To use the database API you have to configure your WebView to accept HTML5 database calls:

WebSettings settings = webView.getSettings();  
settings.setJavaScriptEnabled(true);  
settings.setJavaScriptCanOpenWindowsAutomatically(true); 
... 
settings.setDatabaseEnabled(true);  
settings.setDatabasePath("/data/data/your.package.name/database_name");

You may also override the onExceededDatabaseQuota method of your WebChromeClient if you want to control your storage quota:

public void onExceededDatabaseQuota(String url, String
databaseIdentifier, long currentQuota, long estimatedSize, long
totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
                quotaUpdater.updateQuota(204801);
}