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 path = require('path') | |
| var fs = require('fs') | |
| let pattern | |
| let except | |
| if (process.argv.length == 3) pattern = toRE(process.argv[2]) | |
| if (process.argv.length == 4) { | |
| pattern = toRE(process.argv[2]) | |
| except = toRE(process.argv[3]) | |
| } |
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
| // 循环 | |
| let find = (str, keyword) => { | |
| let i = 0, arr = [] | |
| let index = 0 | |
| while (true) { | |
| index = str.indexOf(keyword, i) | |
| if (index == -1) break | |
| arr.push(index) | |
| i = index + 1 | |
| } |
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 MS_DAY = 1000 * 60 * 60 * 24; | |
| var MS_HOUR = 1000 * 60 * 60; | |
| var MS_MINUTE = 1000 * 60; | |
| var MS_SECOND = 1000; | |
| function addBit(num) { | |
| var str = "" + num; | |
| if (num < 10 && num > -1) { | |
| str = "0" + num; | |
| } |
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
| // ==UserScript== | |
| // @name msn header | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match https://www.msn.com/* | |
| // @grant none | |
| // ==/UserScript== |
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
| { | |
| "window.zoomLevel": 1, | |
| "editor.fontSize": 20, | |
| "files.autoSave": "onFocusChange", | |
| "editor.fontFamily": "'source code pro','lucida console',Consolas, 'Courier New', monospace", | |
| "editor.renderWhitespace": "boundary", | |
| "extensions.autoUpdate": true, | |
| "editor.wrappingColumn": 0, | |
| "editor.lineHeight": 29, | |
| "files.trimTrailingWhitespace": true, |
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
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Println("Hello, World", "!") // 参数以空格分隔 | |
| fmt.Print(1, 2, 3, "a", "\n") // 非字符串参数以空格分隔 | |
| fmt.Printf("%s, %s! %d", "Hello", "World", 12) // 第一个字符串是标准字符串,将后面的参数填充到标准字符串中 | |
| } |
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 CryptoJS = require("crypto-js");//replace thie with script tag in browser env | |
| //encrypt | |
| var rawStr = "hello world!"; | |
| var wordArray = CryptoJS.enc.Utf8.parse(rawStr); | |
| var base64 = CryptoJS.enc.Base64.stringify(wordArray); | |
| console.log('encrypted:', base64); | |
| //decrypt | |
| var parsedWordArray = CryptoJS.enc.Base64.parse(base64); |
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
| /** | |
| * 1. Original JS Implementation by Jeff Greenberg 2/2001 - http://home.earthlink.net/~kendrasg/info/js_opt/ | |
| * 2. (fast duff's device) from an anonymous donor to Jeff Greenberg's site | |
| * 3. (faster duff's defice) by Andrew King 8/2002 for WebSiteOptimization.com | |
| * 4. bug fix (for iterations<8) by Andrew B. King April 12, 2003 | |
| */ | |
| function duffsDevice (iterations) { | |
| var testVal = 0, | |
| n = iterations % 8; |
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 B = {}; | |
| B.url = {}; | |
| // 获取search 或 hash 中的参数 | |
| B.url.getParam = function(name, url) { | |
| url = url || location.href; | |
| var reg = new RegExp("(^|&|\\?|#)" + name + "=([^&]*?)(&|#|$)"); | |
| var tempHash = url.match(/#.*/) ? url.match(/#.*/)[0] : ""; | |
| url = url.replace(/#.*/, ""); | |
| if (reg.test(tempHash)) { |
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 createClass = function (Parent, props) { | |
| if (arguments.length === 1) { | |
| props = Parent; | |
| Parent = null; | |
| } | |
| var Child, F, i; | |
| // 1. 构造函数 | |
| Child = function Klass() { |