In Python, there are 2 ways to determine whether a given integer is between two other integers.
Using Comparisons
Unlike C, all comparison operations in Python have the same priority, which is lower than that of any arithmetic, shifting or bitwise o...
In Python, there are 2 ways to find out the number of CPUs.
Using multiprocessing Module
The multiprocessing.cpu_count() method returns the number of CPUs in the system. For example,
#!/usr/bin/python3
# Import module
import multiprocessing
c...
In Golang, there are 2 ways to check if a file is a valid image.
Using DetectContentType Function
The http.DetectContentType() function implements the algorithm described at https://mimesniff.spec.whatwg.org/ to determine the Content-Type of the gi...
In Python, there are 3 ways to get the system hostname.
Using gethostname Method
The socket.gethostname() method returns a string containing the hostname of the machine where the Python interpreter is currently executing. For example,
#!/usr/bin...
In Python, there are 2 ways to determine if an object is iterable.
Using Duck Typing
Duck typing is a concept related to dynamic typing, where the type or the class of an object is less important than the methods it defines. When you use duck typing...
In Rust, there are 3 ways to check if string contains substring.Using String contains Function
The easiest way to check if a Rust string contains a substring is to use String::contains method.
The contains method Returns true if the given pattern m...
Splitting a String into a Slice in Golang.Using strings.Split Function
Use the strings.Split function to split a string into its comma separated values.
package main
import (
"fmt"
"strings"
)
func main() {
s := "Japan,Germany"
// func S...
How do you check if a string contains a substring?.Using String.prototype.includes
The includes() method performs a case-sensitive search to determine whether one string may be found within another string, returning true or false as appropriate.
'Go...
The most common numeric conversions are Atoi.strconv.Atoi Function
Package strconv implements conversions to and from string representations of basic data types.
package main
import (
"fmt"
"strconv"
)
func main() {
i, err := strconv.Atoi("...
user interface to the TELNET protocol.
Telnet is an application protocol used on the Internet or local area network to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection. User data is interspe...
command line tool and library for transferring data with URLs.
cURL (pronounced 'curl') is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name ...
List Files and Directories.The ls command lists files and directories within the file system, and shows detailed information about them. It is a part of the GNU core utilities package which is installed on all Linux distributions.
List all files, in...
compile packages and dependencies.
Build compiles the packages named by the import paths, along with their dependencies, but it does not install the results.
Build
go build
go build hello.go
ls -lh
1.9M Jun 29 17:38 hello
...