Skip to content

Instantly share code, notes, and snippets.

View cuing's full-sized avatar

delicacy cuing

  • 携程旅行网
  • Shang Hai
View GitHub Profile
@cuing
cuing / record.js
Created April 23, 2014 05:30
High Performance Browser Networking
// the file is split and uploaded in chunks via multiple XHR requests
/*
Slicing large file uploads is a good technique to provide more robust
API where connectivity is unstable or intermittent—e.g., if a chunk
fails due to dropped connection, the application can retry, or resume
the upload later instead of restarting the full transfer from the start.
*/
var blob = [];
@cuing
cuing / jsPattern.js
Created March 8, 2014 10:07
JavaScript Patterns
// 类继承模式 uber 存储超类
function inherit(C, P) {
var F = function(){};
F.prototype = P.prototype;
C.prototype = new F();
C.uber = P.prototype;
C.prototype.constructor = C;
}
/*
Array generic methods
These are currently not part of ECMAScript standards (though the ES6 Array.from() can be used to achieve this).
The following is a shim to allow its use in all browsers:
src: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
*/
(function () {
'use strict';
@cuing
cuing / picLoad.js
Created December 18, 2013 02:33
图片加载完成
// script 1
var img = document.getElementById('image1');
img.addEventListener('load', function() {
// loaded handing
})
img.addEventListener('error', function() {
// error handing
})
#autoresize {
resize: none;
outline: none;
width: 300px;
word-break: break-all;
font-family:sans-serif;
font-size: 1em;
line-height: 1.2em;
margin: 0px;
}
@cuing
cuing / JavaScriptDOM.js
Created November 10, 2013 06:24
JavaScript DOM 编程艺术 Script
// 页面加载完成后调用方法
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof oldonload !== 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
[
{
name:"HTML5",
uri:"http://www.w3.org/TR/html5/single-page.html",
category:"markup"
},
{
name:"HTML 5.1",
uri:"http://www.w3.org/TR/html51/single-page.html",
category:"markup"