Skip to content

Instantly share code, notes, and snippets.

View codethereforam's full-sized avatar
:octocat:
Focusing

thinkam codethereforam

:octocat:
Focusing
View GitHub Profile
@codethereforam
codethereforam / FooEnum.java
Last active June 1, 2019 14:07
Enum getByValue example
public enum FooEnum {
/**
* foo
*/
FOO(0, "foo"),
/**
* bar
*/
BAR(0, "bar");
@codethereforam
codethereforam / WebMvcConfig.java
Created December 20, 2018 03:01
配置多视图解析,包括thymeleaf和Json两种视图
/**
* 配置多视图解析,包括thymeleaf和Json两种视图
* <ul>
* <li>通过url查看thymeleaf视图</li>
* <li>通过url+'.json'查看Json视图</li>
* </ul>
*
* @author yanganyu
* @date 2018/10/15 14:16
*/
@codethereforam
codethereforam / MappingFastjson2JsonView.java
Created December 20, 2018 03:05
配置SpringMVC使用fastjson
/**
* Spring MVC {@link View} that renders JSON content by serializing the model for the current request
* using fastjson.
*
* <p>By default, the entire contents of the model map (with the exception of framework-specific classes)
* will be encoded as JSON. If the model contains only one key, you can have it extracted encoded as JSON
* alone via {@link #setExtractValueFromSingleKeyModel}.
*
* @author yanganyu
* @date 2018/10/15 15:48
@codethereforam
codethereforam / github-dark-patch.css
Last active January 27, 2019 02:17
GitHub-Dark主题补丁 #config
/* thinkam patch start*/
.gh-header .gh-header-sticky.is-stuck + .gh-header-shadow {
background-color: #000;
}
.gh-header {
background-color: unset;
}
/* thinkam patch end*/
@codethereforam
codethereforam / api-authentication.md
Created December 27, 2018 03:11
使用API key做接口签名校验

使用API key做接口签名校验

参考

微信支付

要点

  1. 使用消息认证码而不是单向散列函数,即使用hmac(data, key)而不是hash(data+key)
  2. 使用安全的Hash函数,即选择SHA-2、SHA-3等,而不是MD5等
  3. 防止密钥推测攻击,密钥使用密码学安全的、高强度的伪随机数生成器生成,至少32字符
  4. 防止重放攻击,使用nonce等方式
@codethereforam
codethereforam / personal-blocklist.config
Last active May 26, 2019 14:24
Personal Blocklist个人配置 #config
hk.saowen.com
zhidao.baidu.com
zidao.baidu.com
@codethereforam
codethereforam / switchyomega-autoswitch.config
Last active December 29, 2018 06:46
switchyomega autoswitch配置 #config
[SwitchyOmega Conditions]
@with result
*.*github* +ss
*.*gitlab* +ss
*.digitalocean.com +ss
*.inoreader.com +ss
*.askubuntu.com +ss
.infoq.* +ss
*.bing.com +ss
@codethereforam
codethereforam / spoken-english.md
Last active January 8, 2019 13:30
英语口语学习笔记

My Mon said wait, I don't think I'm able, I want to see some food on top of the table.

  • said wait -> sai wai
  • I don't -> I don
  • I'm able -> I mable
  • want to -> wanna
  • food on -> foodon

other

  • do it -> do wit
@codethereforam
codethereforam / ExcelUtils.java
Last active January 11, 2019 09:02
POI读取Excel单元格工具。由于读取时间、数值等存在精度等坑,因此约定Excel单元格只能为文本格式,否则报错。
/**
* Excel工具类
*
* @author yanganyu
* @date 2019/1/11 11:42
*/
public class ExcelUtils {
private ExcelUtils() {
}