Skip to content

Instantly share code, notes, and snippets.

View SeanPONeil's full-sized avatar

Sean O'Neil SeanPONeil

  • LogicGate
  • Ann Arbor, Michigan
View GitHub Profile

Keybase proof

I hereby claim:

  • I am seanponeil on github.
  • I am seanponeil (https://keybase.io/seanponeil) on keybase.
  • I have a public key ASDDvmJwXIYfULVamNP0aqsGQJCIXwXqn_haFHhrGSqmxgo

To claim this, I am signing this object:

class Node {
char data;
Node next;
}
static Node reverse(Node root){
Node reverseRoot = null;
while(root != null) {
Node next = root.next;
root.next = reverseRoot;

Keybase proof

I hereby claim:

  • I am seanponeil on github.
  • I am seanponeil (https://keybase.io/seanponeil) on keybase.
  • I have a public key whose fingerprint is 6C46 0325 A379 C763 EF36 C51B 32BE 39C5 558F 19A6

To claim this, I am signing this object:

@SeanPONeil
SeanPONeil / receiveNotification.java
Last active August 29, 2015 13:59
receiveNotification
public class NotificationActionReceiver extends WakefulBroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
String action = intent.getStringExtra("action");
int id = intent.getIntExtra("id");
switch (action) {
case "Approve":
// Start service to approve transaction and hold wake lock
Intent approveIntent = new Intent("com.example.app.ApproveService");
intent.putExtra("id", id);
@SeanPONeil
SeanPONeil / displayNotification.java
Last active August 29, 2015 13:59
displayExpandedNotificationWithMultipleActions
public void displayNotification(String title, String message, int smallIcon, int largeIcon) {
// Create PendingIntent that launches an activity
Intent intent = new Intent(getContext(), LoginRequestActivity.class);
PendingIntent activityIntent = PendingIntent.getActivity(getContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);
// Build the notification
Notification notification = new NotificationCompat.Builder()
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(smallIcon)
@SeanPONeil
SeanPONeil / displayNotificationWithOneAction.java
Last active August 29, 2015 13:59
displayNotificationWithOneAction
public void displayNotification(String title, String message, int icon, int id) {
// Create PendingIntent that launches an activity
Intent intent = new Intent(getContext(), LoginRequestActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);
// Build the notification
Notification notification = new NotificationCompat.Builder()
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(icon)
@SeanPONeil
SeanPONeil / displayNotificationWithAction.java
Last active August 29, 2015 13:58
Display Notification with actions
public void displayNotificationWithActions() {
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle("New Message")
.setContentText("You've received new messages.")
.setSmallIcon(R.drawable.ic_notify_status);
// Create Pending Intent that broadcasts an Intent
Intent intent = new Intent(context.getPackageName() + ".READ_MESSAGE");
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
@SeanPONeil
SeanPONeil / displayNotification.java
Last active August 29, 2015 13:58
displayNotification
public void displayNotification() {
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle("New Message")
.setContentText("You've received new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
mNotificationManager.notify(
notifyID, mNotifyBuilder.build());
}
@SeanPONeil
SeanPONeil / PRNGstacktrace.txt
Created August 20, 2013 15:04
Stacktrace when using Google's SecureRandom PRNG patch (http://android-developers.blogspot.com/2013/08/some-securerandom-thoughts.html) with Robolectric
java.lang.RuntimeException: java.lang.SecurityException: Failed to seed OpenSSL PRNG
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:231)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
private static String parseVals(String key, String val, String prefix) throws InvalidKeyException, NoSuchAlgorithmException, IOException {
long ts = System.currentTimeMillis() / 1000;
String[] parts = val.split("\\|");
String u_prefix = parts[0];
String u_b64 = parts[1];
String u_sig = parts[2];
String sig = Util.hmacSign(key, u_prefix + "|" + u_b64);
if (!Util.hmacSign(key, sig).equals(Util.hmacSign(key, u_sig))) {