Git important commands

This sheet can be helpful for git users. It is precise and clear and contain some important commands for using git properly:


Making your android layout scrollable (easy)

You can turn any of your layouts scrollable fairly easily in android (once you understand the steps). You’ll need to insert the ScrollView (or HorizontalScrollView) tag at the correct place within the current layout. One important constraint is that ScrollView tag can have only one child. The child is generally a layout e.g, a RelativeLayout or LinearLayout.
We generally also want some items to remain outside the ScrollView such that they always remain on the screen even when swiping down; e.g, your actionbar or some buttons. If you want to do so as well, then you should avoid making ScrollView the root.

Here is an example of an activity where we want a button with id: btnBackAbout to always remain on the screen while other parts of the layout (a textView with id: textView4) will become scrollable.

Layout before making it Scrollable:

Layout after making it Scrollable:
(Note: a new RelativeLayout was added inside the ScrollView such that the ScrollView will have only one child.)

Scrollable layout hierarchy:

Sharing Printer in Ubuntu

Sharing printer in a LAN (to Windows machine or virtualbox) from a Ubuntu host machine.
1. Setup Samba:
sudo apt-get install system-config-samba.
Launch “Samba” from the launcher
Open “Preferences” > “Server Settings” and enter the work group name used in Windows.

2. Share printer:
Go to http://localhost:631/admin/ and check the box “Share printers connected to this system”.
Go to http://localhost:631/printers/ and check that the expected printer is listed.
Click the printer and check that it is listed as “Idle, Accepting Jobs, Shared, Server Default”.

3. Connect the printer:
On the Windows computer or (e.g VirtualBox), open Windows Explorer and go to the “Network” item. There’s an icon for the Ubuntu computer; open it. There’s an icon for the printer shared from Ubuntu. Right-click that one and select “Connect…”.

On the Windows computer, select “Add new printer” then “Connect to a printer on the Internet or network” and specify the full path of “http://{computername}:631/printers/{printername}”

Java RMI Simple Bank System run on ubuntu

This is a simple Java RMI application where the server manages the bank accounts which are stored in a database and responds to the client requests. The system permits multiple clients to be able to access the server from remote PCs. The client, after he has log in, is able to check his account details, withdraw and and deposit money into his account. It may also help to compile/run Java RMI system on ubuntu

github link:


To run Java RMI server/client on ubuntu, run the following commands on terminal:

cd ‘/directory’

//compile .java files






rmic BankAccount

rmiregistry 2008

//run the server with mysql dependency

java -cp “/mysqldirectory/mysql-connector-java-5.1.23:.”BankServer

//run the client

java BankClient

UDP Chat Group using Java RMI

A simple chat system that allows users to join a group & chat. It uses Java RMI & UDP protocol.


A simple TCP Socket calculator

A simple TCP Socket calculator


//Server Class

public class SimpleServer {
public static void main(String args[]) throws IOException {
// Register service on port 1254
ServerSocket s = new ServerSocket(1251);
Socket s1=s.accept(); // Wait and accept a connection
// Get a communication stream associated with the socket

InputStream s1In = s1.getInputStream();
DataInputStream dis = new DataInputStream(s1In);
int num1 = (dis.readInt());
int num2 = (dis.readInt());
String operation = (dis.readUTF());
int ans = 0;
if (operation.equals(“add”) == true){
ans = num1 + num2;
else if (operation.equals(“sub”)){
ans = num1 – num2;
// Close the connection, but not the server socket


//Client Class

public class SimpleClient {
public static void main(String args[]) throws IOException {
// Open your connection to a server, at port 1254
Socket s1 = new Socket(“localhost”,1251);
// Get an input file handle from the socket and read the input
Scanner scanln = new Scanner(;

//System.out.println(“Enter number1: “);
//int num1 = scanln.nextInt();

//System.out.println(“Enter number2: “);
//int num2 = scanln.nextInt();

System.out.println(“Search Movie: “);
String searchmovie =;

OutputStream s1out = s1.getOutputStream();
DataOutputStream dos = new DataOutputStream (s1out);
//dos.writeInt(num1); //send to server6
//dos.writeInt(num2); //send to server6
//dos.writeInt(operation); //send to server6

//GUI.HomeMenu.homeMenu=new GUI.HomeMenu();
InputStream s1In = s1.getInputStream();
DataInputStream dis = new DataInputStream(s1In);
String st = new String (dis.readUTF());

System.out.println(“” + st);
// When done, just close the connection and exit

postgresql “New Server Registration” connection problem on ubuntu?

“connection error” or “authentication problem” when trying to register a new server in pgAdmin III?

(ubuntu or xubuntu)

This post shows how to obtain & setup the “Host”, “Port”, “Username”, and “Password” of postgresql.

1) Obtain default port.  To do that, open up /etc/postgresql/x.xversion/main/postgresql.conf

See “port= 5432″. You may change the port used by postgresql.


2) Obtain Host.

Search the listen_addresses. For instance, here 'localhost' is my defaut host. You may alter the host here.

3) Change password.

Open terminal.


~$: psql -d postgres -U postgres

psql (9.1.3) Type "help" for help.
postgres=# alter user postgres with password 'mynewpassword'; ALTER ROLE
postgres=# q
~$:sudo /etc/init.d/postgresql restart
Now you can run pgAdminIII. On form New Server Registration, set ‘Username’ to “postgres”, type in password you entered before, and the field ‘Name’ is up to your choice.

Get every new post delivered to your Inbox.