Skip to content

Instantly share code, notes, and snippets.

@joesteele
joesteele / btn_alpha_bg.xml
Last active February 5, 2021 14:58
Ripple when view has alpha background
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#66000000"/>
<corners android:radius="4dp"/>
</shape>
@joesteele
joesteele / Store.java
Last active August 29, 2015 14:06
RxJava wrappers around Ply find methods
public Observable<List<Book>> books() {
return observablePlyFind(Book.class);
}
private static <T extends Model> Observable<List<T>> observableFromPlyQueryBuilder(final QueryBuilder<T> builder) {
return Observable.create(new Observable.OnSubscribe<List<T>>() {
@Override
public void call(Subscriber<? super List<T>> subscriber) {
subscriber.onNext(builder.find());
subscriber.onCompleted();
@joesteele
joesteele / TweetActivity.java
Created April 29, 2014 19:26
Sample Activity to fetch tweets from Twitter, store them in the db, then return the results on the main thread
public class MainActivity extends ListActivity {
private TweetAdapter adapter;
private Subscription subscription;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adapter = new TweetAdapter(this);
setListAdapter(adapter);
loadTweets();
@joesteele
joesteele / eff_levels.java
Last active August 29, 2015 13:59
Example showing RxJava for synchronous operations with no subscribers.
// Example of calculating effective character level from a MUD.
// Single-classed character of level 20 would be level 20.
// Multi-classed character would gain an additional level for
// every 3 levels in their non-primary classes (primary class
// is highest level class).
// e.g. Mage: 30, Ranger: 5:, Thief: 9 # Effective Level: 34
public int effectiveLevel() {
if (classes.size() == 1) {
return classes.get(0).level;
}
@joesteele
joesteele / .zshrc
Last active August 29, 2015 13:57
Grep Android Version Name or Code
function grepversion() {
if [[ -n "$1" ]]; then
local LOOKUP=Name
local APP=$1
if [[ -n "$1" && -n "$2" ]]; then
if [[ "$1" == "code" ]]; then
LOOKUP=Code
fi
APP=$2
fi
#!/usr/bin/env ruby
require 'time'
if ARGV.size < 2
fail "Please supply shift modifier\n" +
"USAGE: ./caption_shifter <caption-input> <shift-modifier>\n" +
"EXAMPLE: ./caption_shifter html.vtt 2"
elsif ARGV.size < 1
fail "Please supply caption file\n" +
"USAGE: ./caption_shifter <caption-input> <shift-modifier>\n" +
@joesteele
joesteele / .zshrc
Created October 19, 2012 19:19
Easily open Github pages from the command line
function ghub() {
open "http://github.com/$1"
}
# Convenience aliases to open the Backbone.js repo in Github
alias ghubdb='ghub documentcloud/backbone'
alias ghubdbi='ghub documentcloud/backbone/issues'
alias ghubdbp='ghub documentcloud/backbone/pulls'
@joesteele
joesteele / .zshrc
Created October 19, 2012 19:15
Easily open Github pages from the command line
function ghub() {
open "http://github.com/$1"
}
alias ghubdf='ghub dispatchio/frontend'
alias ghubdfi='ghub dispatchio/frontend/issues'
alias ghubdfp='ghub dispatchio/frontend/pulls'
alias ghubdb='ghub dispatchio/backend'
alias ghubdbi='ghub dispatchio/backend/issues'
alias ghubdbp='ghub dispatchio/backend/pulls'