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
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
*/
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
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;
/*
* 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
@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;
@evanhalley
evanhalley / save_image.py
Last active May 21, 2017 02:40
Saves an image (jpg) given a url
import sys
import urllib
import time
url = sys.argv[1]
directory = sys.argv[2]
destination = directory + "/" + str(time.time()) + ".jpg"
print 'Saving image from url ', url, ' to ', destination
urllib.urlretrieve(url, destination)