Skip to content

Instantly share code, notes, and snippets.

View kenyee's full-sized avatar

Ken Yee kenyee

View GitHub Profile
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@ContextDsl
fun Route.coGet(path: String, block: suspend ApplicationCall.() -> ServerResponse): Route = get("/") {
val result = call.block()
when (result) {
is ServerResponse.Empty ->
call.respondText { "" }
is ServerResponse.Json ->
call.respondText(result.jsonString, ContentType.Application.Json)
fun Route.coHandler(controller: suspend RoutingContext.() -> ServerResponse): Route =
handler {
launch(it.vertx().dispatcher()) {
val response = it.controller()
when (response) {
is ServerResponse.Empty ->
it.response().end()
is ServerResponse.Json ->
import React from 'react'
import PropTypes from 'prop-types'
import { Formik } from 'formik'
import Dialog, {
DialogActions,
DialogContent,
DialogContentText,
DialogTitle
} from 'material-ui/Dialog'
import Button from 'material-ui/Button'
@trobalik
trobalik / FlakyTests.java
Created June 2, 2016 21:49
Flaky Espresso Tests and the RetryTestRule
package com.yourapp.test;
// import statements...
public class FlakyTests {
@Rule
RetryTestRule retry = new RetryTestRule(3); // will attempt each test up to 3 times
@Test
// Disable VirtualBox authentication
VBoxManage setproperty websrvauthlibrary null
// Start SOAP service so REX-Ray can talk to VirtualBox from the container host VMs
/Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv -H 0.0.0.0 -v
// Create a Swarm cluster
docker-machine create --driver=virtualbox default
eval $(docker-machine env default)
TOKEN=$(docker run --rm swarm create)
@efrohnhoefer
efrohnhoefer / ApiMetricsInterceptor.java
Created April 5, 2016 22:55
Code demonstrating how to measure API performance using Answers and OkHttp 2.2+.
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
@jgilfelt
jgilfelt / CurlLoggingInterceptor.java
Created January 9, 2016 15:34
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
@milosmns
milosmns / Coloring.java
Last active November 23, 2023 06:06
Android: Coloring (Helper Class)
package me.angrybyte.coloringdemo;
/**
* IMPORTANT NOTICE
*
* This is now a part of SillyAndroid https://github.com/milosmns/silly-android,
* with new fixes and improvements.
*/