Skip to content

Instantly share code, notes, and snippets.

@yuanliwei
yuanliwei / google translate.js
Created November 28, 2018 09:42
google translate.js
var buildTkparam = function (a) {
var is = function (a) {
return function () {
return a
}
}, js = function (a, b) {
for (var c = 0; c < b.length - 2; c += 3) {
var d = b.charAt(c + 2);
d = "a" <= d ? d.charCodeAt(0) - 87 : Number(d);
d = "+" == b.charAt(c + 1) ? a >>> d : a << d;
@yuanliwei
yuanliwei / flex 布局属性.md
Created November 20, 2018 16:23
flex 布局属性.md
@yuanliwei
yuanliwei / vim 常用命令.md
Last active November 20, 2018 16:20
vim 常用命令.md

vim 常用命令

  • :help 查看帮助
  • w 定位到下一个单词的开头
  • e 定位到下一个单词的结尾
  • b 定位到上一个单词的开头
  • ge 定位到上一个单词的结尾
  • u 撤销
  • Ctrl+R 重做
  • :shell 打开新终端
  • Ctrl+E 滚动屏幕
@yuanliwei
yuanliwei / Git 统计命令.md
Last active April 12, 2019 02:59
Git 统计命令.md

统计每个人的代码行数

git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done

用户提交次数排名

  • git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r
  • git shortlog | grep '^[^ ]'

邮箱提交次数排名

git log --pretty=format:%ae | gawk -- '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' | sort -u -n -r

@yuanliwei
yuanliwei / node watch file change.js
Created November 20, 2018 16:16
node watch file change.js
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');
var ignores = '.git,doc,tool'.split(',')
var watchDir = '.'
function onFileUpdate() {
console.log('onFileUpdate....................');
// exec(`adb push `)
@yuanliwei
yuanliwei / Atom keymap.cson
Last active November 25, 2018 04:31
Atom keymap.cson
'atom-workspace':
'alt-shift-p': 'application:reopen-project'
'alt-cmd-up': 'core:cmd-move-up'
'alt-cmd-down': 'core:cmd-move-down'
'alt-cmd-left': 'core:cmd-move-left'
'alt-cmd-right': 'core:cmd-move-right'
'atom-text-editor':
'alt-down': 'symbols-view-master:go-to-declaration'
'alt-up': 'symbols-view-master:return-from-declaration'
'f5': 'core:undo'
@yuanliwei
yuanliwei / snippets.cson
Created November 20, 2018 16:13
Atom snippets
'.source.js':
'filter':
'prefix': 'filter'
'body': """filter((item)=>{
return item$1
})"""
'map':
'prefix': 'map'
'body': """map((item)=>{
return item$1
@yuanliwei
yuanliwei / Date format.js
Created November 20, 2018 16:11
Date Format.js
Date.prototype.Format = function(fmt) {
//author: meizz
var o = {
"M+": this.getMonth() + 1,
//月份
"d+": this.getDate(),
//日
"h+": this.getHours(),
//小时
"m+": this.getMinutes(),
@yuanliwei
yuanliwei / fetchWildDogApps.js
Created November 20, 2018 16:04
fetchWildDogApps
async function fetchWildDogApps() {
for (var i = 0; i < 100; i++) {
var html = await GET(`https://github.com/search?p=${i+1}&q=.wilddogio.com&type=Code&_pjax=%23js-pjax-container`)
var urls = html.match(/https?:\/\/[^<]{1,50}.<em>wilddogio<\/em>.<em>com<\/em>/g)
if (!urls) { continue }
urls.map((item)=>item.replace(/<[^.]+>/g,''))
window.globalUrls = [...new Set(window.globalUrls.concat(urls))]
console.log(window.globalUrls.length, i);
}
}
@yuanliwei
yuanliwei / XMLHttpRequest get post.js
Created November 20, 2018 15:33
XMLHttpRequest GET POST
function GET(url) {
return new Promise(function(resolve, reject) {
var request = new XMLHttpRequest()
request.open('GET', url, true)
request.onreadystatechange = () => {
console.log(' - readyState:' + request.readyState + ' status:' + request.status)
if (request.readyState == 4) {
resolve(request.responseText)
}
}