Tuesday, 4 December 2012

Managing your company with Public, Private and Hybrid Cloud

If you have a plan to start an IT company in the future, and thinking about the infrastructure and design of company,  then these tips will going to help you in managing the equipments and systems in the cloud:

Public and Private cloud:
Despite the appeal and promise of cloud computing, your company might want to keep some applications in your house, especially when the business-critical need is high (e.g business intelligence data) or when sensitivity of data is an issue. For this you need to set up a private cloud data centre that supports virtulized load cost effectively and efficiently. The cloud infrastructure is 'right-sized' and must have ability to dynamically scale modular applications and workloads.

Hybrid Cloud:
Another option is the hybrid cloud, a model where you use both private and public clouds. For e.g, your cloud outsource any data centre overload to a public cloud during seasonal spikes in business needs. In this case, you would built your private cloud to your average operation requirements, and then turn to public cloud when you needed it instead of over-sizing your data centre and running it at half load.

Practices for small IT developments within small server rooms and branch offices:

Power: Reliability increases if each UPS is plugged into a separate circuit where each unit is fed from its own circuit breaker.

Cooling: The recommended temp. for IT equipment is between 64.4 F and 80.6 F.

Racks: A rack is a fundamental structure for the IT gear, and increase availability, organization, security, cooling effectiveness, ease of power distribution, and professionalism.

Lightening: IT equipment frequently ends up with poor lightening. A low cost headlamp, hung from a hook in the back of the closed IT cabinet, is a cheap and effective way to ensure proper visibility.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

Thursday, 1 November 2012

How to Install&Configure Alpine with Gmail


1. Enable IMAP access in Gmail by  ‘Forwarding and POP/IMAP’ option in Gmail’s settings

2. Install Alpine
                      sudo apt-get install alpine

3. Launch alpine by typing "alpine" in the command prompt.

4. Access to its setup option by typing "s" in the main menu.

5. Select the ‘CollectionLists’ option by pressing ‘L’ and add new collection list by selecting ‘Add Cltn’.

6. Give new collection name like "Gmail" and set the server as follows:

                      imap.gmail.com/ssl/user=USERNAME@GMAIL.COM

7. Exit the collection list setup and save the changes you have made.

8. In order to finish configuring Alpine, return to the main menu, go back into setup options and select ‘Config’ (press ‘C’). Use the following settings (once again, USERNAME@GMAIL.com is your Gmail user name):

                     SMTP server: smtp.gmail.com/novalidate
cert/user=USERNAME@GMAIL.COM/ssl

            Inbox Path: imap.gmail.com/novalidate-cert/ssl/user=USERNAME@GMAIL.COM (Note: When prompted for an inbox folder, enter ‘INBOX’ (without the inverted commas))

9. Optional: If you don’t want to enter your password every time you open Alpine, simply create a file called ‘.pine-passfile’ in your home directory:
           touch .pine-passfile

Launch alpine by entering "alpine" in the terminal and enjoy the perfect mailing system.

Wednesday, 17 October 2012

Model formsets saving in the in Django models forms.

In case of the the FormSet in the django model forms, the save method is different from that of the forms, as fromset library is different from the form. For formset in the forms the "modelform_factory" is to be called in the views from the django. models. For this write the following line in the header of the views.py file:
                        from django.forms.models import modelsformset_factory

and make a function in the views like,

def chemical_analysis(request):
ChemicalFormSet = modelformset_factory(chem_analysis)
if request.method=='POST':
                formset = ChemicalFormSet(request.POST, request.FILES)
                if formset.is_valid():
cd = formset.cleaned_data
formset.save()
return HttpResponseRedirect(reverse('Automation.report.views.result_chem'))
else:
        return HttpResponse("There was an error with your submission. Please try again.")

else:
formset = ChemicalFormSet()
return render_to_response('report/report_add_row.html', {'formset': formset}, context_instance=RequestContext(request))

In the models.py file write the following in the header of the file;
                                     from django.forms.models import BaseModelFormSet

And made the models in the following way:


class chem_analysis(models.Model):
    s_no = models.CharField(max_length=255,blank=True)
    description = models.CharField(max_length=255,blank=True)
    result = models.CharField(max_length=255,blank=True)
   
    def __str__(self):
        return self.s_no
       
