Skip to content

Instantly share code, notes, and snippets.

View uolcano's full-sized avatar

uolcano uolcano

View GitHub Profile
@uolcano
uolcano / arrayLooper.js
Created July 28, 2016 15:46
Customized integrated array looper[index-specified, support forwards or backwards, break and continue]
/***************************************************************************************************
* @param {Array} [arr] [the array to be iterated]
*
* @param {Function} [process] [the callback to process the element in array]
* (elm, idx, arr, resolve)
* @description [process(elm, idx, arr, resolve) { return true; // return true to terminate current loop }]
*
* @param {Object} [options] [the iteration configurations]
* {loopStart, loopEnd, travType}
* @description [loopStart inclusive the index, loopEnd exclusive the index]
@uolcano
uolcano / cookies.js
Created August 5, 2016 15:34
Some cookie method set
var uTools = {};
/*****************
The cookie method set
*****************/
! function ($) {
$.cookies = {
get: function (name) {
var cookies = document.cookie,
name = encodeURIComponent(name) + '=',
start = cookies.indexOf(name),
@uolcano
uolcano / uTools.js
Last active August 6, 2016 04:14
Some scripts
var uTools = {};
/************************************
Compatible solution for native methods
************************************/
! function () {
'use strict';
if (typeof Object.create != 'function') {
Object.create = function () {
var Temp = function () {};
return function (proto) {
@uolcano
uolcano / EventWrap&MultiEventWrap.js
Created August 16, 2016 10:45
An object(s) event wrapper method, compatible with IE8+
! function() {
if (typeof Array.prototype.forEach != 'function') {
Array.prototype.forEach = function(fn) {
var arr = Object(this),
i = 0,
len = 0;
if (Object.prototype.toString.call(arr).slice(8, -1) != 'Array') {
console.log('Error: Array.prototype.indexOf - the caller must be an array!');
return;
}
@uolcano
uolcano / typeof.js
Last active August 25, 2016 15:20
get the accurate type of certain data by native JavaScript
var _create = Object.create,
_slice = Array.prototype.slice,
_toString = Object.prototype.toString,
_hasOwn = Object.prototype.hasOwnProperty;
/**
* [getTypeOf Get the data type of some data]
* @param {any type} arg [the data to get type]
* @return { string } [the string to describe the data type]
*
* usage:
@uolcano
uolcano / performanceOptimization.js
Last active August 25, 2016 15:36
Some performance optimization
function isArray (arg) {
return Object.prototype.toString.call(arg).slice(8, -1) === 'Array';
}
/**
* [chunk Array chunk iteration]
* @param { array } arr [array to iterate]
* @param {function} fn [function to process array]
* @param {integer } intv [iteration interval milliseconds]
* @param {function} success [function for async invocation when iteration complete]
* @param { object } ctx [context to invoke the function]
@uolcano
uolcano / 0_reuse_code.js
Created March 12, 2017 14:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@uolcano
uolcano / My Tips To Use GitHub.md
Created March 19, 2017 17:09
My Tips To Use GitHub

收集GitHub使用技巧

快捷键Shortcut

Shortcut Description Shortcut Description
Site wide shortcuts ———— Commit list ————
s Focus search bar y Expand URL to its canonical form
g n Go to Notifications Dashboards ————
g d Go to Dashboard g i Go to your issues
? Bring up this help dialog g p Go to your pull requests
@uolcano
uolcano / what-forces-layout.md
Created April 4, 2017 10:23 — 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()
@uolcano
uolcano / 0.Advanced Tricks on JavaScript.md
Last active May 8, 2018 06:16
Advanced Tricks on JavaScript