Skip to content

Instantly share code, notes, and snippets.

Tianxing Li nex3z

Block or report user

Report or block nex3z

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nex3z
nex3z / docker-compose.yml
Created May 20, 2019
docker-compose elasticsearch kibana
View docker-compose.yml
version: '3.7'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1
container_name: es01
environment:
- node.name=es01
- cluster.name=docker-es-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
@nex3z
nex3z / EnumConverter.kt
Created Dec 12, 2017
Kotlin Enum with Custom Property and Converter
View EnumConverter.kt
abstract class EnumConverter<in V, E: Enum<E>>(
private val valueMap: Map<V, E>
) {
fun fromValue(value: V): E? = valueMap[value]
fun fromValue(value: V?, default: E): E = valueMap[value] ?: default
}
inline fun <V, reified E: Enum<E>> buildValueMap(keySelector: (E) -> V): Map<V, E> =
enumValues<E>().associateBy(keySelector)
View Singleton.java
public class Singleton {
private Singleton() {}
private static class Holder {
private static final Singleton INSTANCE = new Singleton();
}
public static Singleton getInstance() {
return Holder.INSTANCE;
}
View MyHandler.java
static class MyHandler extends Handler {
private final WeakReference<MyActivity> mRef;
MyHandler(MyActivity activity) {
mRef = new WeakReference<HomeActivity>(activity);
}
@Override
public void handleMessage(Message msg) {
MyActivity activity = mRef.get();
View codec.cs
// hello 你好
// hello 浣犲ソ
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
View SimpleObserver.java
public class SimpleObserver extends ContentObserver {
private static final String LOG_TAG = SimpleObserver.class.getSimpleName();
public SimpleObserver(Handler handler) {
super(handler);
}
@Override
public void onChange(boolean selfChange) {
this.onChange(selfChange, null);
View TMDb JSON sample
{
"page":1,
"results":[
{
"poster_path":"\/fYzpM9GmpBlIC893fNjoWCwE24H.jpg",
"adult":false,
"overview":"Thirty years after defeating the Galactic Empire, Han Solo and his allies face a new threat from the evil Kylo Ren and his army of Stormtroopers.",
"release_date":"2015-12-18",
"genre_ids":[
28,
You can’t perform that action at this time.