class Basechem_analysisFormSet(BaseModelFormSet):
    class Meta :
        model = chem_analysis

In the input form html file i.e report_add_row.html, call the formset in the following way:


{% extends "base.html" %}
{% load i18n %}

<html>
<head>
    <title>Gndec Ludhiana</title>

</head>
{% block content %}

     


<SCRIPT language="javascript">
        function addRow(tableID) {

            var table = document.getElementById(tableID);

            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);

            var cell1 = row.insertCell(0);
            var element1 = document.createElement("input");
            element1.type = "text";
            cell1.appendChild(element1);

//            var cell2 = row.insertCell(1);
//            cell2.innerHTML = rowCount + 1;

   var cell2 = row.insertCell(1);
            var element2 = document.createElement("input");
            element2.type = "text";
            cell2.appendChild(element2);

            var cell3 = row.insertCell(2);
            var element3 = document.createElement("input");
            element3.type = "text";
            cell3.appendChild(element3);

   var cell4 = row.insertCell(3);
            var element4 = document.createElement("input");
            element4.type = "checkbox";
            cell4.appendChild(element4);

   var cell5 = row.insertCell(4);
            cell5.innerHTML = rowCount + 1;


        }
function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length;

            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[3].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }


            }
            }catch(e) {
                alert(e);
            }
        }

    </SCRIPT>

<br>
    {% if form.errors %}
        <p style="color: red;">
            Please correct the error{{ form.errors|pluralize }} below.
        </p>
    {% endif %}

    <form action="" method="post">
{% csrf_token %}
{{ formset.management_form }}
{% for form in formset %}
        {{ form.id }}
<table width = "528px"> <tr>
<th>S.No.</th>
<th>Description</th>
<th>Result</th>
</tr> </table>      

 <table id="dataTable" width="350px" border="">

<tr>

<td>{{ form.s_no}}</td>
<td>{{ form.description}}</td>
<td>{{ form.result}}</td>
<TD><INPUT type="checkbox" name="chk"/></TD>
<td>1</td>
</tr>
</table>
<ul>
          {% if formset.can_delete %}
                <li>{{ form.DELETE }}</li>
            {% endif %}
        </ul>
    {% endfor %}
<INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />

<INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />

        <input type="submit" value="Submit">

    </form>

</html>
{% endblock %}

       

Monday, 13 August 2012

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type' in case of mysql

In case of mysql database to handle this error add the following line in the DATABASE engine of the setting.py file :
 'ENGINE': 'django.contrib.gis.db.backends.mysql',
which can enable the GIS(Geographic Information System) library in the django project. The error is also discussed at the following link: http://stackoverflow.com/questions/4578352/geodjango-using-mysql 

Monday, 9 July 2012

Upgrade ubuntu 11.10 to 12.04

We can upgrade ubuntu 11.10 to 12.04 by following the simple steps given below.

 1. sudo vi /etc/update-manager/release-upgrades
Then, change the line below from prompt=lts to prompt=normal.  To change it, scroll down to the line press the X key on the keyboard to delete each character. Then hit the I key and begin typing the new line. When you’re done, press Esc key, then type :wq to save and exit.
2. sudo apt-get update && sudo apt-get upgrade
3. sudo do-release-upgrade
When ask if you want to continue with the upgrade, type Y for yes.

Friday, 18 May 2012

PostgreSQL with PHP in Ubuntu on Localhost [STEPS TO RUN phpPgAdmin (postgresql 9.1) ]


Installation

Install PostgreSQL:
sudo apt-get install postgresql
Install GUI Administration application:
sudo apt-get install pgadmin3
Install PHP based Web Administration site (like phpMyAdmin for MySQL database):
sudo apt-get install phppgadmin

Configuration

Configure so that you can access via localhost:
gksudo gedit /etc/postgresql/9.1/main/postgresql.conf 
It witll open the file for editing, Add following line at the end of the file:
listen_addresses = 'localhost'
Save and close the file. Open another file for editing:
gksuso gedit /etc/postgresql/9.1/main/pg_hba.conf
Replace “local all all ident sameuser” with:
local   all         all                               md5

Change Password for root user

