Skip to content

Instantly share code, notes, and snippets.

View pablocattaneo's full-sized avatar

Pablo Cattaneo pablocattaneo

View GitHub Profile
# using pngquant package
https://github.com/kornelski/pngquant
# git revert creates a new commit that undoes the changes from a specific commit. It doesn't remove commits from history or revert "until" a point.
# How git revert works:
# Creates a new commit that reverses the changes
# Doesn't delete or remove commits from history
# Works on specific commits, not ranges
# Important: Order matters
# Revert in reverse chronological order (newest first) to avoid conflicts:
// maps.Equal(map1, map2) bool
myMap2 := map[string]string{
"name": "Alice",
"country": "Wonderland",
}
fmt.Println("Second map:", myMap2)
myMap3 := map[string]string{
"name": "Alice",
"country": "Wonderland",
// syntax: mapLiteral := map[keyType]valueType{ key1: value1, key2: value2, }
myMap2 := map[string]string{
"name": "Alice",
"country": "Wonderland",
}
fmt.Println("Second map:", myMap2)
myMap := make(map[string]int)
myMap["key1"] = 15
myMap["key2"] = 100
myMap["key3"] = 7
myMap["key4"] = 23
value, exists := myMap["key1"]
fmt.Println("Value for key1:", value, "Exists:", exists) //Value for key1: 15 Exists: true
valueOfKey10, existsKey10 := myMap["key10"]
fmt.Println("Value for key10:", valueOfKey10, "Exists:", existsKey10) // Value for key10: 0 Exists: false
myMap := make(map[string]int)
myMap["key1"] = 15
myMap["key2"] = 100
myMap["key3"] = 7
myMap["key4"] = 23
// clear syntax: clear(mapVariable)
clear(myMap)
fmt.Println("Map after clearing:", myMap)
// delete syntax: delete(mapVariable, key)
myMap := make(map[string]int)
myMap["key1"] = 9
delete(myMap, "key1")
//slices.Equal(slice1, slice2)
a := [5]int{1, 2, 3, 4, 5}
slices1 := a[1:4] // from index 1 to index 3
sliceCopy := make([]int, len(slices1))
if slices.Equal(slices1, sliceCopy) {
fmt.Println("slices1 and sliceCopy are equal")
} else {
fmt.Println("slices1 and sliceCopy are not equal")
// []T{e1, e2, e3, ...}
// Where T is the type of the elements (e.g., int, string, bool, struct),
// and e1, e2, e3, etc., are the initial elements of the slice
fruits := []string{"Apple", "Banana", "Orange"}