Skip to content

Instantly share code, notes, and snippets.

@qsLI
qsLI / Init-on-demand holder
Created March 14, 2016 09:06 — forked from 55v/Init-on-demand holder
Initialization-on-demand holder idiom example
public class Something {
private Something() {
}
private static class LazyHolder {
public static final Something INSTANCE = new Something();
}
public static Something getInstance() {
return LazyHolder.INSTANCE;
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
</bean>
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
</bean>
@qsLI
qsLI / ServletThreadSafety.java
Created August 11, 2016 09:32 — forked from raskasa/ServletThreadSafety.java
An example of how to deal with concurrency and thread-safety when accessing context and session attributes. Context attributes can be accessed by an part of the web app including Servlets, JSPs, ContextListeners, and ServletContextAttributeListeners. Session attributes are only for one client, but opening up another new browser windows on the sa…
public class ServletThreadSafety extends HttpServlet {
/*
* Since we have the context lock, we're assuming that once we get inside the synzchonized block,
* the context attributes are safe from other threads until we exit the block... soft of. Safe
* means "safe from any other code that ALSO synchonizes on the ServletContext".
*
* But this is the best you've got for making the context attributes as thread-safe as you can.
*/
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
@qsLI
qsLI / OrgAndUserSelectionController.java
Created September 19, 2016 13:06 — forked from yanhua365/OrgAndUserSelectionController.java
使用Mockito测试Spring MVC 的Controller
package sample.uic.web.controller;
import sample.uic.model.Organization;
import sample.uic.model.OrganizationUser;
import sample.uic.model.User;
import sample.uic.service.OrganizationService;
import sample.uic.service.UserService;
import com.google.common.collect.Lists;
import org.junit.Before;
import org.junit.Test;
@qsLI
qsLI / gist:1f10fa5b8b76f3b5efaf74ad3d6da413
Created September 21, 2016 04:01 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@qsLI
qsLI / 0_reuse_code.js
Created September 25, 2016 14:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@qsLI
qsLI / JSONView.css
Created November 21, 2016 07:02 — forked from wafflesnatcha/JSONView.css
JSONView.css - Custom Stylesheet for the JSONView Chrome extension
/**
* JSONView.css
* Custom Stylesheet for the JSONView Chrome extension
*
* by Scott Buchanan <[email protected]>
* http://wafflesnatcha.github.com
*/
html, body {
margin: 0;
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@qsLI
qsLI / logback.xml
Created February 2, 2017 10:38 — forked from WalterInSH/logback.xml
logback configuration
<?xml version="1.0" encoding="UTF-8"?>
<!-- <configuration debug="true"> 调试模式下,可输出logback的内部日志信息 -->
<configuration debug="false">
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 [%file:%line]日志所在文件及行数 %msg%n消息及换行-->
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%level][%thread]:%logger{50} [%method:%line] %msg%n</pattern>
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/opt/devtools/maven/repo</localRepository>
<mirrors>
<mirror>
<id>maven-aliyun-mirror</id>
<name>maven-aliyun-mirror</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>