Skip to content

Instantly share code, notes, and snippets.

Greg Loesch loeschg

  • Columbus, OH
View GitHub Profile
@loeschg
loeschg / gpio.ex
Created Mar 21, 2017
Fake gpio implementation for ElixirAle
View gpio.ex
defmodule FakeAle.Gpio do
use GenServer
@moduledoc """
This is a fake Elixir interface to ElixirALE.GPIO.
Each "GPIO" is an independent GenServer.
"""
defmodule State do
@moduledoc false
@loeschg
loeschg / DateTypeAdapter.java
Last active Dec 11, 2019
Custom TypeAdapter for GSON which handles both Date and DateTime formats (ISO 8601 and a simple date format)
View DateTypeAdapter.java
package com.my.utility;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.text.DateFormat;
@loeschg
loeschg / android-snippets.md
Last active Aug 29, 2015
Android snippets
View android-snippets.md

New View/Activity/Fragment animation

private void setupAnimation(View view) {
    if (view.getViewTreeObserver().isAlive()) {
        ViewTreeObserver observer = view.getViewTreeObserver();
        observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (view.getViewTreeObserver().isAlive()) {
@loeschg
loeschg / build.gradle
Last active Aug 29, 2015
Robolectric tests are not working with double-espresso due to it not excluding espresso files. This snippet allows you to exclude Espresso resources when running Robolectric tests. More info can be found here: http://stackoverflow.com/a/24706452/413254
View build.gradle
/** Hook into existing tasks. */
tasks.whenTaskAdded { theTask ->
excludeEspressoFilesIfNecessary(theTask)
}
/**
* This excludes Espresso tests from Robolectric. http://stackoverflow.com/a/24706452/413254
*
* This was needed when using double-espresso. I couldn't get Robolectric to exclude them
* normally unless doing this. Double-espresso is used to fix a conflicting Dagger 1.2 dependency
@loeschg
loeschg / activity_main.xml
Last active Aug 29, 2015
ALG - Session 1 - activity_main.xml
View activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.weddingwire.android.learninggroup.session1.MainActivity">
@loeschg
loeschg / MainActivity.java
Last active Aug 29, 2015
ALG - Session 1 - MainActivity.java
View MainActivity.java
package com.weddingwire.android.learninggroup.session1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
* Activity to increment a textfield on button press.
@loeschg
loeschg / gist:31f9ced8437331947221
Last active Aug 29, 2015
WeddingWire: Android Learning Group
View gist:31f9ced8437331947221

Android Learning Group

##Table of Contents: 1 - Intro: Android Studio & Genymotion

#1 - Intro: Android Studio & Genymotion

Android Studio

[Android Studio][1] is a new Android development environment based on IntelliJ IDEA. It bundles all the essential Android SDK and Android IntelliJ plugins.

@loeschg
loeschg / gist:00df15fddefd3614c7d8
Created May 2, 2014
Multiple Fragments side by side
View gist:00df15fddefd3614c7d8
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012 The Android Open Source Project
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
View ImageViewTouchViewPager.java
package some.awesome.package;
import it.sephiroth.android.library.imagezoom.ImageViewTouch;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
public class ImageViewTouchViewPager extends ViewPager {
@loeschg
loeschg / Notes:Vi_IMproved-Vim.md
Last active Dec 14, 2015
Some notes from the book Vi IMproved-Vim by Steve Oualline
View Notes:Vi_IMproved-Vim.md

Vi IMproved - Vim

Notes

Table Of Contents:

Undo/redo

U       - undoes all changes to the line
You can’t perform that action at this time.