This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://www.programiz.com/python-programming/closure | |
def print_msg(msg): | |
# This is the outer enclosing function | |
def printer(): | |
# This is the nested function | |
print(msg) | |
printer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
******************************************************************************** | |
Golang - Asterisk and Ampersand Cheatsheet | |
******************************************************************************** | |
Also available at: https://play.golang.org/p/lNpnS9j1ma | |
Allowed: | |
-------- | |
p := Person{"Steve", 28} stores the value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/go-playground/validator" | |
"regexp" | |
) | |
type Student struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/go-playground/validator" | |
) | |
type Student struct { | |
Name string `validate:"required"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/go-playground/locales/en" | |
ut "github.com/go-playground/universal-translator" | |
"github.com/go-playground/validator/v10" | |
en_translations "github.com/go-playground/validator/v10/translations/en" | |
"reflect" | |
"regexp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def music_pair(song_durations, travel_duration): | |
same_duration_song_indexes = {} | |
for i, duration in enumerate(song_durations): | |
try: | |
same_duration_song_indexes[duration].append(i) | |
except KeyError: | |
same_duration_song_indexes[duration] = [i] |