Skip to content

Instantly share code, notes, and snippets.

View mlc's full-sized avatar

mike castleman mlc

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import com.google.common.base.Joiner;
import com.google.common.primitives.Ints;
import java.util.Arrays;
public class GrimePuz {
public static void main(String[] args) {
int[] n = new int[10];
int[] counts = new int[10];
n[0] = 1;
while (n[0] < 10) {
/**
* Attempts to set copy into a TextView using the normal copy. If it ends up
* wrapping onto more than one line, uses the short copy alternative instead.
* @param textView The TextView (or Button or whatever) to setText on.
* @param normalCopyResId The preferred copy string resource id.
* @param shortCopyResId The alternate (shorter) copy string resource id.
*/
public static void maybeUseShorterCopy(final TextView textView,
@StringRes final int normalCopyResId,
@StringRes final int shortCopyResId) {
@mlc
mlc / .XCompose
Created July 7, 2015 18:41
$HOME/.XCompose
# -*- coding: utf-8; mode: conf -*-
include "%L"
<Multi_key> <s> <h> <r> <u> <g>: "¯\\_(ツ)_/¯"
<Multi_key> <s> <a> <d>: "😿"
@mlc
mlc / gist:caf2ca1bd1261b908f14
Created June 21, 2014 05:25
testing form field escaping in multipart/form-data forms
<!DOCTYPE html>
<html>
<head>
<title>multipart test</title>
<meta charset='utf-8'>
</head>
<body>
<h1>multipart test</h1>
<form action='/test' enctype='multipart/form-data' method='post'>
<p>
@mlc
mlc / OkHttpOAuthConsumer.java
Created June 10, 2014 21:40
okhttp 2.0 + oauth signpost. extremely preliminary and not guaranteed.
import com.squareup.okhttp.Request;
import oauth.signpost.AbstractOAuthConsumer;
import oauth.signpost.http.HttpRequest;
public class OkHttpOAuthConsumer extends AbstractOAuthConsumer {
public OkHttpOAuthConsumer(String consumerKey, String consumerSecret) {
super(consumerKey, consumerSecret);
}
@Override
@mlc
mlc / README.md
Last active August 29, 2015 13:58
@mlc
mlc / pubkey.asc.txt
Created December 15, 2013 05:19
public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.15 (GNU/Linux)
mQGiBDg7OBsRBACAs3JXjvGJ0aKvqA4rIhQUipA86wfq6x3Q9Iji3V2ZQplUIVZy
SD/Pg2WZsG45tjpfV5RBmo721lrhAZBpdvnjAFuUFHN9dtv7GwXad4Z0hPCMWXVu
jInsshhVpNj1aPrRGXpRKDGRkdxAX0MCGMozSckekogGmKw4ZdBQ8RkPgwCgwsVD
KrZqzliuwBbUxboLr3e+dksD/jbzjR/1/vzrQ+a33hu+el84VEEz3UR+GfYcOlRb
ZAVUuKwkJeYNy9U96Bp1UM5tAZ63bvPAJ2KkzhUbztmRHu+hrNudNk3+jMy4CzUe
4jaPeNBJmZZk4kXPrcANxAD180aTmBzmWj2N+phHplD6lQw2do6MlXtz5aCCo2pj
9lvZA/wJjYao5YGm/cON1vS9/cGNQURxt0VLSoRli5xJukELezCnxCNeC8oE7owr
@mlc
mlc / gist:6768769
Created September 30, 2013 19:22
workaround for android bug 58192
/**
* Work around a bug in Android 4.3
*/
public static CharSequence fixFontColor(CharSequence seq, int color) {
if (Build.VERSION.SDK_INT < 18 || !(seq instanceof Spanned))
return seq;
Spannable txt = (seq instanceof Spannable ? (Spannable)seq : new SpannableString(seq));
for (ForegroundColorSpan ann : txt.getSpans(0, txt.length(), ForegroundColorSpan.class)) {
if (ann.getForegroundColor() != color) {
int start = txt.getSpanStart(ann), end = txt.getSpanEnd(ann), flags = txt.getSpanFlags(ann);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed(); // OMG THIS IS SO WRONG BUT ALSO SO RIGHT
return true;
// other cases...
}
}