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 / 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 / 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 / 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 / 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 / flask-upload
Created December 15, 2015 06:28 — forked from dAnjou/flask-upload
Flask upload example
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
@ghostcode
ghostcode / handle_file_upload.php
Created November 29, 2015 11:19 — forked from ebidel/handle_file_upload.php
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@ghostcode
ghostcode / vue.js
Created November 22, 2015 14:02
Vue do not work arr.length = 0
this.paths.splice(0,this.paths.length)
@ghostcode
ghostcode / JavaScript-variable.md
Last active October 18, 2015 08:19
JavaScript变量复习
  1. JavaScript是非类型语言,及变量可以存储任何类型的值。
  2. JavaScript(以前)的程序多是短小的脚本,所以并不需要那么精确,而且我们从简单的语法中也获益匪浅。
  3. 变量在使用之前必须先声明(可以不赋值)。
  4. var声明的变量是永久性的,也就是说用delete运算符来删除这些变量会引发错误。
  5. 隐式声明的变量总是被创建为全局变量,即使是在函数中创建的。
  6. 隐式创建的变量可以使用delete运算符删除。
  7. 没有块级作用域
var scope = "global"
function f(){
@ghostcode
ghostcode / jsversion.md
Last active August 29, 2015 14:07
检测浏览器当前Javascript版本
<script type="text/javascript">
var jsver = 1.0;
</script>
<script language="Javascript1.1">
jsver = 1.1;
</script>
<script language="Javascript1.2">
jsver = 1.2;
@ghostcode
ghostcode / gist:6f507816906bee762ac5
Created September 25, 2014 09:48
documentReady.js
/*
jQuery's document.ready/$(function(){}) should
you wish to use a cross-browser DOMReady solution
without opting for a library.
Demo: http://jsfiddle.net/8j85t/
usage:
$(function(){
// your code