Skip to main content


How to print pretty json in python

Recent posts

How to get thumbnails of youtube videos?

You can try for different types of YouTube videos thumbnails by using these urls -
For the default & normal quality thumbnail:<youtube-video-id>/default.jpg
For the high quality (HQ) thumbnail:<youtube-video-id>/hqdefault.jpg
There is also a medium quality thumbnail:<youtube-video-id>/mqdefault.jpg
For the maximum resolution thumbnail:<youtube-video-id>/maxresdefault.jpg

For eg .
YouTube link - video id -4EvNxWhskf8
So that -
<imgsrc=""title="YouTube Video"alt="YouTube Video"/>

Send POST file using Curl in PHP

Curl is the most powerful Http Client. We can send any request using curl.
Today we will discuss about send a file with curl in PHP.

We will discuss to send file from our directory and also from a form.

File from directory
$this->fields = array( "file" => curl_file_create('file/path/image.png', 'image/jpeg', 'file_name') ); $http = curl_init(); curl_setopt($http, CURLOPT_URL, ""); curl_setopt($http, CURLOPT_POST, true); curl_setopt($http, CURLOPT_POSTFIELDS, $this->fields); curl_setopt($http, CURLOPT_RETURNTRANSFER, true); curl_exec($http);

File from Form
$this->fields = array( "file" => curl_file_create($_FILES['file']['tmp_name'], $_FILES['file']['type'], $_FILES['file']['name']) ); $http = curl_init(); curl_setopt($http, CURLOPT_URL, "ex…

ManyToMany relationship in django models

I'm trying to add relation between three table with manyToMany relationship. I'm learning python and new for Django framework. For requirement, An user can add a project and he also can add permission for view for another user. It means an user can have multiple projects and a project also have multiple user. User model is default user model of django.
and the project model is:
from django.db import models from django.contrib.auth.models import User # Create your models here. class Projects(models.Model): project_title = models.CharField(max_length=255) description = models.TextField(blank=True) privacy = models.SmallIntegerField(default=1) # 1 for public, 2 for private status = models.SmallIntegerField(default=1) #1 for active, 2 for deactive, 3 for delete, 4 for depricated created_at = models.DateTimeField('date published', blank=True, default=False) users = models.ManyToManyField(User, through="UserP…

Run Django server for permanent on Centos and Ubuntu

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

 This article assumes that you have already Django installed alreay. If you don't, you can install Django from here. 

To start Django project, Django have a command for run development server.

python runserver
Now problem is that, after close the terminal server has also stopped. And you can't access your project anymore.

Now what we have to do to run Django server for permanent? 

There are so many methods to run any server for permanent but we will discuss the easiest method to run server.

We are talking about Screen. 
This is  the simple method to run server forever.

First install screen on your system.
Here the guidelines to install screen on linux …

How to install and use "Screen" on Centos and Ubuntu

This article will introduce you to a handy application called "Screen"

We all are familiar with Terminal OR SSH OR Putty. 
We all knows the limit of these tools if we close terminal, we lost our progress. So to handle this problem, There comes Screen to manage all connections.

Installation of screen on Centos6, Cents7
$ sudo yum install screen
Installation of screen on Linux, Ubuntu
$ sudo apt-get install screen

Install a MySQL server on Centos7 using CMD

MySQL is an open-source relational database that is free and widely used. It is a good choice if you know that you need a database but don’t know much about all of the available options.

This article describes a basic installation of a MySQL database server on CentOS Linux. You might need to install other packages to let applications use MySQL, like extensions for PHP. Check your application documentation for details.

Install MariaDB Install the MariaDB server through the CentOS package manager (yum) by running the following command at a command prompt:

sudo yum install mariadb-server mariadb

Start and stop the database service Use the following command to start MariaDB:
sudo systemctl start mariadb.service
Use the following command to stop MariaDB:

sudo systemctl stop mariadb.service
Launch at reboot To ensure that the database server launches after a reboot, you must enable the chkconfig utility. Use the following commands to do this.
Enable chkconfig on MariaDB
sudo syste…