Skip to content

Instantly share code, notes, and snippets.

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
@zzzgit
zzzgit / collection.js
Created September 22, 2019 10:09
a lib for poker
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
let loadImage = (img, src)=>{
return new Promise((resolve, reject)=>{
img.onload = ()=>{
resolve(img)
}
img.src = src
})
}
@zzzgit
zzzgit / attributeChangedCallback.js
Last active September 3, 2019 03:49
watcher implements in lit-element
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]
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)
}
@zzzgit
zzzgit / .....
Created July 13, 2019 07:04
bash.script
# ~/.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
/*
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
/**
* subscriptions data format:
* { eventType: { id: callback } }
*/
const subscriptions = { }
const getNextUniqueId = getIdGenerator()
function subscribe(eventType, callback) {
const id = getNextUniqueId()
/*!
Math.uuid.js (v1.4)
http://www.broofa.com
mailto:robert@broofa.com
Copyright (c) 2010 Robert Kieffer
Dual licensed under the MIT and GPL licenses.
*/
/*