Skip to content

Instantly share code, notes, and snippets.

View whitfin's full-sized avatar
🏠
Working from home

Isaac Whitfield whitfin

🏠
Working from home
View GitHub Profile
@whitfin
whitfin / InlineBrowser.java
Last active March 9, 2022 18:03
Inline browser loading for Android. Just extend and load your URL.
package com.zackehh.example;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
@whitfin
whitfin / WriteObjectFile.java
Created January 28, 2014 21:07
Simple class to write a JSON object to a file, and read it back into JSON. Useful for data storing on Android.
package com.zackehh.example;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import android.content.Context;
@whitfin
whitfin / DirectedStream.java
Last active November 21, 2021 11:34
A simple Thread extension to control a redirection of an InputStream to an OutputStream.
package com.zackehh.example;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* A Thread extension dedicated to redirecting InputStreams
* to given OutputStreams. Feeds into the given OutputStream
* during the lifetime of this Thread.
@whitfin
whitfin / LinkMovementMethod.java
Created January 28, 2014 21:09
Custom Link Movement to open any clicked links inside an inline browser. Requires either a custom inline browser, or the one I created in a gist.
package com.zackehh.example;
import com.zackehh.example.MinimalBrowser;
import android.content.Context;
import android.content.Intent;
import android.text.Layout;
import android.text.Spannable;
import android.text.method.MovementMethod;
import android.text.style.URLSpan;
path = _{ SOI ~ base ~ accessor* ~ EOI }
base = @{ ("$" | "_" | ASCII_ALPHA) ~ identifier }
accessor = _{ ("." ~ identifier ) | ("[\"" ~ inner ~ "\"]") | index }
identifier = { ("$" | "_" | ASCII_ALPHANUMERIC)* }
inner = @{ char* }
char = {
!("\"" | "\\") ~ ANY
@whitfin
whitfin / ArrayNodeCollector.java
Created September 19, 2015 22:46
Collecting to a Jackson ArrayNode from a Java 8 Stream.
package com.zackehh.example;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.util.EnumSet;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
@whitfin
whitfin / Cargo.toml
Last active March 1, 2019 20:56
Example of piping request body to a file in Gotham
[package]
name = "gotham_request_pipe"
version = "0.1.0"
authors = ["Isaac Whitfield <iw@whitfin.io>"]
edition = "2018"
[dependencies]
gotham = "0.3"
hyper = "0.12"
tokio = "0.1"
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Libimobiledevice(AutotoolsPackage):
"""Library to communicate with iOS devices natively."""

Keybase proof

I hereby claim:

  • I am whitfin on github.
  • I am whitfin (https://keybase.io/whitfin) on keybase.
  • I have a public key ASBIcyeqhID9fEJiNyYMaKpyS67OGMiNNXGibXxQ8Hzzngo

To claim this, I am signing this object:

package com.appcelerator.binding;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class Broadcaster {
private static final Map<String, List<Listener>> LISTENERS = new ConcurrentHashMap<>();