Skip to content

Instantly share code, notes, and snippets.

View black-black-cat's full-sized avatar

bcatb black-black-cat

View GitHub Profile
@black-black-cat
black-black-cat / cryptojs_base64_encrypt_decrypt.js
Created August 31, 2016 06:15 — forked from joecliff/cryptojs_base64_encrypt_decrypt.js
An example of base64 usage in cryptojs
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);
@black-black-cat
black-black-cat / go_fmt.go
Created January 20, 2017 10:42
fmt in go
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) // 第一个字符串是标准字符串,将后面的参数填充到标准字符串中
}
@black-black-cat
black-black-cat / settings.json
Last active May 27, 2017 16:10
vscode 用户配置
{
"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,
@black-black-cat
black-black-cat / msn_header.js
Last active April 3, 2017 04:00
去除 msn 顶部菜单
// ==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==
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;
}
@black-black-cat
black-black-cat / indexes.js
Last active July 23, 2017 07:04
匹配关键词在字符串中各处出现的位置的索引,组成数组。
// 循环
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
}
@black-black-cat
black-black-cat / node_getAllFiles.js
Created July 12, 2017 08:22
在 `base` 目录以及其后代目录中查找匹配 `pattern` 的文件;目录或文件为 `except` 时,除外
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])
}
@black-black-cat
black-black-cat / lastDateOfMonth.js
Created November 27, 2017 11:06
获取一个月的最后一天
function getLastDate(y, m) { return new Date(m > 11 ? y + 1 : y, m % 12, 0) }
@black-black-cat
black-black-cat / npm-global.txt
Created November 28, 2017 05:57
npm 全局包
C:\Users\Administrator\AppData\Roaming\npm
+-- [email protected]
+-- [email protected]
+-- [email protected] -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\.browser-sync_npminstall\node_modules\.2.18.6@browser-sync
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected] -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\.generator-fountain-vue_npminstall\node_modules\.1.0.0-rc2@generator-fountain-vue
@black-black-cat
black-black-cat / vendor.js
Last active December 2, 2017 07:26
样式名加前缀
function vendor(style) {
if (!styles[style]) {
prefixes.map(function (prefix) {
return prefix
? prefix + style[0].toUpperCase() + style.slice(1)
: style
}).some(function (prefixedStyle) {
if (elementStyle[prefixedStyle] !== void 0) {
styles[style] = prefixedStyle
return true