Skip to content

Instantly share code, notes, and snippets.

@DennisXie
DennisXie / gist:e478c9b66007d5f23df2b8fd2be71f22
Last active February 24, 2022 09:50
spring security authorization_request_not_found
When using Spring Security to implement an OAuth login process.You may got
a authorization_request_not_found error when you deploy multiple application
instances. This is caused by that the spring security saved the authorization
requests in memory. Just implementing a AuthorizationRequestRepository to share
the requests can solve this problem. Such as HttpCookieOAuth2AuthorizationRequestRepository,
RedisCookieOAuth2AuthorizationRequestRepository.
reference:
docs: https://docs.spring.io/spring-security/site/docs/5.0.7.RELEASE/reference/html/oauth2login-advanced.html#oauth2login-advanced-authorization-request-repository
related source code: https://github.com/spring-projects/spring-security/blob/ea352e1c59507d70920246b2b0df35c31ef3ef0f/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilter.java
@DennisXie
DennisXie / nginx.conf
Created July 10, 2019 08:37
nginx error_page not working
location /xxxx {
proxy_intercept_errors on;
error_page 404 502 = @fallback;
rewrite ^ /yyy.html break;
proxy_pass http://xxxx.com
}
nginx默认情况下只处理自己的404 502这一类错误,如果是代理服务返回的错误码,则不会处理。
这时候需要使用proxy_intercept_erros on; 指令才能让其处理代理返回的错误码。
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors
"editor.glyphMargin": true,
"editor.detectIndentation": false,
@DennisXie
DennisXie / gist:5721fc95484ff54b96b8a5e456a69399
Last active December 6, 2018 08:58
mongodb cursorNotFound exception
一段很简单的代码:
res = db.table.find({"uid": 12345})
l = [d['info'] for d in res]
在有100多条文档的时候,这段代码有时候会抛出 cursorNotFoundException
由于文档只有100多条,可以直接排除cursor超时的问题
经和SA进行确认,链接mongodb的时候使用的是url的方式,部署方式如下:
app->lbc->mongos->mongod
其中app->lbc使用了长连接的方式,但是lbc->mongos并没有使用长连接。
其中由于文档数量超过100条以后,会超过cursor的默认batach_size,超过batch_size以后需要从mongos拉取更多的数据。
由于lbc->mongos没有使用长连接,有可能会出现这种情况,第一个batch使用了mongos A,取第二个batch时使用了mongos B。
@DennisXie
DennisXie / gitrevert.txt
Last active November 23, 2018 08:58
revert a commited merge
git log查看最近的提交
commit 8f937c683929b08379097828c8a04350b9b8e183
Merge: 8989ee0 7c6b236
Author: Ben James <[email protected]>
Date: Wed Aug 17 22:49:41 2011 +0100
git revert 8f937c -m 8989ee0
其中-m用于指定父分支,Merge字段中的提交按1, 2 来编号
问题: 使用jq将[{uid: 1, k1: v1, k2: v2}, {uid: 2, k1: v1, k2: v2}, ....]的list转换成 {'1': {k1: v1, k2: v2}, '2': {k1: v1, k2: v2},.....}这种形式
jq: [.[] | {(.uid | tostring): {k1: .k1, k2: .k2}}] | add
$("form").submit(function() {
$(this).submit(function() {
return false;
});
return true;
});
$( "#target" ).submit(function( event ) {
alert( "Handler for .submit() called." );
@DennisXie
DennisXie / gist:4d6daedc6693cb8165b492cc8e4369d9
Created April 28, 2018 07:08
git pull 报错: There are no candidates for merging among the refs that you just fetched. Generally this means that you provided a wildcard refspec which had no matches on the remote end.
1. git status 查看状态
On branch master
Your branch is behind 'origin/master' by 4 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working directory clean
2. git pull
Your configuration specifies to merge with the ref 'master'
from the remote, but no such ref was fetched.
@DennisXie
DennisXie / 0_reuse_code.js
Created July 13, 2017 15:49
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