Skip to content

Instantly share code, notes, and snippets.

View ericwoodruff's full-sized avatar

Eric Woodruff ericwoodruff

View GitHub Profile
@ericwoodruff
ericwoodruff / gist:6335659
Last active December 21, 2015 16:48
Android Async Task Loader with Exceptions
public interface Catchable<V, T extends Throwable> {
V getValue () throws T;
}
public class CatchableException<V, T extends Throwable> implements Catchable<V, T> {
public CatchableException (T throwable) {
this.throwable = throwable;
}
@Override
@ericwoodruff
ericwoodruff / gist:6335774
Created August 25, 2013 19:31
Open many files in vim tabs
function pipevi () {
xargs -d'\n' bash -c '</dev/tty vim -p "$0" "$@"'
}
find -name "*.xml" | pipevi
grep -rl lib | pipevi
@ericwoodruff
ericwoodruff / gist:6335788
Created August 25, 2013 19:35
Add Gist to Blogger
<script src="https://raw.github.com/moski/gist-Blogger/master/public/gistLoader.js" type="text/javascript"></script>
<div class="gistLoad" data-id="6335659" id="gist-GistID">Loading ....</div>
@ericwoodruff
ericwoodruff / gist:6335800
Created August 25, 2013 19:37
Azilink network interfaces config
iface tun0 inet manual
pre-up adb forward tcp:41927 tcp:41927
openvpn azilink
dns-nameservers 192.168.56.1
@ericwoodruff
ericwoodruff / gist:6335818
Created August 25, 2013 19:40
forever doless
function forever () { while [ TRUE ]; do "$@"; done}
function doless () {
"$@" 2>&1 | tee /dev/stderr | less —buffers=-1 —chop-long-lines —shift 16 —RAW-CONTROL-CHARS —quit-on-intr +G
}
@ericwoodruff
ericwoodruff / gist:6335853
Created August 25, 2013 19:45
xmodmap key rotation for programmers
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Tab
keysym Tab = Escape
add Lock = Caps_Lock
@ericwoodruff
ericwoodruff / thermonitor.rb
Created September 1, 2013 01:19
radiothermostat auto-away
#!/usr/bin/ruby
require 'rest-client'
require 'json'
require 'open-uri'
require 'xmlsimple'
INTERVAL=30
THRESHOLD=10
@ericwoodruff
ericwoodruff / ProgressToast.java
Last active December 22, 2015 02:18
Android progress/status long duration toast with catchable async task loader
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.CountDownTimer;
import android.widget.Toast;
@SuppressLint({ "ViewConstructor", "ShowToast" })
public class ProgressToast {
public ProgressToast (Activity context, String text) {
this.context = context;
@ericwoodruff
ericwoodruff / SyncState.java
Created September 25, 2013 23:20
SyncStates for an Android SyncAdapter
public static enum SyncState {
none,
create,
read,
update,
delete,
creating,
reading,
updating,
deleting,
@ericwoodruff
ericwoodruff / SampleEnum.java
Created November 20, 2013 03:13
Column enum
public static enum Column {
_id ("INTEGER PRIMARY KEY"),
sync_state ("STRING NOT NULL DEFAULT 'none'"),
user_id ("LONG NOT NULL"),
...
;
}