Skip to content

Instantly share code, notes, and snippets.

@orip
orip / build.gradle
Last active April 19, 2016 11:56
ProGuard rules for using Dagger 1.1.0 with gradle.
dependencies {
def dagger_version = "1.1.0"
compile "com.squareup.dagger:dagger:${dagger_version}"
compile "com.squareup.dagger:dagger-compiler:${dagger_version}"
}
@orip
orip / build.gradle
Created October 7, 2013 17:52
Define an Android app's versionName and versionCode from git tags. http://orip.org/2013/10/versioning-android-apps-with-git-tags.html
android {
def gitTag = {
def tagMatchOptions
try {
tagMatchOptions = "--match ${tagToBuildFrom}"
} catch (MissingPropertyException) {
tagMatchOptions = ""
}
"git describe --exact HEAD ${tagMatchOptions}".execute().text.trim()
}()
@orip
orip / AlarmHelper.java
Last active December 24, 2015 22:49
AlarmHelper that helps scheduling repeating non-wakeup inexact alarms. Define how to create the pending intent (e.g. getBroadcast vs getService), the alarm interval, and the first delay.
package com.example;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.util.Log;
/**
@orip
orip / AnimationUtils.java
Last active December 25, 2015 02:09
Helper to simulate withEndAction in NineOldAndroids http://nineoldandroids.com/
package com.example;
import com.nineoldandroids.animation.Animator;
/*
* animate(view).alpha(0).setListener(AnimationUtils.withEndAction(new Runnable() {
* public void run() {
* view.setVisibility(View.GONE);
* view.setAlpha(1); // restore alpha
* }
@orip
orip / AndroidPrivateFileGuavaAdapter.java
Last active August 29, 2015 14:03
Adapt between Android's Context.openFile{Input,Output} and its mode support, and Guava's sinks and sources.
// Available under the MIT license, http://opensource.org/licenses/MIT
/**
* Adapt between Context's file input/output streams and Guava's sinks and sources.
*
* This supports file modes.
*
* Usage:
* ByteSink sink =
* new AndroidPrivateFileGuavaAdapter(
* "foo", Context.MODE_PRIVATE, context).asByteSink();
import com.google.common.io.CharStreams;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Zero error checking or recovery. Apologies.
*
* Requires the READ_LOGS permission.

Keybase proof

I hereby claim:

  • I am orip on github.
  • I am orip (https://keybase.io/orip) on keybase.
  • I have a public key whose fingerprint is 9CA5 31A3 696E BD84 88BC 5BED AC4C 56E0 A3A1 8161

To claim this, I am signing this object:

CXX=clang++
# suppress all warnings :-(
CXXFLAGS=-std=c++11 -stdlib=libc++ -Iapi -w
TARGET=pict
all:
$(CXX) $(CXXFLAGS) api/*cpp cli/*cpp -o $(TARGET)
test:
cd test; perl test.pl ../$(TARGET) rel.log
@orip
orip / rel.log.failures
Created November 19, 2015 08:10
PICT test failure w/clang++
EXP: 0 ACT: 2 bug020.txt /d:` /v
EXP: 0 ACT: 0.0078125 clus011.txt /o:5 /v
Seeding failure clus019.txt /v /r /e:.stdout
Seeding failure clus023.txt /d:space /v /r /e:.stdout
EXP: 0 ACT: 0.0078125 clus024.txt /d:space /v
EXP: 0 ACT: 0.0078125 clus024.txt /O:3 /d:space /v
Seeding failure clus100.txt /o:2 /v /r /e:.stdout
Seeding failure clus100.txt /o:3 /v /r /e:.stdout
Seeding failure clus101.txt /o:2 /v /r /e:.stdout
EXP: 0 ACT: 0.0078125 clus102.txt /o:1 /v
@orip
orip / gist:adb3d6275e9f06976bfdee137ac1b50b
Created December 8, 2016 14:59
auto-closing vim plugins
https://github.com/cohama/lexima.vim
https://github.com/LucHermitte/lh-brackets
https://github.com/rstacruz/vim-closer
https://github.com/jiangmiao/auto-pairs
https://github.com/Raimondi/delimitMate