Blogs

Advertisement

Advertisement

How to Setup Drupal for Local Development with Just PHP

With older versions of Drupal you could not run Drupal without Apache or Nginx to perform the URL rewrites needed to use the application with clean URLs.

New versions of Drupal (8+) come with a .ht.router.php file that is specifically used to run local development instances with just the built-in PHP web server. No Apache, no Wamp, no Mamp, no Xampp. Just the built-in PHP server.

In addition, you don't have to use MySQL an setup a separate database. Drupal supports SQLite3 so can completely skip any MySQL setup.

This means you can run a local Drupal development environment with nothing but PHP.

  • No Apache
  • No MySQL
  • No Wamp,Xampp,Mamp
  • Just PHP

Following the method in this guide works on Windows, Mac, and Linux equally.

Run JavaScript After DOM is Fully Loaded

Introduction

When writing JavaScript for a web browser, there are times when you want the page to fully load before the code is executed. This is particularly true if your JavaScript manipulates or utilized the HTML DOM. Your JavaScript will fail if it tries to reference an element that has not yet been loaded. This example will show you how to defer code from being executed until the web page has fully loaded.

Tips and Tricks for Colab

Colaboratory, or Colab for short, is a browser-based Python interpreter built by Google. It extends the open source Jupyter Notebook project.

With additional niceties such as Markdown previews, free GPU, and the ability to make a comment just like you would any Google Docs, Colab is quickly becoming the Python environment of choice among developers in machine learning, data science, and AI research spaces.

Here are few practical Tips and Tricks to help you get the most out of Colab.

Working with Git Repositories in Python

The GitPython project allows you to work in Python with Git repositories. In this guide we'll look at some basic operations like:

  • Initializing a repo
  • Cloning a repo
  • Adding and committing
  • Pushing and pulling with remotes
  • Checking for changes
  • Getting a diff
  • Listing and switching branches

For full documentation, see https://gitpython.readthedocs.io/. The source code is available at https://github.com/gitpython-developers/GitPython.

Python FTP Client Tutorial

FTP or File Transfer Protocol is a common way to transfer files. For FTP, Python has a built in package called ftplib.

There is also a Secure File Transfer Protocol (SFTP) that uses SSH to encrypt the communication. We will focus just on traditional FTP in this guide. For SFTP you can check out the Paramiko package.

In this guide, we will look at some basic operations like:

  • Connect and login to an FTP server
  • List directories and files
  • Upload and download files

Note these examples are all using Python 3.

Read and Send Email with Python

Python 3 has built-in libraries for IMAP, POP3, and SMTP. We will focus on learning how to send mail with SMTP and read/manage email with IMAP. We will also look at how to send an SMS text message using email.

If you need your own email hosting, check out Interserver.net hosting where you can host unlimited emails for unlimited domains as cheap as $4/month. You could also set up your own SMTP server on a VPS, but that is a hassle.

Advertisement

Advertisement