All Go Rust Python PHP JavaScript
Chrome Dev Summit to secure your spot in workshops, office hours and learning lounges!

How to Print the Memory Address of a Slice in Go

In Golang, using the %p verbs is the easiest way to print the memory address of a slice. Using fmt.Printf Function Pointer: %p base 16 notation, with leading 0x. The %b, %d, %o, %x and %X verbs also work with pointers, formatting the value exactly ...
Tomoki

How to Concatenate a List of Strings into a Single String in Python

In Python, using the str.join function is the easiest way to concatenate a list of strings into a single string Using str.join Function The str.join() method returns a string which is the concatenation of the strings in iterable. A TypeError will be...
aweis

How to Get Memory Size of the Variable in Go

In Golang, using the unsafe.Sizeof function is the easiest way to get memory size of the variable Using Sizeof Function You can use the unsafe.Sizeof function for this. It returns the size in bytes. See the following example: package main impo...
aweis

How to Check If an Object Is of a Given Type in Python

In Python, there are 2 ways to check if an object is of a given type. Using isinstance Method The isinstance(object, classinfo) method returns True if the object argument is an instance of the classinfo argument, or of a (direct, indirect, or virtua...
Unused

How to Read a Whole File into a String Variable in Go

In Golang, there are 3 ways to read a whole file into a string variable. Using ioutil.ReadFile Function ReadFile reads the file named by filename and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads...
aweis

How to Get a Slice of Keys from a Map in Go

In Golang, there are 3 ways to get a slice of keys from a map.Using For Range The easiest way to get keys of map in Golang: package main import "fmt" func main() { m := map[string]int{ "a": 1, "b": 1, "c": 1, } // minimize ...
Sambhav Khandelwal

How to Concatenate Strings in Rust

In Rust, there are 4 ways to concatenate strings. Using String.push_str Function This function actually appends a given string slice onto the end of this `String`. See the following example: fn main() { let mut s1: String = "Hello ".to_owned(...
Tomoki

How to Read a File Line-by-Line in Python

In Python, there are 3 ways to read a file line-by-line. Using For Loop For reading lines from a file, you can loop over the file object. This is memory efficient, fast, and leads to simple code: #!/usr/bin/python3 # -*- coding: utf8 -*- # read a...
pooriabt

How to use hash function in Python

Secure hashes and message digests.Hash algorithms The hashlib module implements a common interface to many different secure hash and message digest algorithms. Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512 (def...
Unused

How to use the free command in Linux

Display amount of free and used memory in the system. free displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The information is gathered by parsing /proc/meminfo....

How to use the curl command in Linux

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 ...

How to use the go build command line

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 ...

How to use the Docker-compose build command line

Build or rebuild services.If you change a service’s Dockerfile or the contents of its build directory, run docker-compose build to rebuild it. Docker-Compose build will read your docker-compose.yml or docker-compose.yaml. This step enables you to a...