Skip to content

Instantly share code, notes, and snippets.

威老(Valor Lin) weilao

Block or report user

Report or block weilao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@weilao
weilao / matchAll.js
Created Apr 19, 2018
matchAll for RegExp
View matchAll.js
function matchAll(str, re) {
let result = [];
let match = null;
while ((match = re.exec(str)) !== null) {
result.push(match);
}
return result;
}
// Example
// matchAll('1.a 2.b 3.c', /\d\.([a-z])/g)
View brew_install_all.sh
brew update && brew upgrade
brew install composer duti htop nvm pcap_dnsproxy pyenv tig telnet zsh
brew cask install font-anonymous-pro
brew cask install wechatwebdevtools —appdir=/Applications
brew cask install adobe-air atom baidunetdisk bettertouchtool charles cyberduck dingtalk iterm2 mpv qq qqmusic scroll-reverser sourcetree telegram-desktop thunder visual-studio-code wiznote youdaodict webstorm
brew cask install betterzipql qlcolorcode qlimagesize qlmarkdown qlprettypatch qlstephen qlvideo quicklook-csv quicklook-json quicklookase suspicious-package webpquicklook
@weilao
weilao / npm.taobao.sh
Last active Jun 26, 2018 — forked from 52cik/npm.taobao.sh
npm 淘宝镜像配置
View npm.taobao.sh
npm set registry https://registry.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs # phantomjs 二进制包镜像
@weilao
weilao / removeGoogleRedirect.js
Last active Aug 29, 2015
【油猴脚本】去除 google 搜索重定向
View removeGoogleRedirect.js
// ==UserScript==
// @name 去除 google 搜索重定向
// @namespace http://doctype-html.com
// @version 0.1
// @description 去除 google 搜索重定向,提高访问速度
// @author Weilao
// @include *//www.google.com/*
// @grant none
// ==/UserScript==
@weilao
weilao / UnicodeConverter.js
Created May 11, 2015
to unicode and form unicode
View UnicodeConverter.js
var UnicodeConverter = {
toUnicode: function(str) {
return escape(str).toLocaleLowerCase().replace(/%u/gi, '\\u');
},
fromUnicode: function(str) {
return unescape(str.replace(/\\u/gi, '%u'));
}
};
@weilao
weilao / omitMiddle.js
Last active Aug 29, 2015
Omit middle for long string, middle version of `text-overflow: ellipsis`
View omitMiddle.js
/**
* Omit middle when a string is too long.
* Example:
* ```
* omitMiddle('veryveryveryveryveryveryveryveryveryverylongfilename.txt')
* // result: 'very......name.txt'
* ```
* @param str
* @param [replacement] Default: ......
* @param [frontCount] How many words you want to keep in the front. Default: 4
@weilao
weilao / showElementEdges.js
Last active Aug 29, 2015
Run this script in the console
View showElementEdges.js
function showElementEdges(el) {
[].forEach.call(el.querySelectorAll("*"), function(a) {
a.style.outline = "1px solid #" + (~~(Math.random() * (1 << 24))).toString(16)
})
}
You can’t perform that action at this time.