Skip to content

Instantly share code, notes, and snippets.

@lidaling
lidaling / HttpClientsRout.java
Last active July 6, 2021 22:18
httpclient 转发
public boolean forward(HttpServletRequest request, HttpServletResponse response , String serviceName) throws IOException {
String[] serviceNames = forwardname.split(";");
String requestURI = request.getRequestURI();//获取请求URI
String queryParam=request.getQueryString();//获取请求url中的参数
String url= targetUrl + requestURI;
if(StringUtils.isNoneBlank(queryParam)) {
url = url + "?" + queryParam;
}
logger.info(serviceName + "=================== forward to " + url );
@RestController
@RequestMapping(GraphDBController.DELEGATE_PREFIX)
@Api(value = "GraphDB", tags = {
"graphdb-Api"
})
public class GraphDBController {
@Autowired
GraphProperties graphProperties;
@lidaling
lidaling / RoutingDelegate.java
Last active July 6, 2021 14:32
spring routing
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StreamUtils;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
@lidaling
lidaling / book.java.performance.20160114.md
Created August 2, 2018 02:01 — forked from zhanhai/book.java.performance.20160114.md
<java性能优化权威指南>读后总结

目的

  • 了解JAVA程序性能调优的过程、原理以及常见方法;在这方面做到“知道自己不知道”;
  • 不用了解太多细节,这些细节的学习需要结合大量实践,只能有机会再深入。

TODO/疑问

  • 为什么优化GC时,要按照“确定内存需求" -> "延迟调优" -> "吞吐量调优"的顺序? 是因为这些指标之间存在该顺序表明的依赖关系?
  • 如何定义性能需求?
@lidaling
lidaling / osx-setup.sh
Created July 12, 2018 22:23 — forked from somebox/osx-setup.sh
Set up an OSX machine from zero to awesome. Uses Homebrew (and cask, fonts, etc). Focused on Ruby/Rails development, includes rvm, xquartz, editor fonts, sublime text, and many tools.
#!/bin/bash
# A script to set up a new mac. Uses bash, homebrew, etc.
# Focused for ruby/rails development. Includes many utilities and apps:
# - homebrew, rvm, node
# - quicklook plugins, terminal fonts
# - browsers: chrome, firefox
# - dev: iterm2, sublime text, postgres, chrome devtools, etc.
# - team: slack, dropbox, google drive, skype, etc
@lidaling
lidaling / postgres_queries_and_commands.sql
Created May 25, 2018 06:44 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@lidaling
lidaling / gist:b076ad65be87d0670287915f571c7579
Created December 27, 2017 13:51
Resizing a filesystem using qemu-img and fdisk

Occasionally we will deploy a virtual instance into our KVM infrastructure and realize after the fact that we need more local disk space available. This is the process we use to expand the disk image. This process assumes the following:

  • You're using legacy disk partitions. The process for LVM is similar and I will describe that in another post.
  • The partition you need to resize is the last partition on the disk.

This process will work with either a qcow2 or raw disk image. For

@lidaling
lidaling / SpringContextTests.scala
Created September 1, 2017 06:06 — forked from shishkin/SpringContextTests.scala
Spring annotation-based configuration with ScalaTest
package samples
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest._
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation._
import org.springframework.stereotype.Service
import org.springframework.test.context.support.AnnotationConfigContextLoader
import org.springframework.test.context.{ActiveProfiles, ContextConfiguration, TestContextManager}
@lidaling
lidaling / Application.scala
Created December 7, 2016 01:51 — forked from Lobedan/Application.scala
Spring-Boot-Application Integration Test in scala
object Application {
def main(args: Array[String]) : Unit = SpringApplication.run(classOf[ApplicationConfig], args :_ *)
}
@lidaling
lidaling / gist:5e1f01bd60b2b4877a1982a6a1262ccc
Created September 9, 2016 05:47 — forked from tnolet/gist:7361441
Install collectd 5.4 on Centos 6.x and make it spit out cool metrics. Copied from http://linuxdrops.com/install-collectd-statistics-collecter-on-centos-rhel-ubuntu-debian/ and tweaked for your and my pleasure. For all other cool options, check the provided link.
#!/bin/bash
# Perform installation as root
# Install prereqs
yum -y install libcurl libcurl-devel rrdtool rrdtool-devel rrdtool-prel libgcrypt-devel gcc make gcc-c++
# Get Collectd, untar it, make it and install
wget http://collectd.org/files/collectd-5.4.0.tar.gz
tar zxvf collectd-5.4.0.tar.gz