This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! MyVerticalMotions(up) | |
let motion = "j" | |
if a:up | |
let motion = "k" | |
endif | |
execute "normal! " . motion | |
while synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") == "Comment" && line('.') < line('$') && line('.') > 1 | |
execute "normal! " . motion | |
endwhile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collection { | |
constructor(set) { | |
if (!['Set', 'Array'].includes(set.constructor.name)) { | |
throw new Error("Conllection 的构造函数只接收Set和Array对象") | |
} | |
this._entries = Array.from(set) | |
this._index = -1 | |
} | |
[Symbol.iterator]() { | |
let that = this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let loadImage = (img, src)=>{ | |
return new Promise((resolve, reject)=>{ | |
img.onload = ()=>{ | |
resolve(img) | |
} | |
img.src = src | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attributeChangedCallback(attr, oldValue, newValue) { | |
super.attributeChangedCallback(attr, oldValue, newValue) | |
if (!this.watch || !this.watch.apply) { | |
return null | |
} | |
if (!this._watch) { | |
this._watch = this.watch() | |
} | |
if (this._watch.hasOwnProperty(attr)) { | |
const watcher = this._watch[attr] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tmpl = require('lodash.template') | |
const tmplOption = { | |
evaluate: /{{([\s\S]+?)}}/g, | |
escape: /{{-([\s\S]+?)}}/g, | |
interpolate: /{{=([\s\S]+?)}}/g, | |
} | |
template(str) { | |
return tmpl(str, tmplOption) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
And connect with a tcp client from the command line using netcat, the *nix | |
utility for reading and writing across tcp/udp network connections. | |
$ netcat 127.0.0.1 1337 | |
You should see: | |
> Echo server | |
*/ | |
/* Or use this example tcp client written in node.js. (Originated with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* subscriptions data format: | |
* { eventType: { id: callback } } | |
*/ | |
const subscriptions = { } | |
const getNextUniqueId = getIdGenerator() | |
function subscribe(eventType, callback) { | |
const id = getNextUniqueId() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
Math.uuid.js (v1.4) | |
http://www.broofa.com | |
mailto:[email protected] | |
Copyright (c) 2010 Robert Kieffer | |
Dual licensed under the MIT and GPL licenses. | |
*/ | |
/* |