Instantly share code, notes, and snippets.

View debugger.js
{
dotenv: '/Users/liuliang/Desktop/project/after-effects/.env',
appPath: '/Users/liuliang/Desktop/project/after-effects',
appBuild: '/Users/liuliang/Desktop/project/after-effects/build',
appPublic: '/Users/liuliang/Desktop/project/after-effects/public',
appHtml: '/Users/liuliang/Desktop/project/after-effects/public/index.html',
appIndexJs: '/Users/liuliang/Desktop/project/after-effects/src/index.js',
appPackageJson: '/Users/liuliang/Desktop/project/after-effects/package.json',
appSrc: '/Users/liuliang/Desktop/project/after-effects/src',
testsSetup: '/Users/liuliang/Desktop/project/after-effects/src/setupTests.js',
View parseURLParameters.js
function getUrlParams(search) {
let hashes = search.slice(search.indexOf('?') + 1).split('&')
let params = {}
hashes.map(hash => {
let [key, val] = hash.split('=')
params[key] = decodeURIComponent(val)
})
return params
}
View WAJavascriptBridge.js
(function () {
if (navigator.userAgent.match(/(iPad|iPhone|iPod).*?YY/g)) {
if (
(window.opener == null && window.YYApiCore == null) ||
(window.opener != null && window.opener.YYApiCore == null) ||
(window.YYApiCore && window.YYApiCore.invokeClientMethod && window.YYApiCore.invokeClientMethod.toString()
.length < 20)
) {
var i = document.createElement("iframe");
i.style.display = "none";
View gitignore_per_git_branch.md

How to have specific .gitignore for each git branch

Objective

My objective is to have some production files ignored on specific branches. Git doesn't allow to do it.

Solution

My solution is to make a general .gitignore file and add .gitignore.branch_name files for the branches I want to add specific file exclusion. I'll use post-checkout hook to copy those .gitignore.branch_name in place of .git/info/exclude each time I go to the branch with git checkout branch_name.

View 1.md

Some things that are "better" with this BetterPromise implementation:

  • BetterPromise # then(..) accepts a BetterPromise (or Promise) instance passed directly, instead of requiring a function to return it, so that the promise is linked into the chain.

    var p = BetterPromise.resolve(42);
    
    var q = Promise.resolve(10);
    
    p.then(console.log).then(q).then(console.log);
View swagger-update.yml
openapi: 3.0.1
servers:
- url: 'http://ysapi.yy.com/api/internal'
description: http
- url: 'https://ysapi.yy.com/api/internal'
description: https
info:
description: 营收业务接口文档
version: 1.0.0
title: ysapi
View tmux-cheatsheet.markdown

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

View safari-reaper.html
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
background: repeat url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/7QCIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGscAVoAAxslRxwCAAACAAAcAnQAV8KpIENoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbGQgLSBodHRwOi8vd3d3LnJlZGJ1YmJsZS5jb20vcGVvcGxlL0NoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAACAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAAAAAAABJzUkdCIElFQzYxOTY2LTIuMQAAAAAAAA
View Google Chrome Incognito.applescript
if application "Google Chrome" is running then
tell application "Google Chrome" to make new window with properties {mode:"incognito"}
else
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"
end if
tell application "Google Chrome" to activate