Skip to content

Instantly share code, notes, and snippets.

View ncornette's full-sized avatar

Nicolas Cornette ncornette

View GitHub Profile
@JakeWharton
JakeWharton / 19.1.0_to_20.0.0.diff
Last active August 29, 2015 14:03
Public API changes between support-v4 19.1.0 to 20.0.0. Created with https://github.com/JakeWharton/jardiff
diff -U 0 -N support-v4-19.1.0/android.support.v4.BuildConfig support-v4-20.0.0/android.support.v4.BuildConfig
--- support-v4-19.1.0/android.support.v4.BuildConfig 1969-12-31 16:00:00.000000000 -0800
+++ support-v4-20.0.0/android.support.v4.BuildConfig 2014-06-26 19:59:59.000000000 -0700
@@ -0,0 +1,9 @@
+public final class android.support.v4.BuildConfig {
+ public static final boolean DEBUG;
+ public static final java.lang.String PACKAGE_NAME;
+ public static final java.lang.String BUILD_TYPE;
+ public static final java.lang.String FLAVOR;
+ public static final int VERSION_CODE;
@daddykotex
daddykotex / DummyAndroidTextUtilsMockTest.java
Last active April 20, 2017 10:51
Mock Android TextUtils static method
import android.text.TextUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@almozavr
almozavr / ObjectGsonParceler.java
Last active September 30, 2020 16:53
Parcelable helper to wrap object convertable with gson
public class ObjectGsonParceler {
private final Gson gson;
public ObjectGsonParceler(Gson gson) {
this.gson = gson;
}
public Parcelable wrap(Object instance) {
try {
String json = encode(instance);
@JakeWharton
JakeWharton / ContractFragment.java
Created May 6, 2012 09:12
Base fragment to ensure the parent activity implements a contract interface.
/* Base fragment to ensure the parent activity implements a contract interface. */
public abstract class ContractFragment<T> extends Fragment {
private T mContract;
@Override
public void onAttach(Activity activity) {
try {
mContract = (T)activity;
} catch (ClassCastException e) {
throw new IllegalStateException(activity.getClass().getSimpleName()
@rgl
rgl / gimp_xcf_list_layers.py
Created January 1, 2014 22:08
List the layers of a GIMP xcf file. This also exports the visible layers into a png file.
# This lists the layers of a GIMP xcf file. This also exports the visible layers into a png file.
#
# Execute the commands:
#
# curl -O https://bitbucket.org/rgl/make_dmg/downloads/background.xcf
# gimp -idf --batch-interpreter=python-fu-eval -b - -b 'pdb.gimp_quit(0)' < gimp_xcf_list_layers.py
#
# See http://www.gimp.org/docs/python/
# See http://gimpbook.com/scripting/
#
@kklimonda
kklimonda / pybrowser.py
Created March 28, 2011 15:18
A minimal Gtk+/Webkit based browser in Python
import sys
from gi.repository import Gtk, Gdk, WebKit
class BrowserTab(Gtk.VBox):
def __init__(self, *args, **kwargs):
super(BrowserTab, self).__init__(*args, **kwargs)
go_button = Gtk.Button("go to...")
go_button.connect("clicked", self._load_url)
self.url_bar = Gtk.Entry()
@skyfishjy
skyfishjy / CursorRecyclerViewAdapter.java
Last active December 16, 2023 08:55
CursorRecyclerViewAdapter
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* 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
@imminent
imminent / AccountUtils.java
Created November 12, 2012 19:55
Utility to retrieve user profile on Android device
/**
* A collection of authentication and account connection utilities. With strong inspiration from the Google IO session
* app.
* @author Dandré Allison
*/
public class AccountUtils {
/**
* Interface for interacting with the result of {@link AccountUtils#getUserProfile}.
*/
@romannurik
romannurik / AndroidManifest.xml
Last active March 7, 2024 11:13
Android example of how to programmatically instantiate a View with a custom style.
<manifest ...>
...
<!-- Make sure your app (or individual activity) uses the
theme with the custom attribute defined. -->
<application android:theme="@style/AppTheme" ...>
...
</application>
</manifest>
@romannurik
romannurik / DrawInsetsFrameLayout.java
Created February 10, 2014 16:28
DrawInsetsFrameLayout — adding additional background protection for system UI chrome when using KitKat’s translucent decor flags.
/*
* Copyright 2014 Google Inc.
*
* 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