Skip to content

Instantly share code, notes, and snippets.

Avatar
🚴

Merab Tato Kutalia tatocaster

🚴
View GitHub Profile
@tatocaster
tatocaster / detekt.gradle
Created Feb 25, 2021
Detekt gradle tasks for multi-module project
View detekt.gradle
// add classpath dependency before
// classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion"
def configFile = files("$rootDir/config/detekt/detekt.yml")
def baselineFile = file("$rootDir/config/detekt/baseline.xml")
def analysisDir = file(projectDir)
def kotlinFiles = "**/*.kt"
def javaFiles = "**/*.java"
def resourceFiles = "**/resources/**"
View EspressoTest.kt
@Test
fun labelsAreDisplyed_SameFragment() {
// some other assertions
onView(withId(R.id.tvAccountNumberLabel))
.perform(nestedScrollTo())
.check(matches(isDisplayed()))
// here as well
}
@tatocaster
tatocaster / EspressoNestedScroll.kt
Created Aug 9, 2020
Nested Scroll View Espresso scroll viewaction
View EspressoNestedScroll.kt
fun nestedScrollTo(): ViewAction {
return object : ViewAction {
override fun getConstraints(): Matcher<View> {
return CoreMatchers.allOf(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE),
ViewMatchers.isDescendantOfA(CoreMatchers.anyOf(
ViewMatchers.isAssignableFrom(ScrollView::class.java),
ViewMatchers.isAssignableFrom(HorizontalScrollView::class.java),
ViewMatchers.isAssignableFrom(NestedScrollView::class.java)))
)
}
@tatocaster
tatocaster / main.go
Created Jun 17, 2020
full script for Slack and Garmin integration
View main.go
package main
import (
"encoding/json"
"fmt"
"github.com/slack-go/slack"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/gmail/v1"
@tatocaster
tatocaster / main.go
Created Jun 17, 2020
set slack status
View main.go
func setSlackStatus() {
api := slack.New(SlackAccessToken, slack.OptionDebug(false))
expirationTime := time.Now().Add(time.Hour * time.Duration(3)).Unix()
err := api.SetUserCustomStatus("Gone Cycling", "🚴🏻‍♂️", expirationTime)
if err != nil {
log.Fatalf("Unable to set status : %v", err)
}
err = api.SetUserPresence("away")
if err != nil {
log.Fatalf("Unable to set presence : %v", err)
@tatocaster
tatocaster / main.go
Created Jun 17, 2020
fetch messages from Gmail
View main.go
func getLastMessageId(srv *gmail.Service) string {
r, err := srv.Users.Messages.List(user).MaxResults(100).Q("to:testuser+garminlivetrack@gmail.com is:unread").Do()
if err != nil {
log.Fatalf("Unable to retrieve messages: %v", err)
}
if len(r.Messages) == 0 {
fmt.Println("No messages found.")
os.Exit(1)
}
return r.Messages[len(r.Messages)-1].Id
@tatocaster
tatocaster / distributed_factorial.go
Created May 21, 2020
concurrent calculation of factorial in golang
View distributed_factorial.go
package main
import (
"fmt"
"math/big"
"runtime"
"time"
)
type computationRange struct {
@tatocaster
tatocaster / randomEmail.dart
Created Dec 18, 2019
select random from set
View randomEmail.dart
import 'dart:math';
void main() {
var _emailSet = new Set.from([
'',
''
]);
final _random = new Random();
@tatocaster
tatocaster / DesignPatterns.java
Last active Nov 27, 2019
Hello World using design patterns
View DesignPatterns.java
// https://developers.slashdot.org/comments.pl?sid=33602&cid=3636102
public interface MessageStrategy {
public void sendMessage();
}
public abstract class AbstractStrategyFactory {
public abstract MessageStrategy createStrategy(MessageBody mb);
}
public class MessageBody {
View MainActvity.java
setContentView(LithoView.create(this,
ListItem.create(mComponentContext)
.title("My Title")
.subtitle("SubTitle")
.listener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Clicked", Toast.LENGTH_SHORT).show();
}
})