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

How to Get a Random Number Between a Float Range in Python

In Python, using the uniform function is the easiest way to get a random number between a float range. Using uniform Method The random.uniform(a, b) method returns a random floating point number N such that a
Unused

How to Encrypt and Decrypt a String Using AES GCM 256 in Go

In Golang, using the crypto/aes package is the easiest way to encrypt a string using AES GCM 256. In cryptography, Galois/Counter Mode (GCM) is a mode of operation for symmetric-key cryptographic block ciphers which is widely adopted for its performa...
Tomoki

How to Generate Random Integers Between 0 and 9 in Python

In Python, there are 3 ways to generate random integers between 0 and 9. Using randrange Method The random.randrange(start, stop[, step]) method returns a randomly selected element from range(start, stop, step). For example, #!/usr/bin/python3 ...
Patcher56

How to Generate a UUID in Go

In Golang, there are 4 ways to generate a uuid. Using uuid Package install Use the following command to download the repository to the local file system. install go mod tidy go get github.com/google/uuid go install github.com...
Sambhav Khandelwal

How to Randomly Select a Element from List in Python

In Python, there are 3 ways to randomly select a element from list. Using random.choice Method The random.choice() method returns a random element from the non-empty sequence seq. If seq is empty, raises IndexError. For example, #!/usr/bin/pyth...
Tomoki

How To Generate a Random String in Python

In Python, there are 3 ways to generate a random string.Using List Comprehension List comprehensions provide a concise way to create lists. See the following example: #!/usr/bin/python3 # -*- coding: utf8 -*- # Import module import random impor...
Sambhav Khandelwal

How to shuffle a slice in Go

Shuffling a Slice in Golang.Using rand.Shuffle Function Shuffle pseudo-randomizes the order of elements using the default Source. package main import ( "fmt" "math/rand" "time" ) func main() { s := []string{"Japan", "Germany", "France"} ...
ada

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 generate a random string in Go

Creating Random Strings of a fixed length in Go. Using rand.Int63 Function Int63 returns a non-negative pseudo-random 63-bit integer as an int64 from the default Source. package main import ( "fmt" "math/rand" "time" ) const letters = "a...
ada

How to use the head command in Linux

Print the first 10 lines of each FILE to standard output. head is a program on Unix and Unix-like operating systems used to display the beginning of a text file or piped data. By default, head will print the first 10 lines of its input to the stand...

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