Skip to content

Instantly share code, notes, and snippets.

class Analytics constructor(
private val platforms: Set<AnalyticsPlatform>
...
) {
fun logEvent(appEvent: AppEvent) {
platforms.forEach { it.onEvent(appEvent) }
}
}
@syndarin
syndarin / 1 - ci.yml
Created May 20, 2021 19:55 — forked from tfcporciuncula/1 - ci.yml
Keeping a project dependency graph on the README up to date automatically by always generating it on CI with a GitHub Action
generate-dependency-graph:
name: Generate Dependency Graph
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
class MainActivity : AppCompatActivity() {
override fun attachBaseContext(base: Context) {
val configuration = Configuration().also {
it.setToDefaults()
}
configuration.setLocale(Locale("ru", "RU"))
@syndarin
syndarin / gist:7eb09aabbc639b44a7474f1e84472f61
Created June 24, 2020 11:47
Kotlin test class template
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
#end
#parse("File Header.java")
#if ($NAME.toString().contains("Test"))import org.junit.Assert.*
#end
class ${NAME} {
@syndarin
syndarin / gist:a472cf04af076fd2c9288ff0c4971f45
Created March 1, 2019 17:07
Run activity from Gradle task
task runActivity(dependsOn: "installDebug", type: Exec) {
workingDir "./"
commandLine 'adb', 'shell', 'am start -n package.name/.relative.path.from.package.name.ActivityName'
}
@syndarin
syndarin / .gitconfig
Created July 7, 2016 12:58 — forked from robmiller/.gitconfig
Some useful Git aliases that I use every day
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
private static String getHexBytesString(byte[] bytes) {
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02X ", b));
}
return sb.toString();
}
#!/bin/bash
service=dropbox-lnx.x86_64-3.20.1
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running, all is well"
else
.dropbox-dist/dropboxd &
fi
@syndarin
syndarin / CurlLoggingInterceptor.java
Created January 17, 2016 20:40 — forked from jgilfelt/CurlLoggingInterceptor.java
An OkHttp interceptor that logs requests as curl shell commands
/*
* Copyright (C) 2016 Jeff Gilfelt.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package main;
public class Main {
private static double getDistanceKm(double lat1, double lon1, double lat2, double lon2){
double latRad1 = lat1 * Math.PI / 180;
double lonRad1 = lon1 * Math.PI / 180;
double latRad2 = lat2 * Math.PI / 180;
double lonRad2 = lon2 * Math.PI / 180;