1.) Pulling Data from GitHub you need to make clone of your Repository on your system. follow the below instruction.
a.) git clone https://github.com/developer-rameshraj/Mean-Stack.git < folder-name >
b.) cd < folder-name >
c.) git init
d.) git pull
2.) Push Data in your GitHubRepository from your system. follow the below instruction.
a.) git init
b.) git add . or git add -A or git checkout -b <new-branch>
c.) git commit -m 'finish'
d.) git push origin master
3.) How to Install Ruby On Rails
4.) How to Use Mysql in Django
1.) Edit your settings.py
file like:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB_NAME',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': 'root',
'PASSWORD': '',
}}
2.) (a). sudo apt-get install libmysqlclient-dev
(b). pip install MySQL-python
- That's it!! you have configured Django with MySQL in a very easy way.
Now run your Django project:
3.) python manage.py migrate
4.) python manage.py runserver
5.) Migrate Table Database in Django
First need to create Model in model.py like
class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30)
the run command
a.) python manage.py makemigrations
b.) python manage.py migrate
6.) How to Send FormData from AJAX
$("form#frm").submit(function(event){
event.preventDefault();
var formData = new FormData($(this)[0]);
$.ajax({ url:'index.php?ajax',processData: false,contentType: false,type: "POST",data:formData,success:function(res){
console.log(res);
}});
return false;
});
7.) How to export data in csv format using python django
import djqscsv
Duplicate=AvOutExpDashDuplicate.objects.values('e_employee_number','report_owner_id').order_by()[:5]
return djqscsv.render_to_csv_response(Duplicate)
8.) How to export data in xls format using python django
import xlwt
import datetime , time
file_name = 'Expense-duplicate-'+str(int(round(time.time() * 1000)))+'.xls'
Duplicate = AvOutExpDashDuplicate.objects.values('e_employee_number','report_owner_id').order_by()[:5]
todo_obj=Duplicate
response = HttpResponse(content_type='application/ms-excel')
response['Content-Disposition'] = 'attachment; filename=%s' %(file_name)
wb = xlwt.Workbook(encoding='utf-8')
ws = wb.add_sheet("Todo")
row_num = 0
columns = [ (u"Employee Number", 4000), (u"Report ID", 8000), ]
font_style = xlwt.XFStyle()
font_style.font.bold = True
for col_num in xrange(len(columns)):
ws.write(row_num, col_num, columns[col_num][0], font_style)
# set column width
ws.col(col_num).width = columns[col_num][1]
font_style = xlwt.XFStyle()
font_style.alignment.wrap = 1
for obj in todo_obj:
row_num += 1
row = [
obj['e_employee_number'],
obj['report_owner_id'],
]
for col_num in xrange(len(row)):
ws.write(row_num, col_num, row[col_num], font_style)
wb.save(response)
return response
9.) How to import data from csv/xls file in database using python django
def import_data(request):
log_message= None
if request.method == 'POST':
file_name=request.FILES['csv_file'].name
fname=str(time.time())+'-'+file_name
handle_uploaded_file( request.FILES['csv_file'] , 'upload/'+fname)
with open('upload/'+fname) as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
p = Product( product_name=row['product_name'], price=row['price'], content_text=row['content_text'] )
p.save()
log_message = 'Data has been successfully added'
product_list = Product.objects.order_by('-pub_date')
context = {'product_list': product_list , 'message': log_message}
return render(request,'administrator/dashboard.html',context)
def handle_uploaded_file(f,fnam):
destination = open(fnam, 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()
======================================================================================
def import_data(request):
import csv
import pyexcel.ext.xls
log_message= None
if request.method == 'POST':
file_name=request.FILES['csv_file'].name
extension = filename.split(".")[1]
sheet = pyexcel.get_sheet(file_type=extension, file_content=request.FILES['csv_file'].read())
for row_xls in sheet:
if row_xls[0] == 'name':
continue
print row_xls[0]
return HttpResponse()
fname=str(time.time())+'-'+file_name
handle_uploaded_file( request.FILES['csv_file'] , 'upload/'+fname)
with open('upload/'+fname) as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
p = Product( product_name=row['product_name'], price=row['price'], content_text=row['content_text'] )
p.save()
log_message = 'Data has been successfully added'
product_list = Product.objects.order_by('-pub_date')
context = {'product_list': product_list , 'message': log_message}
return render(request,'administrator/dashboard.html',context)
def handle_uploaded_file(f,fnam):
destination = open(fnam, 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()
10.) How to install Laravel in Linux
1.) Go to your Root directory by CLI (Command line interface).
2.) We have to need "PHP mcrypt" extension module be enabled.
To enable it, run this command in the terminal.
sudo php5enmod mcrypt
after that restart the Apache web server to load the mcrypt module:
sudo service apache2 restart
to check if mcrypt is enabled or not:
php -m | grep mcrypt
3.) Go to your WebRoot direcory (var/www/html) and run this command in terminal
sudo curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
4.)Finally, we are ready to actually install the Laravel framework, after completing these steps.
composer create-project laravel/laravel laravel --prefer-dist
5.) copy all files of public folder and paste out side of public folder , after that Open the index.php in the laravel folder in a text editor and replace the two occurrences of __DIR__.'/../bootstrap/autoload.php' with __DIR__.'/bootstrap/autoload.php'. Essentially, you are removing /.. from the path. Save the index.php file.
Either you can start by CLI using this command : php artisan serve
*************************************************************************************************************************************
We are ready to test the Laravel installation! Open your web browser and enter http://projects.local/laravel/ in the address bar.
2.) We have to need "PHP mcrypt" extension module be enabled.
To enable it, run this command in the terminal.
sudo php5enmod mcrypt
after that restart the Apache web server to load the mcrypt module:
sudo service apache2 restart
to check if mcrypt is enabled or not:
php -m | grep mcrypt
3.) Go to your WebRoot direcory (var/www/html) and run this command in terminal
sudo curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
4.)Finally, we are ready to actually install the Laravel framework, after completing these steps.
composer create-project laravel/laravel laravel --prefer-dist
5.) copy all files of public folder and paste out side of public folder , after that Open the index.php in the laravel folder in a text editor and replace the two occurrences of __DIR__.'/../bootstrap/autoload.php' with __DIR__.'/bootstrap/autoload.php'. Essentially, you are removing /.. from the path. Save the index.php file.
Either you can start by CLI using this command : php artisan serve
*************************************************************************************************************************************
We are ready to test the Laravel installation! Open your web browser and enter http://projects.local/laravel/ in the address bar.
11.) Strip Integration
// $p=\Stripe\Customer::create( array(
// "email" => "sneha.unified17@gmail.com",
// "description" => "Employess"
// ));
// print_r($p);
// $account = \Stripe\Customer::retrieve(" cus_A8N9jIROdxw0VZ");
// print_r($account->sources);
// $myCard = array('number' => '5200828282828210', 'exp_month' => 8, 'exp_year' => 2018);
// $charge = \Stripe\Charge::create(array(' card' => $myCard, 'amount' => 1000, 'currency' => 'usd'));
// print_r($charge);
// $charge = \Stripe\Charge::create(array(
// "amount" => '100',
// "currency" => "usd",
// "customer" => 'cus_A8N9jIROdxw0VZ',
// "description" => 'Pay for Customer'
// ));
// print_r($charge);
$customer = \Stripe\Customer::retrieve('cus_A8TnDLGgvhzjTh');
$customer->sources->create([
'card' => [
'number' => '4242424242424242',
'exp_month' => 10,
'cvc' => 314,
'exp_year' => 2020,
'name' => 'Sneha Sarkar',
],
]);
$customer = \Stripe\Customer::retrieve('cus_A8TnDLGgvhzjTh');
$customer->sources->create([
'bank_account' => [
'country' => 'US',
'routing_number' => '110000000',
'account_number' => '000123456789',
"account_holder_name" => "Jane Austen",
"account_holder_type" => "individual",
"country" => "US",
"currency" => "usd",
],
]);
12.) How to create virtual host with wildcard in apache server using ubuntu
sudo gedit /etc/apache2/sites-available/demo.com.conf
13.) Install Python 3 virtualenv on Ubuntu
12.) How to create virtual host with wildcard in apache server using ubuntu
1.) Start by copying the file for the first domain:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/
demo.com
.conf
2.) Open the new file in your editor with root privileges:
sudo gedit /etc/apache2/sites-available/demo.com.conf
3.) Remove the all constant from the file and replace the below text :
<VirtualHost *:80>
ServerAdmin demo@example.com
ServerName demo.com
ServerAlias www.demo.com
DocumentRoot /var/www/html/php-work/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
4.) We can use the
ServerAdmin demo@example.com
ServerName demo.com
ServerAlias www.demo.com
DocumentRoot /var/www/html/php-work/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
4.) We can use the
a2ensite
tool to enable each of our sites like this:
sudo a2ensite demo.com.conf5.) Set the local host and restart server:
sudo nano /etc/hosts
127.0.0.1 demo.com
sudo service apache2 restart
for wildcard setup
1.) sudo apt-get install dnsmasq
2.) sudo service network-manager restart
3.) sudo gedit dnsmasq.conf
4.) include the line #address=/demo.com/127.0.0.1
5.)
sudo /etc/init.d/dnsmasq restart
13.) Install Python 3 virtualenv on Ubuntu
# Step 1: Update your repositories sudo apt-get update # Step 2: Install pip for Python 3 sudo apt-get install build-essential libssl-dev libffi-dev python-dev sudo apt install python3-pip # Step 3: Use pip to install virtualenv sudo pip3 install virtualenv # Step 4: Launch your Python 3 virtual environment, here the name of my virtual environment will be env3 virtualenv -p python3 env3 # Step 5: Activate your new Python 3 environment. There are two ways to do this . env3/bin/activate # or source env3/bin/activate which does exactly the same thing # you can make sure you are now working with Python 3 python -- version # this command will show you what is going on: the python executable you are using is now located inside your virtualenv repository which python # Step 6: code your stuff # Step 7: done? leave the virtual environment deactivate