Home » Programming

How to use ‘try/catch’ in PHP (with Examples)

'try/catch' in PHP

PHP is one of the most popular programming languages used to develop web applications and APIs. Linux is the system of choice for serving up your PHP code and is also an ideal PHP development environment. When writing PHP code, you’ll sometimes want to perform a certain action when an error is encountered (rather than just sending the user an error message and halting code execution). This is exactly what try/catch is used for in PHP. Syntax try { // Code to attempt } catch (Exception $e) { … Read more

Categories PHP

Home » Programming

How to Use “if… else” in JavaScript (with Examples)

"if... else" in JavaScript

JavaScript has quickly become one of the most popular programming languages due to its ease of use and flexibility – it can be run in just about any web browser on any device making it perfect for cross-platform apps. Linux is the most popular platform for hosting JavaScript Apps built with Node.js and is a great platform for developing both standalone JavaScript programs and browser-based solutions. If you’re learning JavaScript the if… else control structure is one of the first things you’ll want to get the hang … Read more

Home » Programming

How To Remove Items From A List in Python (With Examples)

python remove items from list

Python is widely used for both scripting and automation on Linux, as well as building web and standalone applications. Python is designed to be easy to learn, easy to write, and easy to read. It’s a great multi-purpose programming language. Python has several different types of arrays for storing data. Lists are arrays which allow you to store items. Items in lists can be altered, and are stored in a specific order. Syntax and Examples There are several methods you can use to remove an … Read more

Home » Programming

How to Make Multiline Comments in Python

How to make multi line comments in Python

In this tutorial, we explain the two methods used to make multiline comments in Python, with examples. There are some drawbacks to one of the methods, so pay attention. Code without comments is like a story written in a language you only half understand. You might be able to figure out the main points, but you’ll miss some nuances and it would be way easier with a translation alongside it. Most coders hate code with no comments or limited comments, so finding ways to clearly … Read more

Home » Programming

Python: How to Check Whether a File or Directory Exists

Python How to check whether a file or directory exists

In this article, we explain how to check whether a file or directory exists in Python and include some useful examples to help you get started. Python is a high-level programming language with dynamic semantics. Developed in the early 90s, and named after the Monty Python comedy troupe, it uses simple, easy-to-learn syntax and remains very popular amongst the programming community. It is particularly attractive for Rapid Application Development (RAD) and for its ability to connect existing components together. Python can be used for: server-side … Read more

Home » Programming

How to Convert a String to int in Python (and Int to String)

how to convert string int python 1

This article explains how to convert a string into an integer in Python. When you are looking to program with Python, it’s essential that you are aware of the different data types that you may be dealing with. The way your data is stored will depend on which kind of data it is and each kind of data operates in a different manner. Different data types in Python Data types that you’re likely to encounter fall under the categories of numeric, string, and boolean. Simply … Read more

Home » Programming

How to Use Split in Python to Split a String

python logo

Python is the world’s second most popular programming language and is the preferred choice of many programmers. It is particularly useful for backend web development, artificial intelligence, data analysis, and scientific computing, but can also be used for creating games and desktop apps. One of the most common questions when it comes to Python is how to split a string. A string in Python is a sequence of Unicode characters, and string variables can be very helpful for Python programmers. They can contain alphanumeric or … Read more

Home » Programming

Postgresql: show tables, show databases, show columns, describe table

PostgreSQL is one of the best database engines for an average web project and many who moves to psql from MySQL (for example) often ask the following questions: What is the analog of “show tables” in Postgres? How can I get the list of databases in Postgres like “show databases” in MySQL? In this quick tutorial, we’ll answer these questions, along with some other common commands which are useful. PostgreSQL doesn’t work with original MySQL commands, but it gives similar functionality with its own commands: … Read more

Home » Programming

How to monitor traffic at Cisco router using Linux (Netflow)

Cisco (featured logo)

By default Cisco IOS doesn’t provide any traffic monitoring tools like iftop or iptraff available in Linux. While there are lots of proprietary solutions for this purpose including Cisco Netflow Collection, you are free to choose nfdump and nfsen open source software to monitor traffic of one or many Cisco routers and get detailed monitoring data through your Linux command line or as graphs at absolutely no cost. Below is beginner’s guide that helps to quickly deploy netflow collector and visualizer under Linux and impress … Read more

Home » Programming

Create Linux user with password

Sometimes it’s necessary to create Linux user accounts in batch mode (fully automatic) but often newbies ask how to set password for a new user without entering it manually. Thanks to heaven command useradd can get password as an input parameter, but it should be encrypted. In other words, to create Linux user account with password the following command will be useful: useradd -m -p encryptedPass username I know at least two ways to get password encrypted. The first one is to use perl crypt(); … Read more