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
<!-- JSON parser configuration-->
<bean id="guavaObjectMapper" class="com.fasterxml.jackson.databind.ObjectMapper"/>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject"><ref local="guavaObjectMapper" /></property>
<property name="targetMethod"><value>registerModule</value></property>
<property name="arguments">
<list>
<bean id="guavaModule" class="com.fasterxml.jackson.datatype.guava.GuavaModule"/>
</list>
@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 <buchanan.sc@gmail.com>
* 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 January 23, 2017 02:38
spring trace level
<logger name="org.springframework.web">
<level value="TRACE"/>
</logger>