Sequelize is a great ORM for Express which supports not just MySQL but also PostgreSQL and SQLite. Just like any other ORM, to perform JOIN queries using models you need to first define an association between the two tables (models). This association can be hasOne, hasMany, belongsTo and so on. Now this becomes tricky if […]
In this article we’ll learn how you can let your app users login with Google Account into your PHP web application using Google PHP Client version 2. It’s assumed that you have already installed composer and are using a version of PHP greater than 5.4. To view the entire code please visit this gist. Create […]
In this article you’ll learn the basics of creating charts using svg and D3. Above is what we’ll be creating by the end of this tutorial. Creating charts with just svg svg with single rect and minimal styling Before proceeding further it’s noteworthy to have a quick overview of how to create charts using svg […]
Below is the code
from glob import glob
PATH = "/home/someuser/projects/someproject"
EXT = "*.csv"
all_csv_files = [file
for path, subdir, files in os.walk(PATH)
for file in glob(os.path.join(path, EXT))]
That’s it !! While above code is written for searching csv files recursively in directory and subdirectory; it can be used to search for any file type. You just need to change the EXT. So say you want to find all the .css files, all you have to do is […]
Get current branch
Above command will list out all the branches in your current working directory that you checked out. The current active branch will have a asterik mark before it. Switch to different branch Say you are working on master branch. Now you need to switch to branch named develop
git checkout develop
Create new […]
mod_rewrite is an Apache module that allows to rewrite requested urls on the fly using rule based rewrite engine. In simple language it is the module that empowers your .htaccess file. It is not activated by default. So you’ll notice your htaccess rules won’t work on fresh install of Apache. In this tutorial we’ll see […]
This tutorial is for changing root directory of apache server on Debian system like Ubuntu. When you install apache (or LAMP) by default the root directory of apache is /var/www/html. When doing development on local machine you might want to change this to some directory in your home directory. Advantage of doing this is you […]
Let’s say you have a website on you wamp server by name project. So there’s a directory project in your C:\wamp\www directory. Also visiting http://localhost/project on the browser takes us to your project website. Now we want to set up a virtual host with self signed SSL certificate so that we can visit our website […]
What are design patterns Design patterns are coding strategy followed by developers. It’s just like an architectural plan followed in building houses. As per theory it can defined as “A general solution to commonly occurring problems in software design”. Instead of talking about what Design patterns are let’s have a look at some real world […]
Below are the steps to install PHPUnit on Windows. Irrespective of whether you are using WAMP or XAMP installation steps shall remain the same. Step I: Create a directory named bin in C drive. Step II: Now add the path C:\bin to your environment. To do this click on Windows icon and right click on […]
In this article we have listed few yet very useful and very commonly used MongoDB commands. This article is not a tutorial on MongoDB but a list of useful commands for MongoDB; so this is kind of cheatsheet of MongoDB commands. How to take backup of MongoDB database Run the below command in command prompt […]
This tutorial covers usage of a custom PHP function to generate paginated links for records fetched from database. This function uses HTML markup as per Bootstrap framework. It also supports adding additional query string to each paginated link.
There has been always a fuzz about the best practices to be followed while programming in PHP. Unlike Python, PHP doesn’t add any restrictions or has any hard and fast rule for indentations. Be it naming conventions for class names or functions or be it positioning of braces; each developer follows his own standards as […]
In this article we’ll learn how to configure your personal Gmail account to use your domain email address. Gmail allows adding 5 such addresses. Mails will be sent through your servers SMTP server but you’ll be able to send and receive them in Gmail.