Skip to main content

Posts

How to get thumbnails of youtube videos?

Recent posts

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, "example.com"); 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:
Projects/model.py
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 manage.py 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…

Google material tabs for website

The MDC Tabs component contains components which are used to create spec-aligned tabbed navigation components adhering to the Material Design tabs guidelines. These components are:
mdc-tab: The individual tab elementsmdc-tab-bar: The main component which is composed of mdc-tab elementsmdc-tab-bar-scroller: The component which controls the horizontal scrolling behavior of an mdc-tab-bar that overflows its container
Example: Tabs  <section id="dynamic-demo-toolbar"> <nav id="dynamic-tab-bar" class="mdc-tab-bar mdc-tab-bar--indicator-accent" role="tablist"> <a role="tab" aria-controls="panel-1" class="mdc-tab mdc-tab--active" href="javascript:void(0)">Item One</a> <a role="tab" aria-controls="panel-2" class="mdc-tab" href="javascript:void(0)">Item Two</a> <a role="tab" aria-cont…