Skip to content

Instantly share code, notes, and snippets.

@biaocy
biaocy / NERDTree.mkd
Created January 3, 2020 02:41 — forked from m3nd3s/NERDTree.mkd
My Vim Cheat Sheet

NERDTree

o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|

O.......Recursively open the selected directory..................|NERDTree-O|

@biaocy
biaocy / queryToObj.js
Created December 9, 2019 09:35
Parse query string to object
function getQueryObj(url) {
let re = /[?&]+(\w+)(?:=([\w%\.]*))*/g;
let results, ret = {};
while ((results = re.exec(url)) !== null) {
let [m, k, v] = results; // array destructuring
ret[k] = v;
}
return ret;
}
@biaocy
biaocy / resources.md
Created January 18, 2019 05:08 — forked from lamont-granquist/resources.md
Three Ways to Write Correct Chef Resources

This has been moved into the official Chef docs:

https://docs.chef.io/custom_resources_notes.html

12.5 style custom resources

This is by far the most recommended way of writing resources for all users. There are two gotchas which we're working through:

  1. For helper functions that you used to write in your provider code or used to mixin to your provider code, you have to use an action_class do ... end block.
@biaocy
biaocy / extract_download_url_from_rss.sh
Last active August 19, 2018 06:39
extract download url from zimuzu rss
#!/bin/bash
#zimuzu video id
vid="$1"
#season: S01 etc
season="$2"
#output file name
fname="${3-$vid}.$season.`date +%Y%m%d`.json"
@biaocy
biaocy / How_Spring_MVC_Work
Created March 27, 2018 03:25
how spring mvc work
Blog about "How Spring Mvc Work"
1.how request url match? Hint: With namespace <mvc:annotation-driven />, it's use of RequestMappingHandleMapping.
A.With "WebMVC" enabled, it will register a couple of HandleMapping and HandleAdapter
当 "WebMVC" enabled 时,Spring 默认会注册一些 HandleMapping 和 HandleAdapter
By default:
1.RequestMappingHandleMapping
2.RequestMappingHandlerAdapter
@biaocy
biaocy / ca.js
Last active January 8, 2018 13:35
coinmarketcap.com crytocurrency change analyze
var count = document.querySelectorAll('#currencies-all > tbody > tr').length;
var data = document.querySelectorAll('#currencies-all > tbody > tr > td:nth-last-child(-n+3)');
var h1 = {'up': 0, 'down': 0, 'zero': 0}; //1 hour change
var h24 = {'up': 0, 'down': 0, 'zero': 0}; //24 hours change
var d7 = {'up': 0, 'down': 0, 'zero': 0}; //7 days change
for (let i = 0; i < data.length; i+=3) {
let a = Number(data[i].dataset.usd), b = Number(data[i+1].dataset.usd), c = Number(data[i+2].dataset.usd);
if (a > 0) h1.up++;
else if (a < 0) h1.down++;
@biaocy
biaocy / date_normalize.js
Created December 17, 2017 09:54
javascript normalize date time
//from https://stackoverflow.com/a/11172083
var date = new Date();
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
date.toJSON(); //2017-12-17T17:51:45.055Z
@biaocy
biaocy / random.sh
Last active April 6, 2023 12:09
linux generate 32 length alphanumeric string
cat /dev/urandom | tr -cd 'a-zA-Z0-9' | fold -w 32 | head -n 1
@biaocy
biaocy / neo-alert.sh
Last active December 22, 2017 12:42
bittrex neo coin alert script
#curl -s https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-neo | awk -F , '{print }' | awk -F : '{print }'
date=`date +"%FT%T"`
log="/var/log/neo.log"
url="https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-neo"
subject="NEO"
threshold="0.003"
mailto="email" # email here
msg=`curl -s $url`
@biaocy
biaocy / pi.js
Created September 25, 2017 07:54
割圆术(刘徽)求π
function cx(lastM, r) { //求圆心到等边形的垂直距离
return Math.sqrt(r-Math.pow(lastM/2, 2));
}
function cm(lastM, r) { //求等边形边长
var x = cx(lastM, r); //圆心到等边形边的垂直距离
return Math.sqrt(Math.pow(r-x, 2) + Math.pow(lastM/2, 2));
}
function pi(t) {