This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tip: If the failing expression is known to be legally null/missing, | |
either specify a default value with myOptionalVar!myDefault, | |
or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. | |
(These only cover the last step of the expression; | |
to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)?? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv=Content-Type content="text/html;charset=utf-8"> | |
<title>canvas 象棋 </title> | |
<script> | |
var layout = {padding: 30, cell: 50, chessRadius: 20, fontSize: 36, width: 400, height: 450, offsetWidth: 460, offsetHeight: 510}; | |
var style = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public byte[] parse(HttpServletRequest request) { | |
byte[] input = null; | |
try { | |
InputStream is = request.getInputStream(); | |
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); | |
while (true) { | |
int c = is.read(); | |
if (c == -1) break; | |
byteStream.write((byte) c); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HasTempFolder { | |
@Rule | |
public TemporaryFolder folder= new TemporaryFolder(); | |
@Test | |
public void testUsingTempFolder() throws IOException { | |
File createdFile= folder.newFile("myfile.txt"); | |
File createdFolder= folder.newFolder("subfolder"); | |
// ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void initialize(Object entity, String... properties){ | |
for(String name : properties){ | |
try { | |
String property = BeanUtils.getProperty(entity, name); | |
Hibernate.initialize(property); | |
} catch (Throwable e) { | |
logger.error("initialize lazy property occurs error.", e); | |
throw Throwables.propagate(e); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"), sys = require('sys'); | |
http.createServer(function(request, response) { | |
response.writeHead(200, {"Content-Type": "text/plain"}); | |
response.write("Welcome to Node.js!"); | |
response.end(); | |
}).listen(6600); | |
sys.puts('Server running at http://127.0.0.1:8006/'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m SimpleHTTPServer 9393 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv=Content-Type content="text/html;charset=utf-8"> | |
<title>canvas 象棋 </title> | |
</head> | |
<body> | |
<canvas id="chess-canvas" width="410" height="460"></canvas> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected String renderResponse(Map ctx, String stringTemplate) { | |
Configuration cfg = new Configuration(); | |
StringTemplateLoader stringLoader = new StringTemplateLoader(); | |
stringLoader.putTemplate("updateResponseTemplate", stringTemplate); | |
cfg.setTemplateLoader(stringLoader); | |
Writer out = new StringWriter(2048); | |
try { | |
Template tpl = cfg.getTemplate("updateResponseTemplate","utf-8"); | |
tpl.process(ctx, out); |