PHPNews

Middleware in Express applications

If you have recently moved or are thinking of moving to the nodejs Express framework than you should primarily get acquainted with its routing and middleware concepts, as an Express application is essentially a series of middleware function calls. Middlewares in Express are functions executed after the incoming …

Continue reading »

Written by code-diesel - - Aggregated on Tuesday January 15, 2019


Styling terminal string in NodeJS

Most terminal applications or tools in NodeJS are single colored in nature. ‘Chalk’ is a nodejs package that allows you to style your application terminal output strings in various colors and styles, making it more readable and colorful. Installation is via npm. npm install chalk Usage is short and …

Continue reading »

Written by code-diesel - - Aggregated on Monday January 14, 2019


Updating WordPress GUIDS

Recently I changed domain name of one of my other WordPress blogs. However after transferring I found that the GUId’s of the old posts were not updated. They were still referencing the old domain. This caused the feed of the new site to show incorrect domains. My initial thought was to to use a plugin, but it would …

Continue reading »

Written by code-diesel - - Aggregated on Thursday December 13, 2018


How to open various desktop applications from nodejs

The most commonly opened resources in a program are files, urls and database connections. he ‘Opn’ package allows you to open stuff like websites, files, executables in their respective desktop applications. The package is cross-platform. I usually use the package during testing phase – opening various resources, …

Continue reading »

Written by code-diesel - - Aggregated on Thursday September 6, 2018


Dash

Build beautiful web-based interfaces in Python. Dash is a Python framework for building analytical web applications. No JavaScript required. The post Dash appeared first on codediesel .

Continue reading »

Written by code-diesel - - Aggregated on Saturday September 1, 2018


Tuples in Python

Tuples are one of the core object types in Python. Although tuples may seem like lists, they are often used in different situations and for different purposes and unlike lists they are immutable. Syntactically they are enclosed in parenthesis (or without them) instead of square brackets like lists, but they …

Continue reading »

Written by code-diesel - - Aggregated on Wednesday August 15, 2018


List Comprehensions in Python

Lists are a versatile Python data structure and allows various sequence operations. Besides the usual, Lists also include a powerful operation called as ‘list comprehension’ which allows us to process various list structures, like a matrix or nested arrays or lists. It allows you to concisely form a new list by …

Continue reading »

Written by code-diesel - - Aggregated on Wednesday August 15, 2018


Working with zip files in Python

Since I started working with computers, my favorite file format was ‘zip’, popularized by the Windows PKZIP program. The idea of compressing data into shorter versions of themselves was a fascinating idea. Then, I was ignorant of the mathematical foundations of information theory, so it seemed like magic. I spent …

Continue reading »

Written by code-diesel - - Aggregated on Wednesday August 15, 2018


How to connect to MySQL in Python

Connecting to MySQL from Python offers many solutions, but I like the official MySQL connector. You can install the module using pip. sudo pip install mysql-connector-python Once the module is installed you can connect to MySQL using the following code. import mysql.connector   cnx = mysql.connecto…

Continue reading »

Written by code-diesel - - Aggregated on Tuesday August 14, 2018


How to check for DNS server speeds

As you may know DNS is a system by which a browser or other software converts a domain name to a IP4 or IP6 address. Each time we access a website the browser needs to convert the domain name to a IP4/IP6 address using a DNS server. The DNS server configured on your computer could be automatically selected by your …

Continue reading »

Written by code-diesel - - Aggregated on Tuesday August 7, 2018


Quickly find all links on a web page

The following PHP script will quickly find all the links on a web page, removing any duplicates and also giving the total count for any duplicate links found. $html = file_get_contents('https://www.example.com/');   $dom = new DOMDocument();   /* Sending any errors to the void */ @$dom->loadHTML($html);   /…

Continue reading »

Written by code-diesel - - Aggregated on Wednesday July 25, 2018


How do MVC routers work

A MVC Router class or a Dispatcher inspects the URL of an HTTP request and attempts to match individual URL components to a Controller and a method defined in that controller, passing along any arguments to the method defined. Below is shown a simple PHP router class which gives a general overview of how a router …

Continue reading »

Written by code-diesel - - Aggregated on Tuesday July 24, 2018


Convert CSV to Excel in PHP

During a recent data conversion project I needed to convert around 250 CSV files to Excel (xls) format. As this was a PHP project I decided to write a small PHP script using the PhpSpreadsheet library. Installation Use composer to install PhpSpreadsheet into your project: composer require phpoffice/phpsp…

Continue reading »

Written by code-diesel - - Aggregated on Thursday July 12, 2018


Writing WordPress posts in Markdown

WordPress allows you to write your posts using Markdown. This feature is available using Jetpack. If you write some of your eBooks or other documents using Markdown, and need to transfer some of the same content to a WordPress blog than this feature is extremely useful. No need to again create a different HTML version …

Continue reading »

Written by code-diesel - - Aggregated on Wednesday July 4, 2018


Free datasets for testing database engines

Below is a small list of free datasets with which you can test your database queries or use it for learning and practicing sql query optimization or other things. I’ve recently started reading some database books, specially by Joe Celko , and needed some medium size datasets on which I could run the sql queries …

Continue reading »

Written by code-diesel - - Aggregated on Monday July 2, 2018


PHP Simple HTML DOM Parser Script

In this post I have explained some elements to scrap data from external websites. Simple HTML DOM parser is a PHP 5+ class which is useful to manipulate HTML elements. This class can work with both valid HTML and HTML pages that do not pass W3C validation. You can find elements by ids, classes, tags and many more. …

Continue reading »

Written by code-diesel - - Aggregated on Thursday June 21, 2018