Skip to content

Instantly share code, notes, and snippets.

@nex3z
nex3z / docker-compose.yml
Created May 20, 2019 06:57
docker-compose elasticsearch kibana
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 December 12, 2017 06:59
Kotlin Enum with Custom Property and Converter
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)
public class Singleton {
private Singleton() {}
private static class Holder {
private static final Singleton INSTANCE = new Singleton();
}
public static Singleton getInstance() {
return Holder.INSTANCE;
}
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();
// hello 你好
// hello 浣犲ソ
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
{
"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,