This file contains hidden or 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
| def factorial(n): | |
| if n==0: | |
| return 1 | |
| else: | |
| return (n*factorial(n-1)) |
This file contains hidden or 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
| def Length(l): | |
| if l==[]: | |
| return (0) | |
| else: | |
| return(1 + Length(l[1:])) |
This file contains hidden or 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
| def sumlist(l): | |
| if l==[]: | |
| return (0) | |
| else: | |
| return(l[0]+sumlist(l[1:])) |
This file contains hidden or 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" | |
| ) | |
| func print(n int) { | |
| for i := 0; i < n; i++ { | |
| fmt.Print("* ") | |
| } |
This file contains hidden or 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
| // getRandNum returns a random number of size four | |
| func getRandNum() (string, error) { | |
| nBig, e := rand.Int(rand.Reader, big.NewInt(8999)) | |
| if e != nil { | |
| return "", e | |
| } | |
| return strconv.FormatInt(nBig.Int64()+1000, 10), nil | |
| } |
This file contains hidden or 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 "github.com/go-redis/redis" | |
| // Client is setting connection with redis | |
| var redisClient = redis.NewClient(&redis.Options{ | |
| Addr: "localhost:6379", | |
| Password: "", // no password set | |
| DB: 0, // use default DB | |
| }) | |
| // SetValue sets the key value pair | |
| func SetValue(key string, value string, expiry time.Duration) error { |
This file contains hidden or 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 ( | |
| "github.com/souvikhaldar/gobudgetsms" | |
| "fmt" | |
| ) | |
| var smsConfig gobudgetsms.Details | |
| func init() { | |
| smsConfig = gobudgetsms.SetConfig(BsmsUsername, BsmsUserId, BsmsHandle, "", 1, 0, 0) | |
| } |
This file contains hidden or 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 "github.com/nu7hatch/gouuid" | |
| func randToken() (string, error) { | |
| // Using UUID V5 for generating the Token | |
| u4, err := uuid.NewV4() | |
| UUIDtoken := u4.String() | |
| if err != nil { | |
| logrus.Errorln("error:", err) | |
| return "", err | |
| } |
This file contains hidden or 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
| // GetValue the value corresponding to a given key | |
| func GetValue(key string) (string, error) { | |
| value, arghhh := redisClient.Get(key).Result() | |
| if arghhh != nil { | |
| return "", arghhh | |
| } | |
| return value, nil | |
| } | |
| originalNum, e := GetValue(otp.SmsNonce) |
This file contains hidden or 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" | |
| "time" | |
| ) | |
| func say(s string) { | |
| for i := 0; i < 5; i++ { | |
| time.Sleep(100 * time.Millisecond) |
OlderNewer