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
//SlackSignIn gives the Authentication token in return to the code
func (LoginService) SlackSignIn(ctx context.Context, code string) (token SlackTokenResponse, err error) {
conf := &oauth2.Config{
ClientID: slackClientID,
ClientSecret: slackClientSecret,
Scopes: slackScopes,
Endpoint: oauth2.Endpoint{
AuthURL: slackAuthURL,
TokenURL: slackTokenURL,
{
"AccessToken": "xoxp-827479-624459-260853-a4291948ksjkjdksdds6df5511ea",
"Expiry": "0001-01-01T00:00:00Z",
"RefreshToken": "",
"TokenType": ""
}
//Elastic match_all gives all records
{
"query": {
"match_all": {
"boost":1.5
}
}
}
//size retrieves only 10 documents back
{
"size": 10,
"query": {
"match_all": {}
}
}
//This brings the record from 100th document and gets the next 100 document
{
"query": {
"match_all": {},
"from": 100,
"size": 100
}
}
//sort query sorts the document based on the field specified
{
"query": {
"match_all": {},
"sort": [
{
"id": {
"order": "desc"
}
},
{
"_source":["id","name"],
"query":{
"match_all":{}
}
}
//match query retrieves all documents which has a title like 'Japan%'
{
"_source":["id","name"],
"query":{
"match":{
"title": "Japan"
}
}
}
//AND operation syntax
{
"query":{
"bool":{
"must":[]
}
}
}
//OR operation syntax
@kanapuli
kanapuli / find-old-branches.sh
Created July 12, 2019 08:13 — forked from mroderick/find-old-branches.sh
A small script to find stale branches
#!/bin/bash
# This is a very naive script, it doesn't do grouping and returns all branches
# I only really care about branches that have not seen commits in two months
#
# I am hoping to find some time to write a tool that can output these reports for me
# In the meantime, I am using this
echo "Merged branches"
for branch in `git branch -r --merged | grep -v HEAD`;do echo -e `git log --no-merges -n 1 --format="%ci, %cr, %an, %ae, " $branch | head -n 1` \\t$branch; done | sort -r