Skip to content

Instantly share code, notes, and snippets.

View bitflower's full-sized avatar

Matthias Max bitflower

View GitHub Profile
@bitflower
bitflower / gist:1d89db90217774af8221
Created January 29, 2015 14:32
Allow SVG through WordPress Media Uploader
// For your functions.php file or a functionality plugin:
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
@bitflower
bitflower / gist:8af5390a9bb54fe9184d
Created January 16, 2015 12:46
Vertically align img inline
<div>
<img style="vertical-align: middle;">
<span style="">Works.</span>
</div>
@bitflower
bitflower / gist:ddb1c1110ca6a0e9ecca
Created January 15, 2015 13:48
IE8 Fix for selectionStart
// input = the text box
if (input.selectionStart) {
return input.selectionStart;
} else {
return 0;
}
@bitflower
bitflower / gist:2bea501c0b80215d87d9
Created January 15, 2015 10:24
Bookmarklet for getting jQuery version
javascript:(function(){console.log('jQuery%20Version:%20'+jQuery().jquery);})();
@bitflower
bitflower / gist:ee1d9146cc687894498d
Created January 15, 2015 06:45
Cut decimal number after 2 digits
// You could use Math.floor and some additional arithmetics:
Math.floor(15.7784514000 * 100) / 100
// Or convert the number into a string, match the number up to the second decimal place and turn it back into a number:
Number(15.7784514000.toString().match(/^\d+(?:\.\d{0,2})?/))
// Then you can still call toFixed to get a string with a fixed number of decimal places.
app.filter('trusthtml', ['$sce', function ($sce) {
return function(t) {
return $sce.trustAsHtml(t)
}
}]);
@bitflower
bitflower / gist:65d8d9fd46f2a10c5795
Created January 12, 2015 10:22
Add CORS support to DaftMonk/angular-fullstack YO generator
1. npm install cors
2. then in the app module:
var cors = require('cors');
//add cors to do the cross site requests
app.use(cors());
@bitflower
bitflower / gist:e63cf54f8c6af27e39c5
Created January 9, 2015 11:49
Activate CORS in PHP
// First line of first PHP file
header( "Access-Control-Allow-Origin: *" );
@bitflower
bitflower / gist:bd7b9cceead1ff914e75
Created January 8, 2015 07:09
Stop scroll bouncing on touch devices
// Stop scroll bouncing
document.ontouchmove = function(e) {
e.preventDefault();
};
@bitflower
bitflower / classie.js
Last active August 29, 2015 14:12 — forked from desandro/classie.js
/*!
* classie - class helper functions
* from bonzo https://github.com/ded/bonzo
*
* classie.has( elem, 'my-class' ) -> true/false
* classie.add( elem, 'my-new-class' )
* classie.remove( elem, 'my-unwanted-class' )
*/
/*jshint browser: true, strict: true, undef: true */