Skip to content

Instantly share code, notes, and snippets.

@lawvs
lawvs / PI
Last active April 14, 2017 13:44
π
const double pi = acos(double(-1));
@lawvs
lawvs / robots.txt
Last active January 19, 2018 02:48
禁止所有爬虫收录
User-agent: *
Disallow: /
@lawvs
lawvs / .gitattributes
Created January 19, 2018 02:52
git相关配置
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
@lawvs
lawvs / log.js
Last active February 18, 2018 13:29
js发送异常日志
window.addEventListener('error', function (e) {
const stack = e.error.stack;
let message = e.error.toString();
if (stack) {
message += '\n' + stack;
}
const xhr = new XMLHttpRequest();
xhr.open('POST', '/log', true);
xhr.send(message);
});
@lawvs
lawvs / main.js
Created February 26, 2018 02:25
html标签状态改变时改变html标题
document.addEventListener('visibilitychange', function () {
document.hidden ? document.title = '(●—●)喔哟,崩溃啦!'
: document.title = '(/≧▽≦/)咦!又好了!'
})
@lawvs
lawvs / editable.js
Created March 1, 2018 17:00
网页进入编辑模式
javascript:document.body.contentEditable='true';document.designMode='on'; void(0);
@lawvs
lawvs / highlights.js
Created March 2, 2018 01:54
高亮HTMLElement
/**
* Highlights text within a dom element.
*
* Specifically this is designed to work with the output
* positions of terms returned from a lunr search.
*
* @param {HTMLElement} element - the element that contains text to highlight.
* @param {MatchLocation[]} matches - the list of matches to highlight.
*/
module.exports = function (element, matches) {
@lawvs
lawvs / changeEmail.sh
Last active March 10, 2018 14:12
Git核弹级操作
#!/bin/sh
git filter-branch --commit-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="your-correct-name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ];
then
GIT_AUTHOR_NAME="$CORRECT_NAME";
@lawvs
lawvs / .sh
Created April 12, 2018 16:04
bash color
#!/bin/bash
red='\e[91m'
green='\e[92m'
yellow='\e[93m'
magenta='\e[95m'
cyan='\e[96m'
none='\e[0m'
# Root
@lawvs
lawvs / customize.ahk
Created April 26, 2018 04:05
a AHK Script
/*
enhance CapsLock
CapsLock -> Backspace
C - CapsLock -> Delete
A - CapsLock -> Enter
*/
SetCapsLockState, AlwaysOff
CapsLock::SendInput {Backspace}
+CapsLock::SendInput {Delete}
^CapsLock::SendInput {Enter}