Skip to content

Instantly share code, notes, and snippets.

View githubxiaowen's full-sized avatar
💭
I may be slow to respond.

萧文 githubxiaowen

💭
I may be slow to respond.
  • Beijing China
View GitHub Profile
@githubxiaowen
githubxiaowen / debounce&throttle.js
Last active October 16, 2017 07:56
debounce&throttle
// https://css-tricks.com/debouncing-throttling-explained-examples/
//https://codepen.io/githubxiaowen/pen/WZaaJm?editors=1011
function debounce(fn,wait){
var timeout;
return function(){
clearTimeout(timeout);
timeout=setTimeout(function(){
fn()
},wait)
}
@githubxiaowen
githubxiaowen / js-snippets
Created October 9, 2017 06:03
vscode setting file
[
{
"key": "tab",
"command": "selectNextQuickFix",
"when": "editorFocus && quickFixWidgetVisible"
},
{
"key": "shift+tab",
"command": "selectPrevQuickFix",
"when": "editorFocus && quickFixWidgetVisible"
@githubxiaowen
githubxiaowen / config.js
Last active September 22, 2017 03:26
node-upload-file
module.exports={
"xiaowen":{
host:'localhost',
port:9001,
from:'src/',
to:'/root/node-receiver/dest/' // RD静态资源地址
}
}
@githubxiaowen
githubxiaowen / install_jdk.sh
Created September 15, 2017 11:50
install jdk using script
# get the jdk.tar.gz
```bash
BASE_URL_8=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144
JDK_VERSION=`echo $BASE_URL_8 | rev | cut -d "/" -f1 | rev`
declare -a PLATFORMS=("-linux-x64.tar.gz")
for platform in "${PLATFORMS[@]}"
@githubxiaowen
githubxiaowen / fiddler script.java
Created September 7, 2017 12:06
fiddler script
import System;
import System.Windows.Forms;
import Fiddler;
// INTRODUCTION
//
// Well, hello there!
//
// Don't be scared! :-)
//
@githubxiaowen
githubxiaowen / what-forces-layout.md
Created September 7, 2017 04:34 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@githubxiaowen
githubxiaowen / eventemitter.js
Created August 11, 2017 13:36
EventEmitter.js
class EventEmitter {
constructor() {
this.events = {}
this.maxEventListeners = 10;
}
on(eventName, handler) {
if(typeof handler!=='function') throw new TypeError('listener must be a function')
if (!this.events.eventName) {
this.events[eventName] = [];
@githubxiaowen
githubxiaowen / server.js
Created February 19, 2017 08:33
https-server
const https=require('https');
const http=require('http');
const fs=require('fs')
const express = require('express');
const httpApp=express();
const httpsApp=express();
httpsApp.use(require('helmet')());
const options={
var EventUtil = {
addHandler: function(element,type,handler) { //事件监听
if(element.addEventListener) {
element.addEventListener(type,handler,false);
}else if(element.attachEvent) {
element.attachEvent("on"+type,handler);
}else {
element["on" +type] = handler;
}
},