Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Hammond patrickhammond

View GitHub Profile
@patrickhammond
patrickhammond / main.dart
Last active Dec 16, 2019
polygon generator
View main.dart
import 'dart:math';
// -----------------------------------
// -----------------------------------
// These are the values that you will want to adjust before hitting run.
// Take note that this is in a lat/long order (what you would normally get from Google Maps, etc)
const centerPoint = [39.1094384, -84.5094552];
// 1 mile
View reply.xml
Thanks! If you want me to stop reminding you, reply with STOP.
View keybase.md

Keybase proof

I hereby claim:

  • I am patrickhammond on github.
  • I am patrickhammond (https://keybase.io/patrickhammond) on keybase.
  • I have a public key whose fingerprint is 6C11 873C A480 C6FC 14C4 E534 7453 02C8 2C35 C49A

To claim this, I am signing this object:

@patrickhammond
patrickhammond / MainActivity.kt
Last active Jan 21, 2017
Motor controlled via L293D.
View MainActivity.kt
package com.madebyatomicrobot.things
import android.app.Activity
import android.os.Bundle
import android.util.Log
import com.google.android.things.pio.Gpio
import com.google.android.things.pio.PeripheralManagerService
import java.io.IOException
@patrickhammond
patrickhammond / MainActivity.kt
Created Jan 9, 2017
Raspberry Pi 3 running Android Things driving an Arduino Uno to control an RGB LED
View MainActivity.kt
package com.madebyatomicrobot.things
import android.app.Activity
import android.os.Bundle
import android.util.Log
import android.widget.SeekBar
import android.widget.SeekBar.OnSeekBarChangeListener
import android.widget.TextView
import com.google.android.things.pio.PeripheralManagerService
import com.google.android.things.pio.UartDevice
@patrickhammond
patrickhammond / MainActivity.java
Created Jan 5, 2017
First tinkering with Android Things on a Raspberry Pi. Demo video: https://goo.gl/photos/R6oZmnqS8XBmTNx58
View MainActivity.java
package com.example.androidthings.myproject;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
@patrickhammond
patrickhammond / 0_no.java
Created Nov 9, 2016
Correctly managing realm results that also have an associated change listener.
View 0_no.java
private void setupChangeListener() {
RealmResults<Unique> results = realm.where(Something.class).findAll();
handleResults(results);
// I've tried this with the listener as an anonymous inner class and also assigning it to a
// field to ensure there isn't an issue with it being GC'd.
results.addChangeListener(new RealmChangeListener<RealmResults<Something>>() {
@Override
public void onChange(RealmResults<Something> element) {
handleResults(element);
View ParcelableHelper.java
import android.os.Parcel;
import android.os.Parcelable;
public class ParcelableHelper {
/**
* There is not always a guarantee that Parcelable values will be immediately written out and
* read back in. For data data that mutable (its own issue), this can be a problem. This is
* for the times when it would be great to have confidence that you will be working with a copy
* of that data.
View SampleJsonTest.java
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class SampleJsonTest {
private static final String SAMPLE_JSON = "{ \"first_name\": \"Atomic\", \"last_name\": \"Robot\" }";