Skip to content

Instantly share code, notes, and snippets.

View evanhalley's full-sized avatar

Evan Halley evanhalley

View GitHub Profile
@evanhalley
evanhalley / designer.html
Created September 27, 2014 02:22
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
@evanhalley
evanhalley / send-gcm.php
Created January 21, 2015 23:53
A PHP script that will send a Google Cloud Messenger push message to 1 or more Android devices.
#!/usr/bin/php
<?php
// your Google Cloud Messenger API Key
$gcm_api_key = 'YOUR_API_KEY';
// array of registration IDs from Android devices (recipients of your push message)
$registration_ids = array('REGISTRATION_ID1', 'REGISTRATION_ID2');
// data to be sent to the Android device
@evanhalley
evanhalley / MainActivity.java
Last active October 26, 2016 01:54
An example for the Cary Android Developer Study Jam on using the LocalBroadcastManager.
package com.example.android.localbroadcastmanager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
@evanhalley
evanhalley / MainActivity.java
Created March 6, 2015 01:41
Implementing onSavedInstanceState.
package com.example.android.sampleform;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
/**
* Demonstrates the activity lifecycle and saving data before the activity is destroyed
*/
@evanhalley
evanhalley / verify.js
Last active August 23, 2018 07:35
Using JavaScript / Node.js to do server side IAB signature verification
var crypto = require('crypto');
// the Base64 encoded Google Play license key / Base64-encoded RSA public key from the Google Play Dev Console
var publicKey = "ABCEDF1234....";
/** sample
{
"orderId":"12999763169054705758.1371079406387615",
"packageName":"com.example.app",
"productId":"exampleSku",
/*
* Copyright (C) 2016 Evan Halley
*
* 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
public class ConnectionStreamDetectionExample {
/**
* Returns the correct input stream based on the content encoding
* @param connection
* @return
* @throws IOException
*/
private static InputStream getInputStream(HttpURLConnection connection) throws IOException {
InputStream inputStream = null;
/**
* Interface for interacting with a media player
* Created by evanhalley on 11/18/15.
*/
public abstract class MediaPlayer {
protected PremoMediaPlayerListener mMediaPlayerListener;
protected ProgressUpdateListener mProgressUpdateListener;
public MediaPlayer(PremoMediaPlayerListener mediaPlayerListener,
/**
* Plays media playback on the device audio output
* Created by evanhalley on 11/18/15.
*/
public class LocalMediaPlayer extends MediaPlayer implements ExoPlayer.Listener,
ProgressUpdateListener {
private static final String TAG = LocalMediaPlayer.class.getSimpleName();
private static final int ALLOCATION_SIZE = 65_535;
private static final int BUFFER_SIZE = 10 * 1_024 * 1_024;
@evanhalley
evanhalley / MainActivity.java
Created February 15, 2017 16:13
Implementing logic to listen for proximity echos in Android Things
package com.emuneee.parkright;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import com.google.android.things.pio.Gpio;
import com.google.android.things.pio.GpioCallback;
import com.google.android.things.pio.PeripheralManagerService;