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
@SeanPONeil
SeanPONeil / NodeCommentFragment.java
Created March 27, 2013 14:31
Sort Method for NodeCommentFragment
public void sort(String type){
SharedPreferences prefs = getActivity().getSharedPreferences(
getActivity().getPackageName(), Context.MODE_PRIVATE);
if(type.equals(ASC)){
prefs.edit().putString(SORT, ASC).commit();
} else {
prefs.edit().putString(SORT, DESC).commit();
}
@SeanPONeil
SeanPONeil / NodeActivity.java
Created February 9, 2013 22:35
Dual Pane layout?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.node_container);
mIsDualPane = getResources().getBoolean(R.bool.has_two_panes);
nid = getIntent().getIntExtra("nid", 0);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@SeanPONeil
SeanPONeil / .bash_prompt
Created September 13, 2012 20:05
Sexy Solarized Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Sexy Solarized Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Customized for the Solarized color scheme by Sean O'Neil
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
BASE03=$(tput setaf 234)
BASE02=$(tput setaf 235)
BASE01=$(tput setaf 240)
@SeanPONeil
SeanPONeil / coloredlogcat.py
Created August 30, 2012 14:49
script to highlight adb logcat output for console
#!/usr/bin/python
'''
Copyright 2009, The Android Open Source Project
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
@SeanPONeil
SeanPONeil / AsyncBus.java
Created August 15, 2012 19:47
Asynchronous Otto BusProvider that always posts events on the main thread
public class AsyncBus extends Bus {
private final Handler mainThread = new Handler(Looper.getMainLooper());
@Override public void post(final Object event) {
mainThread.post(new Runnable() {
@Override public void run() {
AsyncBus.super.post(event);
}
});
}
@SeanPONeil
SeanPONeil / gist:3362100
Created August 15, 2012 18:17
add a suffix to a date
static String getDayOfMonthSuffix(final int n) {
if (n >= 11 && n <= 13) {
return "th";
}
switch (n % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
@Table(name = "node_indices")
@MimeType(company = "com.atami")
@Authority(name = "com.atami.mgodroid.provider")
public class NodeIndex {
@Column(name = "name")
String name;
@Column(name = "_id")
@PrimaryKey
@SeanPONeil
SeanPONeil / NodeIndexProvider.java
Created August 2, 2012 15:55
NodeIndexProvider
public class NodeIndexProvider extends ClassContentProvider {
public static final Uri CONTENT_URI = Uri.parse("content://com.atami.mgodroid.provider/node_indices");
public NodeIndexProvider() {
provideClass(NodeIndex.class);
}
}
@SeanPONeil
SeanPONeil / BlockingIntentService.java
Last active February 15, 2021 21:59
An extension of the IntentService class that will block an Intent from entering the queue if the same Intent is already in the queue.
package com.atami.mgodroid.util;
import java.util.LinkedList;
import android.app.IntentService;
import android.content.Intent;
/**
* An extension of the IntentService class that will block
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
public class PullToRefreshListFragment extends ListFragment {