Skip to content

Instantly share code, notes, and snippets.

View wangbinyq's full-sized avatar
🦀
Build Cool Things

wangb wangbinyq

🦀
Build Cool Things
  • Shanghai
View GitHub Profile
def qsort(L):
if len(L) <= 1: return L
return qsort( [ lt for lt in L[1:] if lt < L[0] ] ) + \
[ L[0] ] + qsort( [ ge for ge in L[1:] if ge >= L[0] ] )
var cbs = []
for(var i=0; i<10; i++) {
cbs.push(function(){console.log(i);});
}
for(var c=0; c<cbs.length; c++) { // index must not be *i*
cbs[c](); // output: 10 ... 10
}
//------
div {
/* start 垂直居中 */
position: absolute;
bottom: 0;
right: 0;
top: 0;
left: 0;
margin: auto;
/* end */
height: 200px;
//1. html
<script src="js/require.js" data-main="js/main"></script>
//2. main.js
requirejs.config({
baseUrl: 'js/',
paths: [
jQuery: 'lib/jQuery.min',
underscore: 'lib/underscore.min'
],
@wangbinyq
wangbinyq / cvim.rc
Last active December 24, 2018 03:36
map h previousTab
map l nextTab
map H goBack
map L goForward
map J scrollLeft
map K scrollRight
map u lastClosedTab
let blacklists = ["http://localhost/*"]
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
@wangbinyq
wangbinyq / gulpfile.js
Last active January 24, 2017 19:37
gulp browserify babel
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var plumber = require('gulp-plumber');
var babelify = require('babelify');
@wangbinyq
wangbinyq / mvvm.js
Last active October 24, 2016 08:50
(function() {
'use strict'
;function defined(o) {
return o !== undefined && o !== null
}
;function Binding(vm, el, key, binder) {
this.vm = vm
this.el = el
@wangbinyq
wangbinyq / findClass.js
Created January 18, 2017 02:10
find how many html element have class or id
(() => {
const $ = document.querySelectorAll.bind(document)
const info = {}
const total = [0, 0]
$('*').forEach((el) => {
const nodeName = el.nodeName
const tagInfo = (info[nodeName] = info[nodeName] || [0, 0])
tagInfo[0] += 1