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

How to Make a List of Alphabet Characters in Python

In Python, there are 2 ways to make a list of alphabet characters. Using string Module The string.ascii_lowercase is a pre-initialized string used as string constant. In Python, string ascii_lowercase will give the lowercase letters ‘abcdefghijklmno...
Patcher56

How to Encrypt and Decrypt a String Using AES CBC in Go

In Golang, using the crypto/aes package is the easiest way to encrypt a string using AES CBC. Ehrsam, Meyer, Smith and Tuchman invented the cipher block chaining (CBC) mode of operation in 1976. In CBC mode, each block of plaintext is XORed with the ...
Tomoki

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 Delete the Contents of a Folder in Python

In Python, there are 2 ways to delete the contents of a folder. Using rmtree Method The shutil.rmtree() method deletes an entire directory tree; path must point to a directory. For example, #!/usr/bin/python3 # Import module import os, shutil ...
Tomoki

How to Create a GUID/UUID in Python

In Python, using the uuid module is the easiest way to create a GUID/UUID. Using uuid Module uuid module provides immutable UUID objects (the UUID class) and the functions uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 UUID...
aweis

How to Determine if an Object is Iterable in Python

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

How to Do a Case Insensitive Regular Expression in Go

In Golang, using the a case-insensitive flag is the easiest way to do a case insensitive regular expression. Using a case-insensitive flag You can set a case-insensitive flag as the first item in the regex. You can add a (?i) at the beginning of th...
ada

How to Reverse a String in Python

In Python, there are 3 ways to reverse a string. Using slicing Slice notation takes the form [start:stop:step]. #!/usr/bin/python3 s = "Hello World" print(s[::-1]) # syntax # a[start:stop] # items start through stop-1 # a[start:] # items...
pooriabt

How to Split a String in Rust

In Rust, there are 3 ways to split a string. Using split Function An iterator over substrings of this string slice, separated by characters matched by a pattern. See the following example: fn main() { let s = "abc1bcd2e"; let _split = s.sp...
ada

Rust error: cannot assign twice to immutable variable

In Rust, variables by default are immutable.Variables Immutable You can make them mutable by adding mut in front of the variable name. For example, fn main() { let x = 2; println!("value x: {}", x); x = 4; println!("value x: {}", x); } ...
Patcher56

Hello World in Rust

In Rust, "Hello World!" is the first basic program. Build and Run In our main.rs, add the following code: // main.rs fn main() { println!("Hello,世界,こんにちは,안녕하세요") } Hello,世界,こんにちは,안녕하세요 we can run our application by typing: B...
pooriabt

How To Install Rust in Linux

In Rust, there are two ways to install rust in Linux.Running the following in your terminal If you’re running macOS, Linux, or another Unix-like OS. To download Rustup and install Rust, run the following in your terminal, then follow the on-screen i...
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 string constants in Python

String Constants Best Practice.String Constants in Python The constants defined in this module are: String constants: string.ascii_lettersThe concatenation of the ascii_lowercase and ascii_uppercase constants described below. This value is not locale...
Tomoki

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