Skip to content

Instantly share code, notes, and snippets.

View kanapuli's full-sized avatar
🏠
Working from home

Athavan Kanapuli kanapuli

🏠
Working from home
View GitHub Profile
@kanapuli
kanapuli / main.go
Created January 20, 2017 16:23
Find the Greatest Common Divisor between Two Numbers
package main
import "fmt"
//FindGCD - finds the greatest common divisor between two numbers
func FindGCD(a, b int) (gcd int) {
var list []int
for i := 1; i <= smallestNumber(a, b); i++ {
if a%i == 0 && b%i == 0 {
list = append(list, i)
@kanapuli
kanapuli / ReverseArray.go
Created July 1, 2017 03:25
Golang Implementation to Reverse print an array
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
//topological sort
package main
import (
"fmt"
"sort"
)
var pathOfFullstack = map[string][]string{
@kanapuli
kanapuli / type.go
Created September 10, 2017 13:17
Types in Go
package main
import "fmt"
type cat string
//String from type cat always meows
func (c cat) String() string {
return fmt.Sprintln("A Cat always Meows")
}
package main
import "fmt"
type cat string
//String from type cat always meows
func (c cat) String() string {
return fmt.Sprintf("A Cat always Meows")
}
@kanapuli
kanapuli / circle.go
Last active September 11, 2017 02:27
main.go for type aliases example
package circle
@kanapuli
kanapuli / circle.go
Created September 11, 2017 02:43
Type Alias main.go after refactoring
package circle
import "github.com/err/square"
//CircleShape is the typealias for square.Shape
type CircleShape = square.Shape
package authentication
//config.go has all the configuration constants
//The following has the slack constants
const (
slackClientID = "6XXXXXXXXXXXXXXXXOOOOOOOOOOOOOOO"
slackClientSecret = "xxxxxxxxxxxxa2ffexxxxxxxxxxxxxxx"
slackAuthURL = "https://slack.com/oauth/authorize"
slackTokenURL = "https://slack.com/api/oauth.access"
package authentication
//SlackAuth responses back the Login URL
func (LoginService) SlackAuth(ctx context.Context) (redirectURL string, err error) {
conf := &oauth2.Config{
ClientID: slackClientID,
ClientSecret: slackClientSecret,
Scopes: slackScopes,
Endpoint: oauth2.Endpoint{
AuthURL: slackAuthURL,
{
"redirectURL": "https://slack.com/oauth/authorize?access_type=offline&client_id=6xxxvvv.28976558208&response_type=code&scope=identity.basic&state=state",
"error": ""
}