Skip to content

Instantly share code, notes, and snippets.

View nekocode's full-sized avatar

nekocode nekocode

View GitHub Profile
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
@neworld
neworld / howto.md
Last active September 15, 2020 11:32
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
@scottdweber
scottdweber / ExpandingCircleAnimationDrawable.java
Created March 22, 2013 02:14
An example showing how to create and use a Drawable that animates.
package com.example.manualanimation;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.animation.AnimationUtils;
@hellokaton
hellokaton / QRterminal.java
Last active July 30, 2021 08:39
Java二维码输出到控制台,需引入 zing 库,颜色代码见 https://gist.github.com/zfkun/9755885
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.util.Hashtable;
@fanzeyi
fanzeyi / v2ex_api.md
Last active November 27, 2022 13:42
V2EX API
@justincampbell
justincampbell / after.sh
Created March 1, 2013 17:45
Jenkins + GitHub Commit Status API
if [[ $BUILD_STATUS == "success" ]]
then
export STATUS="success"
else
export STATUS="failure"
fi
curl "https://api.github.com/repos/justincampbell/my_repo/statuses/$GIT_COMMIT?access_token=abc123" \
-H "Content-Type: application/json" \
-X POST \
@SupaHam
SupaHam / DynamicProxies.kt
Last active February 19, 2023 20:16
Dynamic Proxies with Kotlin for accessing private classes.
/*
* Code by @vmironov on Kotlinlang slack.
*
* This code uses dynamic proxies in Java to make it easier to access inaccessible classes via an accessible representation.
*/
inline fun <reified T : Any> createMirror(value: Any) = createMirror(value, T::class.java)
fun <T> createMirror(value: Any, clazz: Class<T>): T {
val loader = clazz.classLoader
@klausbrunner
klausbrunner / SimpleFuture.java
Created November 19, 2012 11:34
A very simple implementation of the Java Future interface, for passing a single value to some waiting thread. Uses a CountdownLatch to ensure thread safety and provide blocking-with-timeout functionality required by Future. Cancellation isn't supported.
public final class ResultFuture implements Future<Result> {
private final CountDownLatch latch = new CountDownLatch(1);
private Result value;
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
@Override
@lisawray
lisawray / MainActivity.java
Last active March 26, 2023 11:57
Vector drawables from XML with the Android support library 23.3.0
package com.xwray.vectorbinding;
import android.databinding.BindingAdapter;
import android.databinding.DataBindingUtil;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
@jeromerobert
jeromerobert / pandoc-svg.py
Last active September 1, 2023 09:05
Pandoc filter to create PDF files from SVG
#! /usr/bin/env python
"""
Pandoc filter to convert svg files to pdf as suggested at:
https://github.com/jgm/pandoc/issues/265#issuecomment-27317316
"""
__author__ = "Jerome Robert"
import mimetypes
import subprocess