Skip to content

Instantly share code, notes, and snippets.

View ghostcode's full-sized avatar
🎯
Focusing

Zhuxy ghostcode

🎯
Focusing
View GitHub Profile
/**
* @ NAME: Cross-browser TextStorage
* @ DESC: text storage solution for your pages
* @ COPY: sofish, http://sofish.de
*/
typeof window.localStorage == 'undefined' && ~function () {
var localStorage = window.localStorage = {},
prefix = 'data-userdata',
doc = document,
@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 / 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 / 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