Skip to content

Instantly share code, notes, and snippets.

View Siva-Karthi's full-sized avatar
🎯
Focusing

SIVA Siva-Karthi

🎯
Focusing
View GitHub Profile
#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()
@Siva-Karthi
Siva-Karthi / values_pointers.go
Created October 14, 2020 09:41 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@Siva-Karthi
Siva-Karthi / goCustomValidaor.go
Last active June 29, 2021 14:12
custom validation go validator
package main
import (
"fmt"
"github.com/go-playground/validator"
"regexp"
)
type Student struct {
@Siva-Karthi
Siva-Karthi / goValidatorSimple.go
Created June 29, 2021 14:15
simple go validator
package main
import (
"fmt"
"github.com/go-playground/validator"
)
type Student struct {
Name string `validate:"required"`
}
@Siva-Karthi
Siva-Karthi / goValidatorProvideErrorOnJsonTags.go
Created June 29, 2021 14:19
goValidatorProvideErrorOnJsonTags
package main
import (
"fmt"
"github.com/go-playground/validator"
"reflect"
"regexp"
"strings"
)
@Siva-Karthi
Siva-Karthi / goValidatorErrorTranslation.go
Created June 29, 2021 14:31
goValidatorErrorTranslation
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"
@Siva-Karthi
Siva-Karthi / amazon_music_pair.py
Created May 5, 2022 18:42
amazon music interview question solution in python
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]