Skip to content

Instantly share code, notes, and snippets.

View ghostcode's full-sized avatar
🎯
Focusing

蝎子 ghostcode

🎯
Focusing
  • SH,China
View GitHub Profile
@ghostcode
ghostcode / throttle.md
Created January 3, 2016 07:59
节流函数对高频操作限制调用次数,以此提高性能
var throttle = {
    switch:false,
    timer:100,
    process:function(method,context){
        var self = this;
        if(self.switch){
            return;
        }
 self.switch = true;
@ghostcode
ghostcode / amd-jquery-plugin.js
Created January 6, 2016 06:24 — forked from simonsmith/amd-jquery-plugin.js
AMD compatible plugin for jQuery
// UMD dance - https://github.com/umdjs/umd
!function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(root.jQuery);
}
}(this, function($) {
'use strict';
@ghostcode
ghostcode / getVendorPropertyName.js
Last active January 26, 2016 03:10 — forked from jonraasch/jQuery.support-transition.js
Extends the jQuery.support object to CSS3 transition
function getVendorPropertyName(prop) {
// Handle unprefixed versions (FF16+, for example)
if (prop in div.style) return prop;
var prefixes = ['Moz', 'Webkit', 'O', 'ms'];
var prop_ = prop.charAt(0).toUpperCase() + prop.substr(1);
for (var i=0; i<prefixes.length; ++i) {
var vendorProp = prefixes[i] + prop_;
if (vendorProp in div.style) { return vendorProp; }
@ghostcode
ghostcode / version_compare.js
Created March 17, 2016 05:45 — forked from six8/version_compare.js
Javascript to compare different software version strings (ex: 1.0.4 vs 1.1.4). Can handle pre, beta, etc prefixes/suffixes.
// Some versions to test [v1, v2, expected result]
var versions = [
['1.2.0', '1.2', 0],
['1.4', '1.7.2', 1],
['1.2pre', '1.2', 1],
['1.7', '1.1.1', -1],
['1.7.9RC1', '1.7.9RC2', 1],
['1.7.9RC1', '1.7.9RC', -1],
['1.7.9RC1', '1.7.9', 1],
['0.4beta', '0.4', 1],
@ghostcode
ghostcode / compare.js
Created June 20, 2016 03:16 — forked from alexey-bass/compare.js
JavaScript version compare
/**
* Simply compares two string version values.
*
* Example:
* versionCompare('1.1', '1.2') => -1
* versionCompare('1.1', '1.1') => 0
* versionCompare('1.2', '1.1') => 1
* versionCompare('2.23.3', '2.22.3') => 1
*
* Returns:
@ghostcode
ghostcode / meta-tags.md
Created September 7, 2016 03:56 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@ghostcode
ghostcode / visibly.js
Created November 18, 2016 02:51 — forked from addyosmani/visibly.js
Cross-browser Page Visibility API polyfill
/*!
* isVis - v0.5.5 Aug 2011 - Page Visibility API Polyfill
* Copyright (c) 2011 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*/
(function () {
window.visibly = {
b: null,
q: document,
@ghostcode
ghostcode / .gitignore
Created November 21, 2016 06:45 — forked from smebberson/.gitignore
Express simple authentication example
node_modules
*.swp
@ghostcode
ghostcode / index.jade
Created November 22, 2016 05:23
Material Navigation Pure CSS
form
input(type='radio' name='tab')#menu
.container
input(type='radio' name='tab' checked)#home
section.home
h1 Home
label(for='home')
input(type='radio' name='tab')#about
section.about
h1 About
@ghostcode
ghostcode / sample-nginx.conf
Created January 7, 2017 14:54 — forked from cjus/sample-nginx.conf
AngularJS Nginx and html5Mode
server {
server_name yoursite.com;
root /usr/share/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}