In PostGRE, root user is “postgres” which by default, does not have any password. Enter following line in terminal to set a password for it:
sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'your_password';
\q

Create a new User & a new Database

sudo -u postgres createuser -d -R -P new_username
sudo -u postgres createdb -O new_username new_database_name
This will create a new user, with username “new_username” and create a new database“new_database_name” and set “new_username” it’s owner.

Configure phpPgAdmin

I assume you already installed phpPgAdmin by:
sudo apt-get install phppgadmin
Then, configure Apache:
gksudo gedit /etc/apache2/apache2.conf
Add following line at the end of the file:
Include /etc/phppgadmin/apache.conf
sudo /etc/init.d/apache2 restart
sudo /etc/init.d/postgresql-9.1 restart

Access phpPgAdmin

type http://localhost/phppgadmin in your browser & log in by the username you just created (new_username)

HOW TO INSTALL POSTGRESQL9.1 ON UBUNTU

First install python-software-properties:

$sudo apt-get install python-software-properties

Add PPA repository and update apt:

$sudo add-apt-repository ppa:pitti/postgresql

Now install postgresql:

$sudo apt-get install postgresql-9.1 libpq-dev

Check the installation:

$locate postgresql 

$psql -V             # check psql version
psql (PostgreSQL) 9.1
 
$finger postgres     # check if user postgres is created 

Login: postgres          Name: PostgreSQL administrator
Directory: /var/lib/postgresql       Shell: /bin/bash
Never logged in.
No mail.
No Plan.


$ su postgres          # switch user to postgres
$ psql                 # launch psql as postgres and check the server version
psql (9.1)
 
postgres=# select version();
 

Setup Root User 'posrgres':

The installer has created a unix user postgres without a password. So first I give a (unix) password to this special user. The user postgress is a root user (database administrator) of PostgreSQL Server but without a (PostgreSQL) password. So I give it one here as well.
 
$ sudo passwd postgres # give the postgres user a (unix) password
$ su postgres           # switch to the user postgres
$ psql                   # launch psql to give postgres PostgreSQL passord
postgres=# alter user postgres with password 'secret';  # new password for postgres 
ALTER ROLE
postgres=# \q            # quit psql
$ exit                   # exit from user 'postgres'
exit
 

Configure PostgreSQL Server:

$ su postgres    # switch to the user postgres
$ cd /etc/postgresql/9.1/main
$ ls -la 
 
postgres@ubuntu-pc:/etc/postgresql/9.1/main$ cp pg_hba.conf pg_hba.conf.bak.original 
postgres@ubuntu-pc:/etc/postgresql/9.1/main$ cp postgresql.conf postgresql.conf.bak.original 

postgres@ubuntu-pc:/etc/postgresql/9.1/main$ ls -la
 

Make changes to pg_hba.config (authetification methods).


host    all         all       127.0.0.1/32       trust          # md5 -> trust

Make changes to postgresql.conf for error log.

#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------
log_destination = 'stderr'  # 2011.07.04 - enabled
logging_collector = on   # 2011.07.04 - enabled and turned on
log_directory = 'pg_log'  # 2011.07.04 - enabled. I will create this folder (see below).
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # 2011.07.04 - enabled
log_truncate_on_rotation = off  # 2011.07.04 - enabled and keep it off
log_rotation_age = 1d   # 2011.07.04 - enabled
log_rotation_size = 10MB  # 2011.07.04 - enabled


Create a log directory as specified in the config above:

$ su postgres         # switch to postgres user
$ cd ~/9.1/main/      # /var/postgresql/9.0/main
$ mkdir pg_log        # create a new log directory as specified in the config file above
$ ls -F               # confirm the new directory 'pg_log'
PG_VERSION  pg_log/ ...
$ exit

 

Restart the server:

$ sudo /etc/init.d/postgresql restart
 * Restarting PostgreSQL 9.1 database server  
$ sudo /etc/init.d/postgresql status
Running clusters: 9.1/main 
 

Check the new log:

$ sudo ls /var/lib/postgresql/9.1/main/pg_log
postgresql-2011-07-23_135126.log  
 

 Finally Install pgAdmin III (GUI tool for PostgreSQL) :

$ sudo apt-get install pgadmin3   # install the latest pgAdminIII
$ pgadmin3                        # launch it