Skip to content

Instantly share code, notes, and snippets.

/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
public class LiveDataTestUtil {
public static <T> T getOrAwaitValue(final LiveData<T> liveData) throws InterruptedException {
final Object[] data = new Object[1];
final CountDownLatch latch = new CountDownLatch(1);
Observer<T> observer = new Observer<T>() {
@Override
public void onChanged(@Nullable T o) {
data[0] = o;
@ruben-h
ruben-h / android.yml
Created October 9, 2020 12:23
Github Actions workflow for simple a Android build and test project. place the file in /.github/workflows/android.yml
name: Android CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
@ruben-h
ruben-h / AppSignatureHelper.java
Created February 18, 2019 09:41
Android Signature generator for SMS code verification
package com.google.samples.smartlock.sms_verify;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.util.Base64;
import android.util.Log;
import java.nio.charset.StandardCharsets;
@ruben-h
ruben-h / README.md
Created November 10, 2017 09:43 — forked from JamesMenetrey/README.md
Install Oh-My-Zsh + iTerm2 with Solarized + System-wide console in 2017 (macOS)

Install iTerm2 with Solarized in 2017

Here is the looks and feel of your terminal once the tutorial has been applied on your system:

Install iTerm2

Using Homebrew:

@ruben-h
ruben-h / GsonHelper.java
Created August 28, 2017 10:59 — forked from orip/GsonHelper.java
Gson type adapter to serialize and deserialize byte arrays in base64
import java.lang.reflect.Type;
import android.util.Base64;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
@ruben-h
ruben-h / ImagePicker.java
Created August 17, 2017 10:22 — forked from Mariovc/ ImagePicker.java
Utility for picking an image from Gallery/Camera with Android Intents
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@ruben-h
ruben-h / LocalBroadcastExampleActivity.java
Created August 16, 2017 07:43 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@ruben-h
ruben-h / 1. Usage.md
Created June 21, 2017 10:53 — forked from kyawkyaw/1. Usage.md
How to track the progress of any OkHttp request body. Licence: MIT

How to track the progress of any OkHttp request body

Requires OkHttp >= 2.1.0 if you need to work with multipart request bodies. Lower versions don’t report the content length for the body, but the sum of the sizes of the parts is a pretty good approximation.

// TODO: Build a request body
RequestBody body = null;
var env = require('./environment.js');
// This is the configuration file showing how a suite of tests might
// handle log-in using the onPrepare field.
exports.config = {
seleniumAddress: env.seleniumAddress,
framework: 'jasmine',
specs: [
@ruben-h
ruben-h / 01-gulpfile.js
Created May 31, 2016 12:06 — forked from markgoodyear/01-gulpfile.js
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),