Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Gilfelt jgilfelt

  • readyState Software Ltd
  • London, United Kingdom
View GitHub Profile
@jgilfelt
jgilfelt / README.md
Last active Jul 2, 2019 — forked from jagdeepsingh/README.md
ImageMagick 6.7.7-10 homebrew formula
View README.md

Install ImageMagick 6.7.7-10

$ brew install https://gist.githubusercontent.com/jgilfelt/907d60ba5657e18daf9b4db1e442a6b0/raw/a56bc99ade0c86a60c954ec42cd2bc3bba8180ce/imagemagick.rb
View BreakingGzipInterceptorTest.java
import org.junit.Rule;
import org.junit.Test;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@jgilfelt
jgilfelt / CurlLoggingInterceptor.java
Created Jan 9, 2016
An OkHttp interceptor that logs requests as curl shell commands
View CurlLoggingInterceptor.java
/*
* Copyright (C) 2016 Jeff Gilfelt.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jgilfelt
jgilfelt / gist:8105b5ca07776a4359c2
Created Nov 28, 2014
Notification whose content is partially redacted on API 21 secure lockscreens
View gist:8105b5ca07776a4359c2
private Notification buildNotification() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setCategory(NotificationCompat.CATEGORY_EVENT)
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) // default
.setContentTitle(title)
.setContentText(shortText)
.setStyle(new NotificationCompat.BigTextStyle().bigText(fullText))
.setSmallIcon(R.drawable.ic_stat_notification)
.setColor(context.getResources().getColor(R.color.my_color))
.setContentIntent(intent);
@jgilfelt
jgilfelt / install_jdk
Created May 2, 2014
Install Oracle JDK on the Funky Android AOSP build environment VirtualBox image
View install_jdk
# add the webupd8team java PPA
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
# install oracle java 6
sudo apt-get install oracle-java6-installer
@jgilfelt
jgilfelt / ScalpelDrawer.java
Last active Jan 28, 2017
ScalpelDrawer - A simple wrapper for Scalpel (https://github.com/JakeWharton/scalpel) that includes toggle controls accessible from a right-side navigation drawer. Call ScalpelDrawer.wrapInside() in a base Activity onPostCreate() to easily wrap all content in your app.
View ScalpelDrawer.java
package com.example.scalpeldrawer;
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
@jgilfelt
jgilfelt / ExpandingListView.java
Created Nov 6, 2013
Fixes for Daniel Olshansky's DevByte example "ListView Expanding Cells Animation" (lines 130-132), also adds compatibility back to API 11. http://www.youtube.com/watch?v=mwE61B56pVQ http://developer.android.com/shareables/devbytes/ListViewExpandingCells.zip
View ExpandingListView.java
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jgilfelt
jgilfelt / ShameActivity.java
Created Oct 3, 2013
A base Activity class that allows the compatibility menu button (AKA "the menu button of shame") to be displayed for applications whose targetSdkVersion >= 11. On devices with a hard menu key there is no effect. Useful if you want to launch some sort of in-app debug UI from an on-screen affordance without altering your application's user interfa…
View ShameActivity.java
package com.example.shame;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.view.KeyEvent;
import android.view.ViewConfiguration;
public abstract class ShameActivity extends Activity {
@jgilfelt
jgilfelt / whartoff.sh
Created Jul 24, 2013
Whartoff - An ActionBarSherlock migration utility. For educational purposes only. Will not migrate project dependencies, static Sherlock attachments, List/ExpandableList/Preference Activities, compatibility MenuItem methods, Sherlock resource references and probably a dozen other use cases. This program will modify your code. Use it at your own …
View whartoff.sh
# Whartoff - An ActionBarSherlock migration utility
#
# usage: whartoff.sh <option> <project directory>
#
# options:
# -c : ActionBarSherlock to compatibility ActionBar
# -n : ActionBarSherlock to native ActionBar
#!/bin/bash
@jgilfelt
jgilfelt / DrawerSafeViewPager.java
Last active Dec 19, 2015
DrawerLayout friendly ViewPager that will ignore rogue touch events from the bezel swipe gesture.
View DrawerSafeViewPager.java
/*
* Copyright (C) 2013 readyState Software Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
You can’t perform that action at this time.