Skip to content

Instantly share code, notes, and snippets.

View afollestad's full-sized avatar
📱

Aidan Follestad afollestad

📱
View GitHub Profile
@ZacSweers
ZacSweers / RxJava.md
Last active September 3, 2018 18:52 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
import android.graphics.Typeface
import androidx.annotation.CheckResult
import java.lang.Exception
/** @author Aidan Follestad (@afollestad) */
object TypefaceHelper {
private val cache = hashMapOf<String, Typeface>()
/**
* Gets a typeface by its family name. Automatically statically caches it to avoid
class CommandLineParser(
private val input: String
) : Iterator<String> {
private var lastIndex: Int = 0
override fun hasNext(): Boolean = lastIndex in 0..input.length - 2
override fun next(): String {
val value = StringBuilder()
var quoteStarter: Char? = null
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
package com.afollestad.flow.util
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.Unconfined
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
@rafali
rafali / ResizeAnimation.java
Last active February 26, 2021 13:05
Resize animation on Android
public class ResizeAnimation extends Animation {
final int startWidth;
final int targetWidth;
View view;
public ResizeAnimation(View view, int targetWidth) {
this.view = view;
this.targetWidth = targetWidth;
startWidth = view.getWidth();
}
@jordansinger
jordansinger / lil-dice.tsx
Created October 19, 2021 19:43
lil dice FigJam widget
const { widget } = figma
const { Rectangle, AutoLayout, Frame, Text, useSyncedState, usePropertyMenu, useEffect, Ellipse } = widget
function Dot(props) {
let visible = props.visible
return (
<Ellipse
opacity={visible ? 1 : 0}
width={24}
height={24}
@navsing
navsing / clubhouse.swift
Created February 11, 2021 21:22
Recreating ClubHouse in SwiftUI with Dark Mode
//
// Clubhouse.swift
// Playground
//
// Created by Nav Singh on 2/11/21.
//
import SwiftUI
struct Clubhouse: View {
@RussellCollins
RussellCollins / example_permission_setter.sh
Created December 2, 2015 08:56
Set write and read external storage permission prior to a test run so that a screenshot on fail listener can work on device targets running Android 6.0+
SDK=`adb shell getprop ro.build.version.sdk | tr -d '\r'`
echo "Device SDK level is: " $SDK
if (( "$SDK" >= 23 )) ; then
echo "Enabling read and write external storage permissions before running tests on Android 6.0+"
adb shell pm grant com.replace.with.your.app.package android.permission.WRITE_EXTERNAL_STORAGE
adb shell pm grant com.replace.with.your.app.package android.permission.READ_EXTERNAL_STORAGE
fi
@pditommaso
pditommaso / gist:2265496
Created March 31, 2012 14:26
Read/write input/output stream of interactive process
import java.io.*;
public class TestProcessIO {
public static boolean isAlive(Process p) {
try {
p.exitValue();
return false;
}
catch (IllegalThreadStateException e) {
@wbroek
wbroek / genymotionwithplay.txt
Last active February 12, 2024 03:22
Genymotion with Google Play Services for ARM
NOTE: Easier way is the X86 way, described on https://www.genymotion.com/help/desktop/faq/#google-play-services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)