Posts

Showing posts from 2015

MySQL Installation in Ubuntu

Image
To install MySQL, run the following command from a terminal prompt: sudo apt-get install mysql-server During the installation process you will be prompted to enter a password for the MySQL root user. Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:  sudo netstat -tap | grep mysql If the server is not running correctly, you can type the following command to start it: sudo service mysql restart Configuration If you would like to change the MySQL root password, in a terminal enter:  sudo dpkg-reconfigure mysql-server-5.5 The MySQL daemon will be stopped, and you will be prompted to enter a ne

How to hide Checkbox Label Extjs

hideLabel: true, Example:         {             xtype: 'checkbox',             id: '.............',             fieldLabel: '.....................',             name: '............',             hidden: true,             hideLabel: true,             listeners: {                             }         },

How to load python simple server

Image
Go to docs folder $ python -m SimpleHTTPServer 8003 Run in browser http://127.0.0.1:8003

How to create login page in Django

Image
1 ) Create login.html file inside templates file. {% block content %} {% if form.errors %} <p>! Sorry your username and password didn't match. Please try again.</p> {% endif %} <form method="post" action="{% url 'django.contrib.auth.views.login' %}"> {% csrf_token %} <div> LogIn !! <table> <tr>     <td>{{ form.username.label_tag }}</td>     <td>{{ form.username }}</td> </tr> <tr>     <td>{{ form.password.label_tag }}</td>     <td>{{ form.password }}</td> </tr> </table> <input type="submit" value="login" /> <input type="hidden" name="next" value="{{ next }}" /> </form> </div> {% endblock %} 2 ) Edit urls.py with. url(r'^users/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),

Ignoring unwanted files from github commit

Ignoring files From time to time, there are files you don't want Git to check in to GitHub. There are a few ways to tell Git which files to ignore. Create a local .gitignore If you create a file in your repository named .gitignore, Git uses it to determine which files and directories to ignore, before you make a commit.     1 ) In Terminal, navigate to the location of your Git repository.     2 ) Enter touch .gitignore to create a .gitignore file. If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, youuntrack the file first, by running the following command in your terminal: $ git rm --cached OR $ git rm --cached `git ls-files -i -X .gitignore`

About Dictionary

..... Adding new key-value pair to dictionary $ menu = {} # Empty dictionary $ menu['Chicken Alfredo'] = 14.50 $ print menu['Chicken Alfredo'] $ print "There are " + str(len(menu)) + " items on the menu."     There are 1 items on the menu. .....Removed from a dictionary $ del dict_name[key_name]   

How to add java script file in django

1 ) Create index.html inside the  <p>my first HTML page </p> {% load staticfiles %} <script src={% static "js/hello.js" %} type="text/javascript"></script> 2 ) Edit views.py with from django.shortcuts import render # Create your views here. def home(request):     return render(request,'home.html') 3 ) Edit urls.py with from django.conf.urls import patterns, include, url from django.contrib import admin urlpatterns = patterns('',     # Examples:     # url(r'^$', 'perfumes.views.home', name='home'),     # url(r'^blog/', include('blog.urls')),     url(r'^admin/', include(admin.site.urls)),     url(r'^home/$','perfum.views.home', name='home'), ) 4 ) Edit settings.py with STATIC_URL = '/static/' 5 ) Create hello.js inside static/js/hello.js alert('Hello World!');

How to use HTML page in Django

1 ) Create templates folder inside the application folder 2 ) Create home.html file inside the template folder Inside home.html <p>my first HTML page </p> 3 ) Change views.py like this  from django.shortcuts import render # Create your views here. def home(request):     return render(request,'home.html') 4 ) Change urls.py like this from django.conf.urls import patterns, include, url from django.contrib import admin urlpatterns = patterns('',     # Examples:     # url(r'^$', 'perfumes.views.home', name='home'),     # url(r'^blog/', include('blog.urls')),     url(r'^admin/', include(admin.site.urls)),     url(r'^home/$','perfum.views.home', name='home'), ) 5 ) Add app name to settings.py INSTALLED_APPS = (     'django.contrib.admin',     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',    

About Python Lists

About Python Lists Lists are a datatype you can use to store a collection of different pieces of information as a sequence under a single variable name … ..You can assign items to a list with Example : $ list_name = [item_1, item_2] Example : A list can also be empty: $ empty_list = [] Example : $ animals = ["cat", "dog", "lion", "tiger"];   print "The first " + animals[0] print "The second " + animals[1] print "The third " + animals[2] print "The fourth " + animals[3] Example : $ numbers = [5, 6, 7, 8] $ print numbers[0] + numbers[2] $ 12 Replace list value $ animals[2] = "zzz" … ..You can add items to the end of a list $ number.append(“9”) … ..List Slicing Sometimes, you only want to access a portion of a list. numb