Skip to content

Instantly share code, notes, and snippets.

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

Esa Firman esafirm

🏠
Working from home
View GitHub Profile
@evancz
evancz / union-types.md
Last active March 12, 2018 13:14
Imagine conversations and questions for a time when people say "union type" instead of "algebraic data type". Think about how the responses might work if you said "ADT" instead.

Union Types

If Elm community is going to begin referring to "union types" instead of "algebraic data types" we should think about how that will work in practice. What discussions will we have? Will we find ourselves in awkward spots trying to explain things?

The following question/answer pairs simulate things I'd expect to see in a world of "union types". The pairs are grouped by what background I expect the questions to come from so we know the subtext. I have also added some meta comments in italic to explain my phrasing.

One thing to consider is that a lot of learners will not have a person to ask, so the path to arriving at these answers needs to be easy if you are just searching online.

General Questions

package com.squareup.leakcanary
import android.app.Application
import com.bugsnag.android.Client
import com.bugsnag.android.MetaData
import com.bugsnag.android.Severity.ERROR
import com.squareup.leakcanary.BugsnagLeakUploader.ReportType.FAILURE
import com.squareup.leakcanary.BugsnagLeakUploader.ReportType.LEAK
import com.squareup.leakcanary.BugsnagLeakUploader.ReportType.NOT_FOUND
import com.squareup.leakcanary.BugsnagLeakUploader.ReportType.WONT_FIX_LEAK
@cr7pt0gr4ph7
cr7pt0gr4ph7 / README.md
Last active October 13, 2019 15:02
Gradle Dependency Resolution

Gradle Dependency Resolution

Normal Gradle behavior

The default behavior of Gradle to pick the newest version also applies if a lower version has been declared locally, but another dependency transitively pulls in a newer version. This is in contrast with Maven, where a locally declared version will always win.

For example, if your build.gradle specifies the dependency org.springframework:spring-tx:3.2.3.RELEASE, and another dependency declares 4.0.5.RELEASE as a transitive dependency, then 4.0.5.RELEASE will take precedence:

dependencies {
    compile("org.springframework.data:spring-data-hadoop:2.0.0.RELEASE")
    compile("org.springframework:spring-tx:3.2.3.RELEASE")

// will select org.springframework:spring-tx:4.0.5.RELEASE

apply from: "../jacoco.gradle"
def debugTree = fileTree(dir: "${buildDir}/intermediates/packaged-classes/flavorUnsigned", includes: includeFileFilter, excludes: excludeFileFilter)
def kotlinDebugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/flavorUnsignedDebug", includes: includeFileFilter, excludes: excludeFileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
task jacocoTestReport(type: JacocoReport, dependsOn: ['testFlavorUnsignedDebugUnitTest', 'assembleDebug']) {
reports {
xml.enabled = true
@ndbroadbent
ndbroadbent / ci_cache
Last active September 2, 2020 12:15
A powerful CI caching tool for Google Cloud Storage
#!/bin/bash
set -e
# CI Cache Script for Google Cloud Storage
# TIP: Set CI_CACHE_VERBOSE=true while testing the script
# to show a list of all files that are compressed/extracted.
# Note that you might see "tar: write error" if there are too many
# files in the verbose output.
@konmik
konmik / gist:6ac725fa7134402539c4
Last active September 8, 2020 21:36
Dagger 2 injection with inheritance
/**
* This class allows to inject into objects through a base class,
* so we don't have to repeat injection code everywhere.
*
* The performance drawback is about 0.013 ms per injection on a very slow device,
* which is negligible in most cases.
*
* Example:
* <pre>{@code
@chrisbanes
chrisbanes / KotterKnife.kt
Last active February 7, 2021 15:25
LifecycleAware KotterKnife
package kotterknife
import android.app.Activity
import android.app.Dialog
import android.app.DialogFragment
import android.app.Fragment
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.OnLifecycleEvent
import cv2
import numpy as np
canny = rho = threshold = minLen = maxGap = None
def draw():
lines = cv2.HoughLinesP(canny, rho, np.pi / 180,
threshold, None, minLen, maxGap)
dst = cv2.cvtColor(canny, cv2.COLOR_GRAY2BGR)
@gpeal
gpeal / build.gradle
Created May 22, 2018 02:01
Airbnb Gradle Flavors
...
apply from: './flavors.gradle'
...
android {
buildTypes {
productFlavors {
project.flavors.each { flavor, config ->
"$flavor" {
dimension 'scope'
if (flavor != 'full') {
@offirgolan
offirgolan / unwatch-gh-org.js
Created August 2, 2017 05:57
Unwatch All Org Repos
// Navigate to https://github.com/watching and then run:
// Taken from: https://stackoverflow.com/questions/11043374/how-to-unwatch-multiple-repos-easily-on-github
Array.prototype
.slice.apply(document.querySelectorAll('.js-subscription-row'))
.forEach(el => { const org = el.querySelector('a[href^="/YOUR_ORG"]'); if (org) el.querySelector('button').click()});