Skip to content

Instantly share code, notes, and snippets.

View ncornette's full-sized avatar

Nicolas Cornette ncornette

View GitHub Profile
@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);
@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;
@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
@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;
@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
@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/
#
@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>
@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}.
*/
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 23, 2024 15:29
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname