Skip to content

Instantly share code, notes, and snippets.

View winteryoung's full-sized avatar

Winter Young winteryoung

View GitHub Profile
@winteryoung
winteryoung / GenericActualArgumentResolver.java
Last active February 22, 2016 12:54
java 泛型类型推导
// 输出 Integer
// 用法: GenericActualArgumentResolver.resolve(A.class, C.class, 0);
import com.google.common.collect.Lists;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
@winteryoung
winteryoung / repackage.xml
Last active February 22, 2016 13:02
maven pom - repackage
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>jarjar-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jarjar</goal>
</goals>
@winteryoung
winteryoung / dokka.xml
Created February 22, 2016 13:04
maven - dokka
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>0.9.4</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>dokka</goal>
</goals>
@winteryoung
winteryoung / centralPom.xml
Created February 22, 2016 13:05
maven - standard maven pom to upload to central
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.winteryoung</groupId>
<artifactId>yanwte</artifactId>
<version>1.2.0-beta-6</version>
<packaging>pom</packaging>
<inceptionYear>2016</inceptionYear>
@winteryoung
winteryoung / settings.xml
Last active March 6, 2016 08:16
Standard Maven 3 settings
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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
@winteryoung
winteryoung / ChangePomVersion.bat
Last active February 22, 2016 13:17
Maven - change pom versions in all sub projects of a multi-module project
mvn versions:set -DnewVersion=1.2.0-beta-7
@winteryoung
winteryoung / ByteArrayClassLoader.java
Created February 22, 2016 13:24
Byte array class loader. Copied from byte-buddy.
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.*;
import java.util.HashMap;
import java.util.Map;
/**
* A {@link java.lang.ClassLoader} that is capable of loading explicitly defined classes. The class loader will free
* any binary resources once a class that is defined by its binary data is loaded. This class loader is thread safe
* since the class loading mechanics are only called from synchronized context.
@winteryoung
winteryoung / .gitignore
Last active March 8, 2016 13:27
Standard .gitignore
# Android built application files
*.apk
*.ap_
*.dex
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
@winteryoung
winteryoung / clearfix.css
Created February 23, 2016 10:17
CSS - A trick to clear float
&:after {
content: ".";
display: block;
height: 0;
clear: both;
}
@winteryoung
winteryoung / PackageNamedKeyMap.kt
Created March 1, 2016 06:58
PackageNamedKeyMap
/**
* Package name keyed map finds an entry if it has the given package name registered in it,
* or the ancestor package of the given package name registered in it.
*/
internal class PackageNamedKeyMap<T> {
private val map = TreeMap<String, T>()
/**
* Returns the value if this map has the given package name registered in it,
* or the ancestor package of the given package name registered in it.