Skip to content

Instantly share code, notes, and snippets.

View jerrybendy's full-sized avatar
🏢
Hard working

Jerry Bendy jerrybendy

🏢
Hard working
View GitHub Profile
@jerrybendy
jerrybendy / flat-data-to-tree.js
Created March 29, 2019 02:23
Convert flat data to tree format 平铺格式转树状结构
/**
* Convert flat data to tree format
*
* @see http://blog.csdn.net/chelen_jak/article/details/21290769
*
* @param {array} a json数据
* @param {String} idStr id的字符串
* @param {String} pidStr 父id的字符串
* @param {String} childrenStr children的字符串
* @return {array} 数组
@jerrybendy
jerrybendy / resolveHttps.js
Created June 27, 2019 09:10
Force modify a URL to HTTPS if your website is under HTTPS
/**
* Force modify a URL to HTTPS if your website is under HTTPS
*
* @example resolveHttps('http://example.com')
* If you are under a HTTPS website, it'll return `https://example.com`,
* Else it'll return `http://example.com`
*
* @param {string} url
* @return {string}
*/
@jerrybendy
jerrybendy / loadScript.js
Created July 9, 2019 07:40
Load a JavaScript file from the server, then execute it.
/**
* Load a JavaScript file from the server, then execute it.
*
* Code comes from `https://github.com/ded/script.js`
* If your want more features, please follow the original
*
* @usage:
* loadScript('http://example.com/test.js', function() {
* console.log('Loaded')
* });