Skip to content

Instantly share code, notes, and snippets.

View patrickhammond's full-sized avatar

Patrick Hammond patrickhammond

View GitHub Profile
@patrickhammond
patrickhammond / main.dart
Last active December 16, 2019 20:44
polygon generator
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
Thanks! If you want me to stop reminding you, reply with STOP.

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 January 21, 2017 04:59
Motor controlled via L293D.
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 January 9, 2017 02:59
Raspberry Pi 3 running Android Things driving an Arduino Uno to control an RGB LED
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 January 5, 2017 04:48
First tinkering with Android Things on a Raspberry Pi. Demo video: https://goo.gl/photos/R6oZmnqS8XBmTNx58
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 November 9, 2016 14:46
Correctly managing realm results that also have an associated change listener.
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);
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.
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\" }";
find . -not -name 'ic_attachment_grey600_24dp.png' -not -type d | xargs rm