Skip to content

Instantly share code, notes, and snippets.

View caseykulm's full-sized avatar
🔲

Casey Kulm caseykulm

🔲
View GitHub Profile
import timber.log.Timber
object Klocky {
private val tagToLastTimeMap = mutableMapOf<String, Long>()
@JvmOverloads
fun stamp(tag: String, message: String = "", restart: Boolean = false) {
val currTime = System.currentTimeMillis()
if (restart) tagToLastTimeMap.remove(tag)
import arrow.optics.Lens
import arrow.optics.optics
@optics data class Street(val number: Int, val name: String) { companion object }
@optics data class Address(val city: String, val street: Street) { companion object }
@optics data class Company(val name: String, val address: Address) { companion object }
@optics data class Employee(val name: String, val company: Company) { companion object }
fun main() {
withCopy()
@caseykulm
caseykulm / ngrams.py
Last active July 16, 2019 16:40
Find the most common n-grams in an input string
# Adapted from this SO post https://stackoverflow.com/a/14670769/1229735
from collections import Counter
counter = Counter()
text = '' # Put your text here. It helps to prune stuff from the input that you consider noise.
min_substring_length = 7
max_substring_length = 15 # len(text) + 1 # for max length
ytho
@caseykulm
caseykulm / main.md
Last active June 6, 2023 18:25
Guava ListenableFuture Hell

Guava ListenableFuture Hell

Problem

Duplicate jar entry [com/google/common/util/concurrent/ListenableFuture.class]

Caused by having,

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/4.0.1/redux.js"></script>
<title>JS Bin</title>
</head>
<body>
public class DebugUtils {
public static void logCurrentStackTrace(Thread thread) {
List<StackTraceElement> traceElements = Arrays.asList(thread.getStackTrace());
Timber.d("StackTrace: START");
for (StackTraceElement traceElement : traceElements) {
Timber.d("\tStackTrace: %30s#%20s line: %4d",
traceElement.getClassName(),
traceElement.getMethodName(),
traceElement.getLineNumber());
@caseykulm
caseykulm / LaunchExample.java
Created January 29, 2018 20:03
Launch Multiple Activities in sequence - https://stackoverflow.com/a/10807848/1229735
public class LaunchExample {
public void launchManyActivities() {
Intent i = new Intent(this, A.class);
i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i);
Intent j = new Intent(this, B.class);
j.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(j);
android {
lintOptions {
// Severity Overrides
warning (
// These are errors by default
"OnClick",
"MissingPermission",
"MissingSuperCall",
"GradleCompatible",
"GradlePluginVersion",
@caseykulm
caseykulm / AndroidManifest.xml
Created January 15, 2018 17:27
AndroidManifest.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest package="com.company.app"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:networkSecurityConfig="@xml/network_security_config" />
</manifest>