Skip to content

Instantly share code, notes, and snippets.

class Solution {
public List<List<Integer>> threeSum(int[] nums) {
if (nums == null || nums.length < 3) return Collections.emptyList();
Arrays.sort(nums);
int min = nums[0];
int max = nums[nums.length-1];
List<List<Integer>> list = new LinkedList();
Set<Triplet> catches = new TreeSet<Triplet>();
for (int i = 0; i < nums.length; i++) {
@avvero
avvero / quartz.properties
Last active September 26, 2018 10:52
#quartz #cluster #configuration
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName = ODPS_Scheduler
org.quartz.scheduler.instanceId = AUTO
#============================================================================
# Configure ThreadPool
#============================================================================
@avvero
avvero / find.groovy
Created March 21, 2018 07:20
#find all #resources in #groovy
def properties = new Properties()
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(this.getClass().getClassLoader());
def resources = resolver.getResources("classpath*:**/*.properties")
resources.each {
println it
properties.load(it.inputStream)
}
@avvero
avvero / Config.java
Created March 19, 2018 10:11
skipp #tld #scan during #tomcat loanch with #spring
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ServletContainerConfig {
@Value("${app.tomcat.additional-tld-skip-patterns}")
private String tldSkip;
@avvero
avvero / CustomMetricsCollector.java
Created March 15, 2018 08:27
add custom #metrics for #spring
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.stereotype.Component;
@avvero
avvero / MetricsCollector.java
Last active March 15, 2018 08:27
add custom #metrics for #spring
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@avvero
avvero / logback.grooy
Created February 22, 2018 03:16
put serverId to the #log
def serverId = Math.abs(new Random().nextInt() % 89) + 10
appender("file", RollingFileAppender) {
file = "main.log"
encoder(PatternLayoutEncoder) {
charset = java.nio.charset.StandardCharsets.UTF_8
pattern = "\\(serverId=${serverId}\\) %d{yyyy-MM-dd HH:mm:ss.SSS}"
}
}
@avvero
avvero / file.java
Created February 15, 2018 06:14
#read resource from #jar in spring
@Value("classpath*:**/*.feature")
private Resource[] featureResources;
String string = StreamUtils.copyToString(resource.getInputStream(), Charset.forName("UTF-8"));
@avvero
avvero / File.java
Created February 13, 2018 07:16
#search all #resources in #spring
@Component
public class FeatureController {
@Value("classpath*:**/*.feature")
private Resource[] features;
}
@avvero
avvero / build.gradle
Last active February 5, 2018 11:00
#gradle #include additional single file to #resources
processResources {
from ('.') {include 'CHANGELOG.md'}
}